1个回答
展开全部
正好以前写过一个,发出来了,如果需要源码可以联系的
QQ:631113025
unit main;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Menus, StdCtrls,shellapi, ComCtrls, ActnList, ExtCtrls;
type
TMainfrm = class(TForm)
MainMenu1: TMainMenu;
N1: TMenuItem;
E1: TMenuItem;
S1: TMenuItem;
H1: TMenuItem;
Mu_New: TMenuItem;
Mu_Open: TMenuItem;
Mu_Save: TMenuItem;
Mu_SaveAs: TMenuItem;
N3: TMenuItem;
Mu_PrtSet: TMenuItem;
Mu_Prt: TMenuItem;
N5: TMenuItem;
Mu_Quit: TMenuItem;
Mu_UnDo: TMenuItem;
N7: TMenuItem;
Mu_Cut: TMenuItem;
Mu_Copy: TMenuItem;
Mu_Paste: TMenuItem;
Mu_Del: TMenuItem;
N9: TMenuItem;
Mu_SelectAll: TMenuItem;
Mu_Date: TMenuItem;
N10: TMenuItem;
Mu_AutoLine: TMenuItem;
Mu_Font: TMenuItem;
Mu_Find: TMenuItem;
Mu_FindNext: TMenuItem;
Mu_Help: TMenuItem;
Mu_About: TMenuItem;
N14: TMenuItem;
Memo1: TMemo;
StatusBar1: TStatusBar;
OpenDlg: TOpenDialog;
SaveDlg: TSaveDialog;
FontDlg: TFontDialog;
PrtSetDlg: TPrinterSetupDialog;
FindDlg: TFindDialog;
ReplaceDlg: TReplaceDialog;
Mu_AutoSave: TMenuItem;
PrintDialog1: TPrintDialog;
ActionList1: TActionList;
Ac_UnDo: TAction;
Ac_copy: TAction;
Ac_Cut: TAction;
Ac_Paste: TAction;
Ac_Del: TAction;
procedure Mu_AboutClick(Sender: TObject);
procedure Mu_HelpClick(Sender: TObject);
procedure Mu_OpenClick(Sender: TObject);
procedure Mu_SaveClick(Sender: TObject);
procedure Mu_NewClick(Sender: TObject);
procedure Memo1Change(Sender: TObject);
procedure Mu_QuitClick(Sender: TObject);
procedure Mu_SaveAsClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure Mu_PrtSetClick(Sender: TObject);
procedure Mu_FontClick(Sender: TObject);
procedure Ac_UnDoExecute(Sender: TObject);
procedure Ac_copyExecute(Sender: TObject);
procedure Ac_CutExecute(Sender: TObject);
procedure Ac_PasteExecute(Sender: TObject);
procedure Ac_UnDoUpdate(Sender: TObject);
procedure ActionList1Update(Action: TBasicAction;
var Handled: Boolean);
procedure Ac_DelExecute(Sender: TObject);
procedure Mu_SelectAllClick(Sender: TObject);
procedure Mu_DateClick(Sender: TObject);
procedure Mu_AutoLineClick(Sender: TObject);
procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Mainfrm: TMainfrm;
MainFilename:shortstring;
IsChanged,IsSaved:boolean;
implementation
uses Clipbrd;
{$R *.dfm}
procedure TMainfrm.Mu_AboutClick(Sender: TObject);
var CopyRightStr:string;
begin
copyRightstr:='本软件为免费软件.育林软件 版权所有@2006-2008';
shellabout(self.Handle,'迷你记事本',pchar(copyrightstr),application.Icon.Handle);
end;
procedure TMainfrm.Mu_HelpClick(Sender: TObject);
begin
shellexecute(self.Handle,'open','C:\WINDOWS\HELP\Notepad.chm',nil,nil,sw_normal);
end;
procedure TMainfrm.Mu_OpenClick(Sender: TObject);
begin
if IsChanged then
if messagebox(self.Handle,'文件已经更改,是否保存所做的修改?','提示',mb_yesno or mb_iconinformation)=Id_yes then
mu_save.Click;
if not opendlg.Execute then exit;
MainFilename:=opendlg.FileName;
memo1.Lines.LoadFromFile(MainFilename);
issaved:=true;
ischanged:=false;
end;
procedure TMainfrm.Mu_SaveClick(Sender: TObject);
begin
if not ischanged then exit;
if issaved then
begin
memo1.Lines.SaveToFile(Mainfilename);
end else
begin
MainFilename:=copy(trim(memo1.Lines[0]),0,20);
Mainfilename:=changefileext(mainFilename,'.txt');
savedlg.FileName:=mainfilename;
if savedlg.Execute then
begin
Mainfilename:=savedlg.FileName;
memo1.Lines.SaveToFile(Mainfilename);
issaved:=true;
end;{If}
end;
ischanged:=false;
end;
procedure TMainfrm.Mu_NewClick(Sender: TObject);
begin
if IsChanged then
if messagebox(self.Handle,'文件已经更改,是否保存所做的修改?','提示',mb_yesno or mb_iconinformation)=Id_yes then
mu_save.Click;
memo1.Clear;
ischanged:=false;
issaved:=false;
end;
procedure TMainfrm.Memo1Change(Sender: TObject);
begin
ischanged:=true;
end;
procedure TMainfrm.Mu_QuitClick(Sender: TObject);
begin
self.Close;
end;
procedure TMainfrm.Mu_SaveAsClick(Sender: TObject);
begin
if issaved then
begin
savedlg.FileName:=mainfilename;
if savedlg.Execute then
begin
Mainfilename:=savedlg.FileName;
memo1.Lines.SaveToFile(Mainfilename);
end;{If}
end else
begin
ischanged:=true;
mu_save.Click;
end;{If}
issaved:=true;
ischanged:=false;
end;
procedure TMainfrm.FormCreate(Sender: TObject);
begin
issaved:=false;
ischanged:=false;
end;
procedure TMainfrm.Mu_PrtSetClick(Sender: TObject);
begin
PrtSetDlg.Execute;
end;
procedure TMainfrm.Mu_FontClick(Sender: TObject);
begin
if not fontdlg.Execute then exit;
memo1.Font:=fontdlg.Font;
end;
procedure TMainfrm.Ac_UnDoExecute(Sender: TObject);
begin
memo1.Undo;
end;
procedure TMainfrm.Ac_copyExecute(Sender: TObject);
begin
memo1.CopyToClipboard;
end;
procedure TMainfrm.Ac_CutExecute(Sender: TObject);
begin
memo1.CutToClipboard;
end;
procedure TMainfrm.Ac_PasteExecute(Sender: TObject);
begin
memo1.PasteFromClipboard;
end;
procedure TMainfrm.Ac_UnDoUpdate(Sender: TObject);
begin
ac_undo.Enabled:=memo1.CanUndo;
end;
procedure TMainfrm.ActionList1Update(Action: TBasicAction;
var Handled: Boolean);
var Selected:boolean;
begin
selected:=memo1.SelLength>0;
ac_copy.Enabled:=selected;
ac_cut.Enabled:=selected;
ac_del.Enabled:=selected;
ac_paste.Enabled:=Clipboard.HasFormat(CF_TEXT);
end;
procedure TMainfrm.Ac_DelExecute(Sender: TObject);
begin
memo1.SelText:='';
end;
procedure TMainfrm.Mu_SelectAllClick(Sender: TObject);
begin
memo1.SelectAll;
end;
procedure TMainfrm.Mu_DateClick(Sender: TObject);
begin
memo1.SelText:=datetimetostr(now);
end;
procedure TMainfrm.Mu_AutoLineClick(Sender: TObject);
begin
mu_autoline.Checked:=not mu_autoline.Checked ;
if mu_autoline.Checked then
memo1.ScrollBars:=ssVertical
else
memo1.ScrollBars:=ssBoth;
memo1.Update;
end;
procedure TMainfrm.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
begin
if ischanged then
if messagebox(self.Handle,'文件已经更改,是否保存所做的修改?','提示',mb_yesno or mb_iconinformation)=Id_yes then
mu_save.Click;
canclose:=true;
end;
end.
QQ:631113025
unit main;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, Menus, StdCtrls,shellapi, ComCtrls, ActnList, ExtCtrls;
type
TMainfrm = class(TForm)
MainMenu1: TMainMenu;
N1: TMenuItem;
E1: TMenuItem;
S1: TMenuItem;
H1: TMenuItem;
Mu_New: TMenuItem;
Mu_Open: TMenuItem;
Mu_Save: TMenuItem;
Mu_SaveAs: TMenuItem;
N3: TMenuItem;
Mu_PrtSet: TMenuItem;
Mu_Prt: TMenuItem;
N5: TMenuItem;
Mu_Quit: TMenuItem;
Mu_UnDo: TMenuItem;
N7: TMenuItem;
Mu_Cut: TMenuItem;
Mu_Copy: TMenuItem;
Mu_Paste: TMenuItem;
Mu_Del: TMenuItem;
N9: TMenuItem;
Mu_SelectAll: TMenuItem;
Mu_Date: TMenuItem;
N10: TMenuItem;
Mu_AutoLine: TMenuItem;
Mu_Font: TMenuItem;
Mu_Find: TMenuItem;
Mu_FindNext: TMenuItem;
Mu_Help: TMenuItem;
Mu_About: TMenuItem;
N14: TMenuItem;
Memo1: TMemo;
StatusBar1: TStatusBar;
OpenDlg: TOpenDialog;
SaveDlg: TSaveDialog;
FontDlg: TFontDialog;
PrtSetDlg: TPrinterSetupDialog;
FindDlg: TFindDialog;
ReplaceDlg: TReplaceDialog;
Mu_AutoSave: TMenuItem;
PrintDialog1: TPrintDialog;
ActionList1: TActionList;
Ac_UnDo: TAction;
Ac_copy: TAction;
Ac_Cut: TAction;
Ac_Paste: TAction;
Ac_Del: TAction;
procedure Mu_AboutClick(Sender: TObject);
procedure Mu_HelpClick(Sender: TObject);
procedure Mu_OpenClick(Sender: TObject);
procedure Mu_SaveClick(Sender: TObject);
procedure Mu_NewClick(Sender: TObject);
procedure Memo1Change(Sender: TObject);
procedure Mu_QuitClick(Sender: TObject);
procedure Mu_SaveAsClick(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure Mu_PrtSetClick(Sender: TObject);
procedure Mu_FontClick(Sender: TObject);
procedure Ac_UnDoExecute(Sender: TObject);
procedure Ac_copyExecute(Sender: TObject);
procedure Ac_CutExecute(Sender: TObject);
procedure Ac_PasteExecute(Sender: TObject);
procedure Ac_UnDoUpdate(Sender: TObject);
procedure ActionList1Update(Action: TBasicAction;
var Handled: Boolean);
procedure Ac_DelExecute(Sender: TObject);
procedure Mu_SelectAllClick(Sender: TObject);
procedure Mu_DateClick(Sender: TObject);
procedure Mu_AutoLineClick(Sender: TObject);
procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Mainfrm: TMainfrm;
MainFilename:shortstring;
IsChanged,IsSaved:boolean;
implementation
uses Clipbrd;
{$R *.dfm}
procedure TMainfrm.Mu_AboutClick(Sender: TObject);
var CopyRightStr:string;
begin
copyRightstr:='本软件为免费软件.育林软件 版权所有@2006-2008';
shellabout(self.Handle,'迷你记事本',pchar(copyrightstr),application.Icon.Handle);
end;
procedure TMainfrm.Mu_HelpClick(Sender: TObject);
begin
shellexecute(self.Handle,'open','C:\WINDOWS\HELP\Notepad.chm',nil,nil,sw_normal);
end;
procedure TMainfrm.Mu_OpenClick(Sender: TObject);
begin
if IsChanged then
if messagebox(self.Handle,'文件已经更改,是否保存所做的修改?','提示',mb_yesno or mb_iconinformation)=Id_yes then
mu_save.Click;
if not opendlg.Execute then exit;
MainFilename:=opendlg.FileName;
memo1.Lines.LoadFromFile(MainFilename);
issaved:=true;
ischanged:=false;
end;
procedure TMainfrm.Mu_SaveClick(Sender: TObject);
begin
if not ischanged then exit;
if issaved then
begin
memo1.Lines.SaveToFile(Mainfilename);
end else
begin
MainFilename:=copy(trim(memo1.Lines[0]),0,20);
Mainfilename:=changefileext(mainFilename,'.txt');
savedlg.FileName:=mainfilename;
if savedlg.Execute then
begin
Mainfilename:=savedlg.FileName;
memo1.Lines.SaveToFile(Mainfilename);
issaved:=true;
end;{If}
end;
ischanged:=false;
end;
procedure TMainfrm.Mu_NewClick(Sender: TObject);
begin
if IsChanged then
if messagebox(self.Handle,'文件已经更改,是否保存所做的修改?','提示',mb_yesno or mb_iconinformation)=Id_yes then
mu_save.Click;
memo1.Clear;
ischanged:=false;
issaved:=false;
end;
procedure TMainfrm.Memo1Change(Sender: TObject);
begin
ischanged:=true;
end;
procedure TMainfrm.Mu_QuitClick(Sender: TObject);
begin
self.Close;
end;
procedure TMainfrm.Mu_SaveAsClick(Sender: TObject);
begin
if issaved then
begin
savedlg.FileName:=mainfilename;
if savedlg.Execute then
begin
Mainfilename:=savedlg.FileName;
memo1.Lines.SaveToFile(Mainfilename);
end;{If}
end else
begin
ischanged:=true;
mu_save.Click;
end;{If}
issaved:=true;
ischanged:=false;
end;
procedure TMainfrm.FormCreate(Sender: TObject);
begin
issaved:=false;
ischanged:=false;
end;
procedure TMainfrm.Mu_PrtSetClick(Sender: TObject);
begin
PrtSetDlg.Execute;
end;
procedure TMainfrm.Mu_FontClick(Sender: TObject);
begin
if not fontdlg.Execute then exit;
memo1.Font:=fontdlg.Font;
end;
procedure TMainfrm.Ac_UnDoExecute(Sender: TObject);
begin
memo1.Undo;
end;
procedure TMainfrm.Ac_copyExecute(Sender: TObject);
begin
memo1.CopyToClipboard;
end;
procedure TMainfrm.Ac_CutExecute(Sender: TObject);
begin
memo1.CutToClipboard;
end;
procedure TMainfrm.Ac_PasteExecute(Sender: TObject);
begin
memo1.PasteFromClipboard;
end;
procedure TMainfrm.Ac_UnDoUpdate(Sender: TObject);
begin
ac_undo.Enabled:=memo1.CanUndo;
end;
procedure TMainfrm.ActionList1Update(Action: TBasicAction;
var Handled: Boolean);
var Selected:boolean;
begin
selected:=memo1.SelLength>0;
ac_copy.Enabled:=selected;
ac_cut.Enabled:=selected;
ac_del.Enabled:=selected;
ac_paste.Enabled:=Clipboard.HasFormat(CF_TEXT);
end;
procedure TMainfrm.Ac_DelExecute(Sender: TObject);
begin
memo1.SelText:='';
end;
procedure TMainfrm.Mu_SelectAllClick(Sender: TObject);
begin
memo1.SelectAll;
end;
procedure TMainfrm.Mu_DateClick(Sender: TObject);
begin
memo1.SelText:=datetimetostr(now);
end;
procedure TMainfrm.Mu_AutoLineClick(Sender: TObject);
begin
mu_autoline.Checked:=not mu_autoline.Checked ;
if mu_autoline.Checked then
memo1.ScrollBars:=ssVertical
else
memo1.ScrollBars:=ssBoth;
memo1.Update;
end;
procedure TMainfrm.FormCloseQuery(Sender: TObject; var CanClose: Boolean);
begin
if ischanged then
if messagebox(self.Handle,'文件已经更改,是否保存所做的修改?','提示',mb_yesno or mb_iconinformation)=Id_yes then
mu_save.Click;
canclose:=true;
end;
end.
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询