主题:请高手指教
原代码如下:错在//定义检查修改的过程如下
procedure CheckFileModi;
请高手指教
unit MyEdit;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ComCtrls, ToolWin, Menus, StdCtrls, ImgList;
type
TEditForm = class(TForm)
MainMenu1: TMainMenu;
N1: TMenuItem;
N2: TMenuItem;
N3: TMenuItem;
N4: TMenuItem;
N5: TMenuItem;
O1: TMenuItem;
S1: TMenuItem;
N6: TMenuItem;
P1: TMenuItem;
N7: TMenuItem;
N8: TMenuItem;
E1: TMenuItem;
N9: TMenuItem;
N10: TMenuItem;
N11: TMenuItem;
N12: TMenuItem;
N13: TMenuItem;
N14: TMenuItem;
N15: TMenuItem;
N16: TMenuItem;
N17: TMenuItem;
N18: TMenuItem;
N19: TMenuItem;
L1: TMenuItem;
N20: TMenuItem;
R1: TMenuItem;
N21: TMenuItem;
W1: TMenuItem;
N22: TMenuItem;
A1: TMenuItem;
RichEdit1: TRichEdit;
ToolBar1: TToolBar;
StatusBar1: TStatusBar;
OpenDialog1: TOpenDialog;
SaveDialog1: TSaveDialog;
FontDialog1: TFontDialog;
ColorDialog1: TColorDialog;
PrintDialog1: TPrintDialog;
PrinterSetupDialog1: TPrinterSetupDialog;
FindDialog1: TFindDialog;
ReplaceDialog1: TReplaceDialog;
PopupMenu1: TPopupMenu;
N23: TMenuItem;
N24: TMenuItem;
N25: TMenuItem;
N26: TMenuItem;
N27: TMenuItem;
N28: TMenuItem;
N30: TMenuItem;
N29: TMenuItem;
N31: TMenuItem;
N32: TMenuItem;
N33: TMenuItem;
ToolButton1: TToolButton;
ImageList1: TImageList;
ToolButton2: TToolButton;
ToolButton3: TToolButton;
ToolButton4: TToolButton;
procedure O1Click(Sender: TObject);
procedure S1Click(Sender: TObject);
procedure N5Click(Sender: TObject);
procedure E1Click(Sender: TObject);
procedure L1Click(Sender: TObject);
procedure N20Click(Sender: TObject);
procedure R1Click(Sender: TObject);
procedure W1Click(Sender: TObject);
procedure N22Click(Sender: TObject);
procedure P1Click(Sender: TObject);
procedure A1Click(Sender: TObject);
procedure N9Click(Sender: TObject);
procedure N12Click(Sender: TObject);
procedure N13Click(Sender: TObject);
procedure N14Click(Sender: TObject);
procedure N15Click(Sender: TObject);
procedure N16Click(Sender: TObject);
procedure N10Click(Sender: TObject);
procedure N18Click(Sender: TObject);
procedure N19Click(Sender: TObject);
procedure N7Click(Sender: TObject);
procedure N6Click(Sender: TObject);
procedure FindDialog1Find(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
EditForm: TEditForm;
pathname:string;
implementation
uses about;//放在最前面
{$R *.dfm}
//定义命名文件名的过程如下
procedure setfileName(const filename:string);
begin
pathname:=filename;
editform.caption:=format('%s-%s',[extractfilename(filename),application.title]);
//定义检查修改的过程如下
procedure CheckFileModi;
var Resp:integer;
begin
if not editform.richedit1.Modified then exit;
Resp:=messagedlg(format('将修改的文件存入文件%s?',
[pathname]),mtconfirmation,mbyesnocancel,0);
case Resp of
idyes:editform.RichEdit1.Lines.SaveToFile(pathname);
idno:;
idcancel:abort;
end;
end;
procedure CheckFileModi;
请高手指教
unit MyEdit;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ComCtrls, ToolWin, Menus, StdCtrls, ImgList;
type
TEditForm = class(TForm)
MainMenu1: TMainMenu;
N1: TMenuItem;
N2: TMenuItem;
N3: TMenuItem;
N4: TMenuItem;
N5: TMenuItem;
O1: TMenuItem;
S1: TMenuItem;
N6: TMenuItem;
P1: TMenuItem;
N7: TMenuItem;
N8: TMenuItem;
E1: TMenuItem;
N9: TMenuItem;
N10: TMenuItem;
N11: TMenuItem;
N12: TMenuItem;
N13: TMenuItem;
N14: TMenuItem;
N15: TMenuItem;
N16: TMenuItem;
N17: TMenuItem;
N18: TMenuItem;
N19: TMenuItem;
L1: TMenuItem;
N20: TMenuItem;
R1: TMenuItem;
N21: TMenuItem;
W1: TMenuItem;
N22: TMenuItem;
A1: TMenuItem;
RichEdit1: TRichEdit;
ToolBar1: TToolBar;
StatusBar1: TStatusBar;
OpenDialog1: TOpenDialog;
SaveDialog1: TSaveDialog;
FontDialog1: TFontDialog;
ColorDialog1: TColorDialog;
PrintDialog1: TPrintDialog;
PrinterSetupDialog1: TPrinterSetupDialog;
FindDialog1: TFindDialog;
ReplaceDialog1: TReplaceDialog;
PopupMenu1: TPopupMenu;
N23: TMenuItem;
N24: TMenuItem;
N25: TMenuItem;
N26: TMenuItem;
N27: TMenuItem;
N28: TMenuItem;
N30: TMenuItem;
N29: TMenuItem;
N31: TMenuItem;
N32: TMenuItem;
N33: TMenuItem;
ToolButton1: TToolButton;
ImageList1: TImageList;
ToolButton2: TToolButton;
ToolButton3: TToolButton;
ToolButton4: TToolButton;
procedure O1Click(Sender: TObject);
procedure S1Click(Sender: TObject);
procedure N5Click(Sender: TObject);
procedure E1Click(Sender: TObject);
procedure L1Click(Sender: TObject);
procedure N20Click(Sender: TObject);
procedure R1Click(Sender: TObject);
procedure W1Click(Sender: TObject);
procedure N22Click(Sender: TObject);
procedure P1Click(Sender: TObject);
procedure A1Click(Sender: TObject);
procedure N9Click(Sender: TObject);
procedure N12Click(Sender: TObject);
procedure N13Click(Sender: TObject);
procedure N14Click(Sender: TObject);
procedure N15Click(Sender: TObject);
procedure N16Click(Sender: TObject);
procedure N10Click(Sender: TObject);
procedure N18Click(Sender: TObject);
procedure N19Click(Sender: TObject);
procedure N7Click(Sender: TObject);
procedure N6Click(Sender: TObject);
procedure FindDialog1Find(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
EditForm: TEditForm;
pathname:string;
implementation
uses about;//放在最前面
{$R *.dfm}
//定义命名文件名的过程如下
procedure setfileName(const filename:string);
begin
pathname:=filename;
editform.caption:=format('%s-%s',[extractfilename(filename),application.title]);
//定义检查修改的过程如下
procedure CheckFileModi;
var Resp:integer;
begin
if not editform.richedit1.Modified then exit;
Resp:=messagedlg(format('将修改的文件存入文件%s?',
[pathname]),mtconfirmation,mbyesnocancel,0);
case Resp of
idyes:editform.RichEdit1.Lines.SaveToFile(pathname);
idno:;
idcancel:abort;
end;
end;