Заглавная страница Избранные статьи Случайная статья Познавательные статьи Новые добавления Обратная связь FAQ Написать работу КАТЕГОРИИ: ТОП 10 на сайте Приготовление дезинфицирующих растворов различной концентрацииТехника нижней прямой подачи мяча. Франко-прусская война (причины и последствия) Организация работы процедурного кабинета Смысловое и механическое запоминание, их место и роль в усвоении знаний Коммуникативные барьеры и пути их преодоления Обработка изделий медицинского назначения многократного применения Образцы текста публицистического стиля Четыре типа изменения баланса Задачи с ответами для Всероссийской олимпиады по праву
Мы поможем в написании ваших работ! ЗНАЕТЕ ЛИ ВЫ?
Влияние общества на человека
Приготовление дезинфицирующих растворов различной концентрации Практические работы по географии для 6 класса Организация работы процедурного кабинета Изменения в неживой природе осенью Уборка процедурного кабинета Сольфеджио. Все правила по сольфеджио Балочные системы. Определение реакций опор и моментов защемления |
Cоздать текстовый редактор, позволяющий с помощью диалоговых окон сохранять и открывать текстовые файлы , а также изменять характеристики шрифта и цвет компонента Memo.Содержание книги
Поиск на нашем сайте 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.
Узнать имя файла дериктории и сделать ее текущей unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, ShellApi, FileCtrl, ExtCtrls, jpeg, Buttons, ComCtrls; type TForm1 = class(TForm) FileListBox1: TFileListBox; DirectoryListBox1: TDirectoryListBox; DriveComboBox1: TDriveComboBox; FileListBox2: TFileListBox; DirectoryListBox2: TDirectoryListBox; DriveComboBox2: TDriveComboBox; BitBtn1: TBitBtn; BitBtn2: TBitBtn; procedure BitBtn1Click(Sender: TObject); procedure BitBtn2Click(Sender: TObject); private { Private declarations } public { Public declarations } end; var Form1: TForm1; x,y: string; iconindex:integer; implementation {$R *.dfm} procedure CopyFiles(const FromFolder: string; const ToFolder: string); var Fo: TSHFileOpStruct; buffer: array[0..4096] of char; p: pchar; begin FillChar(Buffer, sizeof(Buffer), #0); p:= @buffer; StrECopy(p, PChar(FromFolder)); //директория, которую мы хотим скопировать FillChar(Fo, sizeof(Fo), #0); Fo.Wnd:= Application.Handle; Fo.wFunc:= FO_COPY; Fo.pFrom:= @Buffer; Fo.pTo:= PChar(ToFolder); //куда будет скопирована директория Fo.fFlags:= 0; if ((SHFileOperation(Fo) <> 0) or (Fo.fAnyOperationsAborted <> false)) then ShowMessage('File copy process cancelled') end; procedure TForm1.BitBtn1Click(Sender: TObject); begin CopyFiles(directorylistbox1.Directory,Directorylistbox2.Directory); Showmessage('Копирование завершено'); end; procedure TForm1.BitBtn2Click(Sender: TObject); begin close; end; end.
Скрытый файл сделать видимым. Поменять атрибут. Windows.setfileattributes(‘c:\test.txt’,fahidden); -сделать скрытым файл программа Function filesethidden(filename:string;hid:Boolean):Boolean; Var flags:integer; Begin Result:=false; Flags:=getfileattributes(pchar(filename)); If hid then flags:=flags or fahidden Else flags:=flags and not fahidden; Result:=setfileattributes(pchar(filename),flags);end; Hid=true сделать файл скрытым Hid=false сделать файл не скрытым Поменять атрибуты файла Button1: TButton; Button2: TButton; procedure Button1Click(Sender: TObject); procedure Button2Click(Sender: TObject); mplementation {$R *.dfm} procedure TForm1.Button1Click(Sender: TObject); var fileattr:integer; begin fileattr:=filegetattr('C:\Documents and Settings\bista\Рабочий стол\ержан19,04,09.doc'); if fileattr and fareadonly=0 then filesetattr('C:\Documents and Settings\bista\Рабочий стол\ержан19,04,09.doc',fileattr+fareadonly); end; procedure TForm1.Button2Click(Sender: TObject); begin filesetreadonly('C:\Documents and Settings\bista\Рабочий стол\ержан19,04,09.doc', false); end; end. Решить квадратное уравнение TForm1 = class(TForm) Edit1: TEdit; Edit2: TEdit; Edit3: TEdit; Memo1: TMemo; Button1: TButton; procedure Button1Click(Sender: TObject); implementation {$R *.dfm} procedure TForm1.Button1Click(Sender: TObject); var a,b,c,x,y,d:real; begin a:=Strtofloat(Edit1.Text); b:=Strtofloat(Edit2.Text); c:=Strtofloat(Edit3.Text); D:= sqr(b)-4*a*c; if (D>0) then begin x:= (-b+sqrt(D))/(2*a); y:= (-b-sqrt(D))/(2*a); Memo1.Lines.Add(floattostr(x)); Memo1.Lines.Add(floattostr(y)) end else if(D<0) then Memo1.Lines.Add('нету решений') else x:= (-b)/(2*a); y:= (-b)/(2*a); Memo1.Lines.Add(floattostr(x)); Memo1.Lines.Add(floattostr(y)); end; end. С заголовком Header procedure TForm1.Button1Click(Sender: TObject); begin checklistbox1.HeaderColor:=clgreen; checklistbox1.HeaderBackgroundColor:=clyellow; checklistbox1.Header[0]:=true; checklistbox1.HeaderColor:=clwhite; checklistbox1.HeaderBackgroundColor:=clred; checklistbox1.Header[3]:=true; checklistbox1.Header[6]:=true; end 33. Вывести на StatusBar фамилия имя студента а также дата время сегодняшние-системную информацию procedure TForm1.Timer1Timer(Sender: TObject); begin statusbar1.Panels[0].Text:=datetostr(now)+' '+timetostr(now)+' '+ +' '+'Разработчик приложения Ташибаева Айнур Ерланкызы'; 34. Из полного имени файла, которое содержится в Edit1 формируются 2 строки-одна содержит путь к файлу включая им диска и название каталога а другая его имя и расширение. Var Drive:Char; Dirpart,filepart:string; Begin ProcessPath(Edit1.Text,Drive, dirpart,filepart) Label1.Caption:=Drive+’:’+ dirpath+’’ Label2.Caption:=filepart; 2 способ- с помощью Extract Var Filename:string; Begin Filename:=edit1.text; Label1.Caption:=extractfilepath(filename) Label2.caption:=extractfilename(filename); 35.Cформировать массив стоимость. Результат из этого массива в файл Total. Var f:textfile; S:string[16]; i,k,cena,name.kol:integer; stoim:array[1..10] of integer; begin i:=0; assignfile(f,’mark.txt’) reset(f); readln(f); while not eof(f) do begin inc(i); read(f,s,cena,kol); stoim[i]:=cena*kol; readln(f); end; k:=I; close(f); end.
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.
|
||
|
Последнее изменение этой страницы: 2016-08-14; просмотров: 348; Нарушение авторского права страницы; Мы поможем в написании вашей работы! infopedia.su Все материалы представленные на сайте исключительно с целью ознакомления читателями и не преследуют коммерческих целей или нарушение авторских прав. Обратная связь - 216.73.216.196 (0.009 с.) |