delphi代码

合集下载
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

实验7:
Begin
If RadoButton1.Checked=true then
Begin
With Open Dialog1 do
Begin
Filter:=’文本文件’(*.txt)*.txt’ ;
DefaultExt:=’txt’;
Filename:=”;
Options:=[ofHideReadOnly,ifFilemustexist,ofpathmustexist];
If execute then
If ofextensiondifferent in options then
Messigedlg(不存在扩展名为.txt的文件’,mterror,[mbok],0) Else
Memol1.Lines.loadfromfile(filename);
End;
End
If radiobutton2.cheaked=true then
Begin
With optiondialog1 do
Begin
Filter:=’任何类型文件(*.*)|*.*‘;
Filename:=”;
Options:=[];
If execute then
Memo1.lines.loadfromfile(filename);
End;
End;
End;
Procedure tform1.button2click(sender:tobject);
Begin
If radiobutton1.checked=true then
Begin
With savedialog1 do
Begin
Filter:=’文本文件(*.txt)|*.txt’;
Defaultext:=’txt’;
Filename:=”;
Options:=[ofhidereadonly,ofpathmustexist];
If execute then
If ofextensiondifferent in options then
Messagedlg(‘不是扩展名为.txt的文件’,mterror,[mbok],0) Else
Memo1.lines.savetofile(filename);
End;
If radiobutton2.checked=true then
Begin
With savedialog1 do
Begin
File:=’任何类型文件(*.*)|*.*’;
Filename:=”;
Options:=[ofpathmustexist];
If execute then
Memo1.lines.savetofile(filename);
End;
End;
End;
Procedure tform1.button3click(sender:tobject); Begin
With fondialog1 do
Begin
Options:=[fdeffects,fdtruetypeonly,fdforcefontexist]; If execute then
Memo1.font:=font;
End;
Procedure tform1.button4click(sender:tobject);
Begin
Close;
End;
实验8
Procedure twinform.button1.checked=true then
Begin
If radiobutton1.checked=true then
Begin
With openfiledialog1 do
Begin
Filter:=’文本文件(*.txt)|*.txt’;
Defaultext:=’txt’;
Filename:=”;
Restoredirectory:=true;
If showdialog=system.windos.forms.dialogresult.ok then
Rich textbox1.loadfile(filename,richtextboxstreamtype.plaintext); End;
End;
If radiobutton2.checked=true then
With optionfiledialog1 do
Begin
Filename:=’任何类型文件(*.*)|*.*‘;
Filename:=”;
Restoredictory:=true;
If showdialog=system.windows.forms.dialogresult.ok then
Richtextbox1.loadfile(filename,richtextboxstreamtype.plaintext);
End;
End;
End;
Procedure
twinform.button2_click(sender:system.object;e:system.eventargs);
Begin
With savefiledialog1.do
Begin
Filter:=’文本文件’(*.txt)|*.txt’;
Defaultext:=’txt’;
Filename:=”;
If showdialog=system.windows.forms.dialogresult.ok then
Richtextbox1.savefile(filename,richtextboxstreamtype.plaintext);
End;
End;
If radiobutton2.checked=true then
Begin
With savefiledialog1 do
Begin
Filter:=’任何类型文件’(*.*)|*.*’;
Filename:=”;
If showdialog=system.windows.forms.dialogresult.ok then
Richtextbox1.savefile(filename,richtextboxstreamtype.plaintext);
End;
End;
End;
Procedure
twinform.button3_chick(sender:system.object;e:system.eventargs);
Begin
With fontdialog1 do begin
If showdialog=system.windows.forms.dialogresult.ok then
Richtextbox1.font:=font;
End;
End;
Procedure
twinform.button4_click(sender:system.object;e:system.eventargs);
Begin
Close;
End;
实验9
Procedure tform1.new1click(sender:tobject);
Begin
Form1.caption:=’文档1’;
Txtname1:= ’文档1’;
Form1.richedit1.lines.clear;
End;
Procedure tform1.open1click(sender:tobject);
Begin
If form1.opendialog1.execute then
Begin
Form1.richedit1.lines.loadfromfile(form1
Opendialog1.filename);
Form1.caption:=form1.optiondialog1.filename;
End;
End;
Procedure tform1.save1click(sender:tobject); Begin
If richedit1.modified then
If form1.caption<>’文档1’then
Form1.richedit1.lines.savetofile(txtname) Else if form1.savedialog1.execute then Begin
Txtname:=form1.savedialog1.filename; Form1.richedit1.lines.savetofile(txtname); End;
End;
Procedure tform1.exit1click(sender:tobject); Begin
Close;
End;
Procedure tform1.printclick(seder:tobject); Begin
Form1.printdialog1.execute;
End;
Procedure tform1.cut1click(sender:tobject); Begin
Form1.richedit1.undo;
Procedure tform1.cut1click(sender:tobject);
Begin
Form1.richedit1.cuttoclpboard;
End;
Procedure tform1.copyclick(sender:tobject);
Begin
Form1.richedit1.copytoclipboard;
End;
Proceduretform1.richedit1.paste1click(sender:tobject); Begin
Form1.richedit1.pastefromclipboard;
End;
Procedure tform1.replacedialog1.extcute;
End;
Procedure tform1.toolbutton1click(sender:tobject); Begin
Form1.caption:=’文档1’;
Txtname:= ’文档1’;
Form1.richedit1.lines.clear;
End;
Procedure tform1.toolbutton2click(sender:object);
If form1.opendialog1.execute then
Begin
If form1.opendialog1.execute then
Begin
Form1.richedit1.lines.loadfromfile(form1.opendialog1.filename); Form1.caption:=form1.opendialog1.filename;
End;
End;
Procedure tform1.toolbutton1click(sender:tobject);
Begin
If richedit1.modified then
If form1.caption<>’文档1’then
Form1.richedit1.lines.savetofile(txtname);
Else if form1.savedialog1.execute then
Begin
Txtname:=form1.savedialog1.filename;
Form1.richedit1.lines.savetofile(txtname);
End;
End;
Procedure tform1.toolbutton4click(sender:tobject);
Begin
Form1.printdialog1.execute;
End;
Procedure tform1.toolbutton5click(sender:tobject); Begin
Form1.richedit1.cuttoclipboard;
End;
Procedure tform1.toolbutton6click(sender:tobject); Begin
Form1.richedit1.copytoclipboard;
End;
Procedure tform1.toolbutton7click(sender:tobject); Begin
Form1.richedit1.paste1fromclipboard;
End;
Procedure tform1.toolbutton8click(sender:tobject); Begin
Form1.richedit1.font.style:=[fsbold];
End;
Procedure tform1.toolbutton9click(sender:tobject); Begin
Form1.richedit1.font.style:=[fsunderline];
End;
Procedure tform1.toolbutton10click(sender:tobject);
Begin
Form1.richedit1.font.style:=[fsitalic];
End;
Procedure tform1.formcreat(sender:tobject);
Begin
Form1.caption:=’文档1’;
txtname:=’文档1’;
form1.statusbar1.panels[0].text:=txtname;
form1.statusbar1.panels[1].text:=timetostr;
form1.statusbar1.panels[2].text:=datetostr;
end;
实验十
Procedure
tform.menultem2_click(sender:system.object;e:system.eventargs);
Begin
Text:=’文档1’;
Txtname:=’文档1’;
Richtextbox1.clear;
End;
Procedure
tform.menultem3_click(sender:system.object;e:system.eventargs);
Begin
If openfiledialog1.showdialog=system.windows.forms.dialogrsult.ok then
Begin
Richtextbox1.loadfile(openfiledialog1.filename,richtextboxstreamty pe.plaintext);
Text:=openfiledialog1.filename;
End;
End;
Procedure
tform.menultem4_click(sender:system.object;e:system.eventargs);
Begin
If richtextbox1.modidied then
If text<>’文档1’then
Richtextbox1.savefile(txtname);
Else if savefiledialog1.showdialog=system.wimdows.forms.dialogresutl.ok then Begin
Txtname:=savefiledialog1.filename;
Richtextbox1.savefile(txtname);
End;
End;
Procedure
tform.menultem6_click(sender:system.object;e:system.eventargs);
Begin
Close;
End;
Procedure
tform.menultem8_click(sender:system.object;e:system.eventargs);
Begin
Richtextbox1.undo;
End;
Procedure
tform.menultem9_click(sender:system.object;e:system.eventargs);
Begin
Richtextbox1.cut;
End;
Procedure
tform.menultem10_click(sender:system.object;e:system.eventargs);
Begin
Richtextbox1.copy;
End;
Procedure
tform.menultem11_click(sender:system.object;e:system.eventargs);
Begin
Richtextbox1.paste;
End;
Procedure
twinform.twform_load(sender:system.object;e:system.event);
Begin
Text:=’文档1’;
txtname:=’文档1’;
statusbar1.panels[0].text:=txtname;
statusbar1.panels[1].text:=timetostr(time);
statusbar1.panels[0].text:=datetostr(date);
end;
实验十一
Procedure tformmain
Mminewexecute(sender:tobject);
Begin
Controlbar1.visible:=false;
Statusbar1.visible:=tfrmeditor.create(self);
Procedure tformmain
tbopenclick (sender:tobject);
begin
opendialog1.execute;
if opendialog1.filename<>”them
begin
controbar1.visible:=false;
statusbar1.visible:=false;
with tformeditor.create(self)do
openfile(opendialog1.filename);
end;
end;
Procedure tformmain
mmihelpextcute(sender:tobject);
const
help_tab=15;
contents_active=-3;
begin
application.helpcommand(help_tab,contents_active); end;
application.helpcommand(help_tab,contents_active); end;
procedure tfmmain.mmiaboutexecute(sender:tobject);
begin
with taboutbox.create(self)do
try
showmodal;
finally
free;
end;
end;
procedure tfrmmain.formtreate(sender.tobjec);
begin
application.onhint:=showhint;
application.helpfile:=exetracefilepath(application.exename)+textedi tor.hlp’;
end;。

相关文档
最新文档