记事本

记事本

 

步骤一:向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;

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值