欢迎来到三一办公! | 帮助中心 三一办公31ppt.com(应用文档模板下载平台)
三一办公
全部分类
  • 办公文档>
  • PPT模板>
  • 建筑/施工/环境>
  • 毕业设计>
  • 工程图纸>
  • 教育教学>
  • 素材源码>
  • 生活休闲>
  • 临时分类>
  • ImageVerifierCode 换一换
    首页 三一办公 > 资源分类 > DOCX文档下载  

    Delphi中用memo写的记事本程序.docx

    • 资源ID:3060707       资源大小:41.75KB        全文页数:23页
    • 资源格式: DOCX        下载积分:6.99金币
    快捷下载 游客一键下载
    会员登录下载
    三方登录下载: 微信开放平台登录 QQ登录  
    下载资源需要6.99金币
    邮箱/手机:
    温馨提示:
    用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)
    支付方式: 支付宝    微信支付   
    验证码:   换一换

    加入VIP免费专享
     
    账号:
    密码:
    验证码:   换一换
      忘记密码?
        
    友情提示
    2、PDF文件下载后,可能会被浏览器默认打开,此种情况可以点击浏览器菜单,保存网页到桌面,就可以正常下载了。
    3、本站不支持迅雷下载,请使用电脑自带的IE浏览器,或者360浏览器、谷歌浏览器下载即可。
    4、本站资源下载后的文档和图纸-无水印,预览文档经过压缩,下载后原文更清晰。
    5、试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。

    Delphi中用memo写的记事本程序.docx

    Delphi中用memo写的记事本程序实验四 Delphi组件应用综合实验指导 实验目的 掌握公共对话框组件的属性、事件及应用方法。 掌握应用程序界面设计方法。 掌握基本组件的综合应用。 掌握常用函数的应用。 实验内容 设计一个文本编辑器 实验要求 参照windows记事本程序,编写类似的程序。要求应用公共对话框、菜单组件、工具栏组件、备注框组件,完成菜单设计,工具栏设计,实现文件打开、保存、关闭、文字编辑,文字格式设置等功能,保证主菜单、弹出式菜单、工具栏同步。 此编辑器主要由一个主菜单,一个工具栏,和一个快捷菜单组成,主要功能如下: 主菜单:文件,编辑,更改,关于。 工具栏:保存,新建,打开,打印,字体,粗体,斜体,下划线。此工具栏是让用户更方便地使用按键。 快捷菜单:复制,剪切,黏贴。 可以自行设计其他功能,完善文本编辑器。 1、 代码实现 unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, Menus, StdCtrls, ComCtrls, ImgList, ToolWin, ExtDlgs; type TForm1 = class(TForm) MainMenu1: TMainMenu; E1: TMenuItem; O1: TMenuItem; V1: TMenuItem; N3: TMenuItem; C1: TMenuItem; P2: TMenuItem; F2: TMenuItem; R1: TMenuItem; W1: TMenuItem; N4: TMenuItem; N5: TMenuItem; N1: TMenuItem; N2: TMenuItem; O2: TMenuItem; S1: TMenuItem; A1: TMenuItem; U1: TMenuItem; P1: TMenuItem; X1: TMenuItem; N6: TMenuItem; N7: TMenuItem; PopupMenu1: TPopupMenu; Edit1: TEdit; ToolBar1: TToolBar; ImageList1: TImageList; ToolButton1: TToolButton; ToolButton2: TToolButton; ToolButton3: TToolButton; ToolButton4: TToolButton; ToolButton5: TToolButton; ToolButton6: TToolButton; ToolButton7: TToolButton; ToolButton8: TToolButton; ToolButton9: TToolButton; ToolButton10: TToolButton; ToolButton11: TToolButton; N8: TMenuItem; N9: TMenuItem; N10: TMenuItem; N11: TMenuItem; N12: TMenuItem; N13: TMenuItem; N14: TMenuItem; N15: TMenuItem; N16: TMenuItem; N17: TMenuItem; N18: TMenuItem; N19: TMenuItem; N20: TMenuItem; FontDialog1: TFontDialog; ColorDialog1: TColorDialog; OpenDialog1: TOpenDialog; SaveDialog1: TSaveDialog; PrintDialog1: TPrintDialog; FindDialog1: TFindDialog; ReplaceDialog1: TReplaceDialog; PageSetupDialog1: TPageSetupDialog; Memo1: TMemo; D1: TMenuItem; L1: TMenuItem; w2: TMenuItem; procedure ToolButton8Click(Sender: TObject); procedure ToolButton9Click(Sender: TObject); procedure ToolButton10Click(Sender: TObject); procedure N11Click(Sender: TObject); procedure N12Click(Sender: TObject); procedure N15Click(Sender: TObject); procedure N16Click(Sender: TObject); procedure N17Click(Sender: TObject); procedure N18Click(Sender: TObject); procedure N19Click(Sender: TObject); procedure N3Click(Sender: TObject); procedure C1Click(Sender: TObject); procedure P2Click(Sender: TObject); procedure Memo1MouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, procedure N8Click(Sender: TObject); procedure N9Click(Sender: TObject); procedure N10Click(Sender: TObject); procedure ToolButton11Click(Sender: TObject); procedure ToolButton3Click(Sender: TObject); procedure ToolButton5Click(Sender: TObject); procedure P1Click(Sender: TObject); procedure A1Click(Sender: TObject); Y: Integer); procedure N20Click(Sender: TObject); procedure X1Click(Sender: TObject); procedure U1Click(Sender: TObject); procedure R1Click(Sender: TObject); procedure F2Click(Sender: TObject); procedure ToolButton2Click(Sender: TObject); procedure ToolButton1Click(Sender: TObject); procedure O2Click(Sender: TObject); procedure N2Click(Sender: TObject); procedure S1Click(Sender: TObject); procedure N14Click(Sender: TObject); procedure N13Click(Sender: TObject); procedure N5Click(Sender: TObject); procedure D1Click(Sender: TObject); procedure L1Click(Sender: TObject); / procedure N21Click(Sender: TObject); procedure FindDialog1Find(Sender: TObject); procedure ReplaceDialog1Replace(Sender: TObject); procedure ReplaceDialog1Find(Sender: TObject); private Private declarations public Public declarations end; var Form1: TForm1; filename:string; implementation $R *.dfm procedure TForm1.Memo1MouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer); /鼠标选中文本,剪切,复制,等按钮才生效 begin if memo1.SelLength>0 then begin n3.Enabled:=true; C1.Enabled:=true; n8.Enabled:=true; n9.Enabled:=true; D1.Enabled:=true; L1.Enabled:=true; end else begin n3.Enabled:=false; C1.Enabled:=false; n8.Enabled:=false; n9.Enabled:=false; D1.Enabled:=false; L1.Enabled:=false; end; end; procedure TForm1.N2Click(Sender: TObject); /新建 begin if (memo1.Lines.Text)<>'' then begin if MessageDlg('记事本中还有文本内容未保存,是否保存?',mtWarning,mbyes,mbno,0)=mrok then ToolButton1.Click ; end; memo1.clear; end; procedure TForm1.O2Click(Sender: TObject); /打开 begin if OpenDialog1.Execute then memo1.lines.LoadfromFile(OpenDialog1.Filename);/把在打开文件对话框中选中的文件装载到 文本框中 end; procedure TForm1.S1Click(Sender: TObject); /保存 begin if filename='' then begin if savedialog1.Execute then begin memo1.Lines.SaveToFile(savedialog1.FileName); filename:=savedialog1.filename; end end else memo1.Lines.SaveToFile(savedialog1.FileName); / 把文件保存到已打开的文本中 end; procedure TForm1.A1Click(Sender: TObject); / 另存为 begin if savedialog1.Execute then begin memo1.Lines.SaveToFile(savedialog1.FileName); filename:=savedialog1.filename; end; end; procedure TForm1.U1Click(Sender: TObject); /页面设置? begin PagesetupDialog1.Execute; end; procedure TForm1.P1Click(Sender: TObject); /打印 begin PrintDialog1.Execute; end; procedure TForm1.X1Click(Sender: TObject); /退出 begin close; end; procedure TForm1.N3Click(Sender: TObject); /剪切 begin memo1.CutToClipboard; n3.Enabled:=false; C1.Enabled:=false; n8.Enabled:=false; n9.Enabled:=false; end; procedure TForm1.C1Click(Sender: TObject); /复制 begin memo1.CutToClipboard; n3.Enabled:=false; C1.Enabled:=false; n8.Enabled:=false; n9.Enabled:=false; end; procedure TForm1.P2Click(Sender: TObject); /粘贴 begin memo1.PasteFromClipboard; end; procedure TForm1.F2Click(Sender: TObject); /查找?begin /FindDialog1.Execute; /FindDialog1.Position:=Point(memo1.Left+memo1.Top,memo1.Width); /memo1.Lines.Text:=FindDialog.FindText; end; procedure TForm1.R1Click(Sender: TObject); /替换?begin ? ? ReplaceDialog1.Execute; end; procedure TForm1.N11Click(Sender: TObject); /字体-粗体 begin if memo1.font.Style*fsbold= then begin memo1.font.Style:=memo1.Font.Style+fsbold; n11.checked:=true; ToolButton8.Down:=true; end else begin memo1.font.Style:=memo1.Font.Style-fsbold; n11.checked:=false; ToolButton8.Down:=false; end; end; procedure TForm1.N12Click(Sender: TObject); /字体-斜体 begin if memo1.font.Style*fsitalic= then begin memo1.font.Style:=memo1.Font.Style+fsitalic; n12.checked:=true; ToolButton9.Down:=true; end else begin memo1.font.Style:=memo1.Font.Style-fsitalic; n12.checked:=false; ToolButton9.Down:=false; end; end; procedure TForm1.N15Click(Sender: TObject); /背景色-银色 begin memo1.color:=clsilver; end; procedure TForm1.N16Click(Sender: TObject); begin memo1.color:=clgray; end; procedure TForm1.N17Click(Sender: TObject); begin memo1.color:=clblack; end; procedure TForm1.N18Click(Sender: TObject); begin memo1.color:=clred; end; procedure TForm1.N19Click(Sender: TObject); begin memo1.color:=clwhite; end; /背景色-灰色 /背景色-黑色/背景色-红色 /背景色-白色 procedure TForm1.N20Click(Sender: TObject); /字体颜色 begin with ColorDialog1 do if execute then memo1.Font.Color:=ColorDialog1.Color; end; procedure TForm1.ToolButton1Click(Sender: TObject); /保存 begin S1.Click; end; procedure TForm1.ToolButton2Click(Sender: TObject); / 新建文件 begin if (memo1.Lines.Text)<>'' then begin if MessageDlg('记事本中还有文本内容未保存,是否保存?',mtWarning,mbyes,mbno,0)=mrok then ToolButton1.Click ; end; memo1.clear; end; procedure TForm1.ToolButton3Click(Sender: TObject); /打开 begin if OpenDialog1.Execute=true then memo1.lines.LoadfromFile(OpenDialog1.Filename);/把在 打开文件对话框中选中的文件装载到 文本框中 end; procedure TForm1.ToolButton5Click(Sender: TObject); /打印 begin PrintDialog1.Execute; end; procedure TForm1.ToolButton11Click(Sender: TObject);/字体 begin FontDialog1.font:=memo1.Font; with FontDialog1 do if execute then memo1.Font:=FontDialog1.Font; end; procedure TForm1.ToolButton8Click(Sender: TObject); begin if memo1.font.Style*fsbold= then begin memo1.font.Style:=memo1.Font.Style+fsbold; n11.checked:=true; ToolButton8.Down:=true; end else begin memo1.font.Style:=memo1.Font.Style-fsbold; n11.checked:=false; ToolButton8.Down:=false; end; end; /粗体 procedure TForm1.ToolButton9Click(Sender: TObject); /斜体 begin if memo1.font.Style*fsitalic= then begin memo1.font.Style:=memo1.Font.Style+fsitalic; n12.checked:=true; ToolButton9.Down:=true; end else begin memo1.font.Style:=memo1.Font.Style-fsitalic; n12.checked:=false; ToolButton9.Down:=false; end; end; procedure TForm1.ToolButton10Click(Sender: TObject); 栏) begin if memo1.font.Style*fsunderline= then begin memo1.font.Style:=memo1.Font.Style+fsunderline; ToolButton10.Down:=true; end else begin memo1.font.Style:=memo1.Font.Style-fsunderline; ToolButton10.Down:=false; end; end; /下划线 begin memo1.CutToClipboard; n3.Enabled:=false; C1.Enabled:=false; n8.Enabled:=false; n9.Enabled:=false; end; procedure TForm1.N9Click(Sender: TObject); /剪切 begin memo1.CutToClipboard; n3.Enabled:=false; C1.Enabled:=false; n8.Enabled:=false; n9.Enabled:=false; end; procedure TForm1.N10Click(Sender: TObject); /粘贴 begin memo1.PasteFromClipboard; end; procedure TForm1.N13Click(Sender: TObject); /查找? begin FindDialog1.Execute; memo1.SelStart:=0; end; procedure TForm1.N14Click(Sender: TObject); /替换 ? begin ReplaceDialog1.Execute; memo1.SelStart:=0; end; procedure TForm1.N5Click(Sender: TObject); begin showmessage('欢迎使用本程序!'+#13'编者姓名:卢慧琳'); end; procedure TForm1.D1Click(Sender: TObject); begin memo1.SelText:='' end; procedure TForm1.L1Click(Sender: TObject); begin memo1.SelText:='' end; procedure TForm1.FindDialog1Find(Sender: TObject); /查找 Var selpos,startpos,toend:integer; t:string; begin startpos:=memo1.SelStart+memo1.SelLength+1; toend:=Length(memo1.lines.Text)-startpos+1; t:=copy(memo1.Lines.Text,startpos,toend); selpos:=pos(finddialog1.FindText,t); if selpos>0 then begin selpos:=selpos+startpos-1; memo1.setfocus; memo1.SelStart:=selpos-1; memo1.SelLength:=Length(FindDialog1.FindText); end else showmessage('不能找到'+finddialog1.findtext); end; procedure TForm1.N21Click(Sender: TObject); /查找下一个 begin if finddialog1.FindText='' then finddialog1.Execute else finddialog1Find(sender); end; procedure TForm1.ReplaceDialog1Replace(Sender: TObject); var selpos:integer; begin selpos:=Pos(ReplaceDialog1.FindText ,Memo1.Lines.Text ); if selpos>0 then begin Memo1.SelStart :=selpos-1; Memo1.SelLength :=Length(ReplaceDialog1.FindText ); Memo1.SelText :=ReplaceDialog1.ReplaceText ; end else showmessage('不能找到'+ReplaceDialog1.FindText); end; procedure TForm1.ReplaceDialog1Find(Sender: TObject); begin Form1.FindDialog1Find(Sender); end; end. unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, Menus, StdCtrls, ComCtrls, ImgList, ToolWin, ExtDlgs; type TForm1 = class(TForm) MainMenu1: TMainMenu; E1: TMenuItem; O1: TMenuItem; V1: TMenuItem; N3: TMenuItem; C1: TMenuItem; P2: TMenuItem; F2: TMenuItem; R1: TMenuItem; W1: TMenuItem; N4: TMenuItem; N5: TMenuItem; N1: TMenuItem; N2: TMenuItem; O2: TMenuItem; S1: TMenuItem; A1: TMenuItem; U1: TMenuItem; P1: TMenuItem; X1: TMenuItem; N6: TMenuItem; N7: TMenuItem; PopupMenu1: TPopupMenu; Edit1: TEdit; ToolBar1: TToolBar; ImageList1: TImageList; ToolButton1: TToolButton; ToolButton2: TToolButton; ToolButton3: TToolButton; ToolButton4: TToolButton; ToolButton5: TToolButton; ToolButton6: TToolButton; ToolButton7: TToolButton; ToolButton8: TToolButton; ToolButton9: TToolButton; ToolButton10: TToolButton; ToolButton11: TToolButton; N8: TMenuItem; N9: TMenuItem; N10: TMenuItem; N11: TMenuItem; N12: TMenuItem; N13: TMenuItem; N14: TMenuItem; N15: TMenuItem; N16: TMenuItem; N17: TMenuItem; N18: TMenuItem; N19: TMenuItem; N20: TMenuItem; FontDialog1: TFontDialog; ColorDialog1: TColorDialog; OpenDialog1: TOpenDialog; SaveDialog1: TSaveDialog; PrintDialog1: TPrintDialog; FindDialog1: TFindDialog; ReplaceDialog1: TReplaceDialog; PageSetupDialog1: TPageSetupDialog; Memo1: TMemo; D1: TMenuItem; L1: TMenuItem; w2: TMenuItem; procedure ToolButton8Click(Sender: TObject); procedure ToolButton9Click(Sender: TObject); procedure ToolButton10Click(Sender: TObject); procedure N11Click(Sender: TObject); procedure N12Click(Sender: TObject); procedure N15Click(Sender: TObject); procedure N16Click(Sender: TObject); procedure N17Click(Sender: TObject); procedure N18Click(Sender: TObject); procedure N19Click(Sender: TObject); procedure N3Click(Sender: TObject); procedure C1Click(Sender: TObject); procedure P2Click(Sender: TObject); procedure Memo1MouseUp(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, procedure N8Click(Sender: TObject); procedure N9Click(Sender: TObject); procedure N10Click(Sender: TObject); procedure ToolButton11Click(Sender: TObject); procedure ToolButton3Click(Sender: TObject); procedure ToolButton5Click(Sender: TObject); procedure P1Click(Sender: TObject); procedure A1Click(Sender: TObject); procedure N20Click(Sender: TObject); procedure X1Click(Sender: TObject); procedure U1Click(Sender: TObject); procedure R1Click(Sender: TObject); procedure F2Click(Sender: TObject); Y: Integer); procedure ToolButton2Click(Sender: TObject); procedure ToolButton1Click(Sender: TObject); procedure O2Click(Sender: TObject); procedure N2Click(Sender: TObject); procedure S1Click(Sender: TObject); procedure N14Click(Sender: TObject); procedure N13Click(Sender: TObject); procedure N5Click(Sender: TObject);

    注意事项

    本文(Delphi中用memo写的记事本程序.docx)为本站会员(牧羊曲112)主动上传,三一办公仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知三一办公(点击联系客服),我们立即给予删除!

    温馨提示:如果因为网速或其他原因下载失败请重新下载,重复下载不扣分。




    备案号:宁ICP备20000045号-2

    经营许可证:宁B2-20210002

    宁公网安备 64010402000987号

    三一办公
    收起
    展开