1、主要功能都已添加上并测试可用。效果图:源码:unit Unit1Calculator;interfaceusesWindows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,Dialogs, Menus, StdCtrls, ComCtrls;typeTForm1 = class(TForm)ColorDialog1: TColorDialog;SaveDialog1: TSaveDialog;ColorDialog2: TColorDialog;MainMenu1: TMainMenu;N1: TMenuI
2、tem;myNew: TMenuItem;mySave: TMenuItem;N3: TMenuItem;myPage: TMenuItem;myPrint: TMenuItem;myQuit: TMenuItem;myEdit: TMenuItem;myUndo: TMenuItem;N4: TMenuItem;myCut: TMenuItem;myCopy: TMenuItem;myPaste: TMenuItem;myDelete: TMenuItem;N6: TMenuItem;myFind: TMenuItem;myReplace: TMenuItem;myFormat: TMenu
3、Item;myFont: TMenuItem;myView: TMenuItem;myStatus: TMenuItem;myHelp: TMenuItem;myHelpTopics: TMenuItem;N9: TMenuItem;myAbout: TMenuItem;OpenDialog1: TOpenDialog;FontDialog1: TFontDialog;myOpen: TMenuItem;FindDialog1: TFindDialog;ReplaceDialog1: TReplaceDialog;FontDialog2: TFontDialog;PageSetupDialog
4、1: TPageSetupDialog;PrintDialog1: TPrintDialog;RichEdit1: TRichEdit;procedure myNewClick(Sender: TObject);procedure FormCreate(Sender: TObject);procedure myOpenClick(Sender: TObject);procedure mySaveClick(Sender: TObject);procedure myQuitClick(Sender: TObject);procedure myUndoClick(Sender: TObject);
5、procedure myCutClick(Sender: TObject);procedure myCopyClick(Sender: TObject);procedure myPasteClick(Sender: TObject);procedure myDeleteClick(Sender: TObject);procedure myFindClick(Sender: TObject);procedure myReplaceClick(Sender: TObject);procedure myFontClick(Sender: TObject);procedure myPageClick(
6、Sender: TObject);procedure myPrintClick(Sender: TObject);procedure myAboutClick(Sender: TObject);procedure myHelpTopicsClick(Sender: TObject);procedure FormClose(Sender: TObject; var Action: TCloseAction);private Private declarations public Public declarations end;varForm1: TForm1;implementation$R *
7、.dfmvar fName: String;procedure TForm1.myNewClick(Sender: TObject);var msg : integer;beginif (richEdit1.Modified) thenbeginmsg := Application.MessageBox(文件已被修改,是否保存 ?,Delphi 记事本, mb_YesNoCancel);case msg ofidYes: beginmySaveClick(Sender);richEdit1.Clear;fName := 文档 1;Caption := fName + -Delphi 记事本;e
8、nd;idNo: beginrichEdit1.Clear;fName := 文档 1;Caption := fName + -Delphi 记事本;end;idCancel: ;end;endelse beginrichEdit1.Clear;fName := 文档 1;Caption := fName + -Delphi 记事本;end;end;procedure TForm1.FormCreate(Sender: TObject);beginfName := 文档 1;richEdit1.Clear;Caption := fName + -Delphi 记事本;end;procedure
9、 TForm1.myOpenClick(Sender: TObject);var msg : integer;beginif (richEdit1.Modified) thenbeginmsg := Application.MessageBox(文件已被修改,是否保存 ?,Delphi 记事本, mb_YesNoCancel);case msg ofidYes: beginmySaveClick(Sender);end;idNo: if (openDialog1.Execute) thenbeginfName := openDialog1.FileName;richEdit1.Lines.Lo
10、adFromFile(fName);form1.Caption := fName + Delphi 记事本;end;idCancel: ;end;endelse if (openDialog1.Execute) thenbeginfName := openDialog1.FileName;richEdit1.Lines.LoadFromFile(fName);form1.Caption := fName + Delphi 记事本;end;end;procedure TForm1.mySaveClick(Sender: TObject);beginif (fName 文档 1) thenbegi
11、nrichEdit1.Lines.SaveToFile(fName);endelse beginsaveDialog1.FileName := fName;if (saveDialog1.Execute) thenbeginfName := saveDialog1.FileName;richEdit1.Lines.SaveToFile(fName);form1.Caption := fName;end;end;richEdit1.Modified := false;end;procedure TForm1.myQuitClick(Sender: TObject);beginif (richEd
12、it1.Modified) then mySaveClick(Sender);Application.Terminate;end;procedure TForm1.myUndoClick(Sender: TObject);beginrichEdit1.Undo;end;procedure TForm1.myCutClick(Sender: TObject);beginrichEdit1.CutToClipboard;end;procedure TForm1.myCopyClick(Sender: TObject);beginrichEdit1.CopyToClipboard;end;proce
13、dure TForm1.myPasteClick(Sender: TObject);beginrichEdit1.PasteFromClipboard;end;procedure TForm1.myDeleteClick(Sender: TObject);beginrichEdit1.ClearSelection;end;procedure TForm1.myFindClick(Sender: TObject);beginfindDialog1.Execute;end;procedure TForm1.myReplaceClick(Sender: TObject);beginreplaceDi
14、alog1.Execute;end;procedure TForm1.myFontClick(Sender: TObject);beginfontDialog1.Font := richEdit1.Font; /初始化字体对话框if (fontDialog1.Execute) then richEdit1.SelAttributes.Assign(fontDialog1.Font);end;procedure TForm1.myPageClick(Sender: TObject);beginpageSetupDialog1.Execute;end;procedure TForm1.myPrin
15、tClick(Sender: TObject);beginif (printDialog1.Execute) thenbeginrichEdit1.Print(fName);end;end;procedure TForm1.myAboutClick(Sender: TObject);beginShowMessage(Delphi 记事本 1.0 + #13 + 记念于 12.5.14);end;procedure TForm1.myHelpTopicsClick(Sender: TObject);beginmyAboutClick(Sender);end;procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);beginmyQuitClick(Sender);end;end.Delphi 记事本程序源码及 exe 下载地址:http:/