Изменение шрифтов в многострочном редакторе
Cоздать текстовый редактор, позволяющий с помощью диалоговых окон сохранять и открывать текстовые файлы , а также изменять характеристики шрифта и цвет компонента Memo.
procedure TForm1.Button1Click(Sender: TObject);
begin
with openDialog1 do
begin
if not Execute then exit;
memo1.lines.loadFromFile(FileName)
end;
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
with
saveDialog1 do
begin
if not Execute then exit;
memo1.lines.savetoFile(FileName)
end; end;
procedure TForm1.Button3Click(Sender: TObject);
begin
with fontDialog1 do
begin
if not Execute then exit;
memo1.font:=font;
end;
end;
procedure TForm1.Button4Click(Sender: TObject);
begin
close;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
memo1.Clear;
end;
end.
2. ПОЛЯРНАЯ СИСТЕМА КООРДИНАТ R=5*SINFI
TForm1 = class(TForm)
Chart1: TChart;
Button1: TButton;
Series1: TPointSeries;
procedure Button1Click(Sender: TObject);
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var i:integer; x,y,v,r:array[1..420] of real;
begin
for i:=1 to 420 do
begin
v[i]:=(i-1)*0.0157;
r[i]:=5*sin(5*v[i]);
x[i]:=r[i]*cos(v[i]);
y[i]:=r[i]*sin(v[i]);
end;
for i:=1 to 420 do
chart1.Series[0].AddXY(x[i],y[i],'',clred);
end;
end.
3. В chart y=sin(kx)
procedure TForm1.trckbr1Change(Sender: TObject);
var x,k:word;
begin
k:=trckbr1.Position;
Form1.Caption:=IntToStr(trckbr1.Position);
for x := 0 to 10 do
form1.series1.AddXY(x,Sin(k*x));
end;
ТИПЫ ЛИНИЙ
TForm1 = class(TForm)
implementation
{$R *.dfm}
procedure TForm1.FormPaint(Sender: TObject);
begin
//
with canvas do
begin
//сплошная
Pen.Style:=psSolid;
moveto(10,20);
lineto(200,20);
textout(250,10,'solid');
//тире
Pen.Style:=psDash;
moveto(10,40);
lineto(200,40);
textout(250,30,'dash');
//черточки
Pen.Style:=psDot;
moveto(10,60);
lineto(200,60);
textout(250,50,'dot');
//пунктир
Pen.Style:=psDashDot;
moveto(10,80);
lineto(200,80);
textout(250,70,'dashdot');
//смешанная
Pen.Style:=psDashDotDot;
moveto(10,100);
lineto(200,100);
textout(250,90,'dashdotdot')
end;
end;
|
|
end.
Дерево-каталог в соответствии в соответствии с внутренним дисковым носителем
TForm1 = class(TForm)
DirectoryListBox1: TDirectoryListBox;
DriveComboBox1: TDriveComboBox;
BitBtn1: TBitBtn;
procedure DriveComboBox1Change(Sender: TObject);
implementation
{$R *.dfm}
procedure TForm1.DriveComboBox1Change(Sender: TObject);
begin
DirectoryListBox1.Drive:=DriveComboBox1.Drive;
end;
end.
ВЫБОР РАЗМЕРА МАТРИЦЫ С ПОМОЩЬЮ КОМПОНЕНТА COMBOBOX. ВВОДА ЗНАЧЕНИЙ ЭЛЕМЕНТОВ МАТРИЦЫ В STRINGGRID. ВЫЧИСЛЕНИЕ СУММЫ ЧЕТНЫХ ЭЛЕМЕНТОВ МАТРИЦЫ
TForm1 = class(TForm)
ComboBox1: TComboBox;
Button1: TButton;
Button2: TButton;
Label1: TLabel;
StringGrid1: TStringGrid;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var i,j:integer;
begin
case ComboBox1.ItemIndex of
0:begin for i:=0 to 4 do
for j:=0 to 4 do
StringGrid1.Cells[j,i]:=' ';
stringGrid1.RowCount:=3; StringGrid1.ColCount:=3; end;
1: begin for i:=0 to 4 do
for j:=0 to 4 do
StringGrid1.Cells[j,i]:=' ';
StringGrid1.RowCount:=4; StringGrid1.ColCount:=4; end;
2: begin for i:=0 to 4 do
for j:=0 to 4 do
StringGrid1.Cells[j,i]:=' ';
StringGrid1.RowCount:=5; StringGrid1.ColCount:=5; end;
end;
end;
procedure TForm1.Button2Click(Sender: TObject);
var i,j,s:integer;
begin
s:=0;
if ComboBox1.ItemIndex=0 then begin
for j:=0 to 2 do
for i:=0 to 2 do
begin
label1.Visible:=true;
label1.Caption:=stringgrid1.Cells[j,i];
if strtoint(label1.Caption) mod 2=0 then
begin
label1.Visible:=true;
s:=s+strtoint(StringGrid1.Cells[j,i]);
label1.Caption:=inttostr(s);
end;
end;
end;
end;
if ComboBox1.ItemIndex=1 then begin
for j:=0 to 3 do
for i:=0 to 3 do
begin
label1.Visible:=true;
label1.Caption:=stringgrid1.Cells[j,i];
if strtoint(label1.Caption) mod 2=0 then
|
|
begin
label1.Visible:=true;
s:=s+strtoint(StringGrid1.Cells[j,i]);
label1.Caption:=inttostr(s);
end;
end;
end;
end;
end.
Изменение шрифта при вводе в Edit
TForm1 = class(TForm)
Edit1: TEdit;
RadioGroup1: TRadioGroup;
RadioGroup2: TRadioGroup;
RadioGroup3: TRadioGroup;
Button1: TButton;
BitBtn1: TBitBtn;
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
if radiogroup1.ItemIndex=-1
then showmessage('Необходимо выбрать цвет шрифта!')else
case radiogroup1.ItemIndex of
0:begin edit1.Font.Color:=clRed;
end;
1:begin edit1.Font.Color:=clGreen;
end;
2:begin edit1.Font.Color:=clBlue;
end;
3:begin edit1.Font.Color:=clYellow;
end;
4:begin edit1.Font.Color:=clMaroon;
end;
end;
if radiogroup2.ItemIndex=-1
then showmessage('Необходимо выбрать начертание шрифта!')else
case radiogroup2.ItemIndex of
0:begin edit1.Font.Style:= [fsBold];
end;
1:begin edit1.Font.Style:= [fsItalic];
end;
2:begin edit1.Font.Style:= [fsUnderline];
end;
3:begin edit1.Font.Style:= [fsStrikeout];
end;
end;
if radiogroup3.ItemIndex=-1
then showmessage('Необходимо выбрать размер шрифта!')else
case radiogroup3.ItemIndex of
0:begin edit1.Font.Size:=8;
end;
1:begin edit1.Font.Size:=10;
end;
2:begin edit1.Font.Size:=12;
end;
3:begin edit1.Font.Size:=14;
end;
4:begin edit1.Font.Size:=15;
end;
5:begin edit1.Font.Size:=18;
end;
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
edit1.Clear
end;
end.
Изменение шрифтов в многострочном редакторе
TForm1 = class(TForm)
RadioGroup1: TRadioGroup;
RadioGroup2: TRadioGroup;
RadioGroup3: TRadioGroup;
Button1: TButton;
BitBtn1: TBitBtn;
Memo1: TMemo;
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
implementation
|
|
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
if radiogroup1.ItemIndex=-1
then showmessage('Необходимо выбрать цвет шрифта!')else
case radiogroup1.ItemIndex of
0:begin memo1.Font.Color:=clRed;
end;
1:begin memo1.Font.Color:=clGreen;
end;
2:begin memo1.Font.Color:=clBlue;
end;
3:begin memo1.Font.Color:=clYellow;
end;
4:begin memo1.Font.Color:=clMaroon;
end;
end;
if radiogroup2.ItemIndex=-1
then showmessage('Необходимо выбрать начертание шрифта!')else
case radiogroup2.ItemIndex of
0:begin memo1.Font.Style:= [fsBold];
end;
1:begin memo1.Font.Style:= [fsItalic];
end;
2:begin memo1.Font.Style:= [fsUnderline];
end;
3:begin memo1.Font.Style:= [fsStrikeout];
end;
end;
if radiogroup3.ItemIndex=-1
then showmessage('Необходимо выбрать размер шрифта!')else
case radiogroup3.ItemIndex of
0:begin memo1.Font.Size:=8;
end;
1:begin memo1.Font.Size:=10;
end;
2:begin memo1.Font.Size:=12;
end;
3:begin memo1.Font.Size:=14;
end;
4:begin memo1.Font.Size:=15;
end;
5:begin memo1.Font.Size:=18;
end;
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
memo1.Clear
end;
end.
Дата добавления: 2018-04-15; просмотров: 179; Мы поможем в написании вашей работы! |
Мы поможем в написании ваших работ!