2012年(106)
分类: 嵌入式
2012-05-07 18:09:28
记事本
步骤一:向Form1中添加Memo, MainMenu组件,dialogs组---OpenDialog,SaveDialog, FontDialog(可选) 组件,Name就默认吧
步骤二:双击MainMenu1,设置菜单名字(具体名字只要能表达其功能,怎么起都可以) 。
例如:主菜单分别设置为File(Caption---&File),Edit(Caption---&Edit),Format(可选) (Caption---F&ormat),Help(Caption---&Help).
File的子菜单分别设置为
New(Caption---&New),Open(Caption---&Open),Save(Caption---&Save),Saveas(Caption---Save &as),Exit(Caption---&Edit)
Edit的子菜单分别设置为
Cut(Caption---&Cut),Copy(Caption---C&opy),Paste(Caption---&Paste)Clear(Caption---C&lear),Select All(Caption---&Select All)
Format (可选)的子菜单分别设置为
Font(Caption---Fo&nt)
Help的子菜单分别设置为
About(Caption---&About)
步骤三:
1. 在implementation下面一行定义变量s:
var s:string;
2.分别完善MainMenu1中每个子菜单的功能:
New:
Memo1.clear;
Open:
if (Opendialog1.Execute) then
begin
Memo1.lines.loadFromFile(opendialog1.FileName);
s:=opendialog1.FileName;
end;
Save:
if(s='') then
begin
if (savedialog1.execute) then
begin
Memo1.Lines.Savetofile(savedialog1.FileName);
s:=savedialog1.FileName;
end;
end
else memo1.lines.SaveToFile(s);
Saveas:
if (savedialog1.Execute) then
begin
memo1.lines.SaveToFile(savedialog1.filename);
s:=savedialog1.filename;
end;
Exit:
close;
Cut:
memo1.CutToClipboard;
Copy:
memo1.CopyToClipboard;
Paste:
memo1.PasteFromClipboard;
Clear:
memo1.Clear;
Select All:
memo1.SelectAll;
Font:
fontdialog1.Execute;
memo1.Font:=fontdialog1.Font;