大家好!请教个问题在保存文件时,如果碰到已有同名文件,就需要有“是否覆盖的提示”。现在我碰到一个问题,就是提示时如果点击“取消”按钮的话,覆盖提示消息框和保存文件对话框也一起消失了!我想像记事本那样,覆盖提示时如果点击“取消”按钮的话,消息框消失,而保存文件对话框继续保留,请问需要怎样做
procedure TForm1.btn1Click(Sender: TObject);
begin
begin
if dlgSave1.Execute then
if fileexists(dlgSave1.FileName) then
if Application.MessageBox(Pchar(dlgSave1.FileName +' 已存在,你要替换它吗?'),'另存为',MB_YESNO+MB_ICONWARNING )=IDNO then
Exit;
redt1.lines.savetofile(dlgSave1.FileName);
end;
end;
procedure TForm1.btn1Click(Sender: TObject);
begin
begin
if dlgSave1.Execute then
if fileexists(dlgSave1.FileName) then
if Application.MessageBox(Pchar(dlgSave1.FileName +' 已存在,你要替换它吗?'),'另存为',MB_YESNO+MB_ICONWARNING )=IDNO then
Exit;
redt1.lines.savetofile(dlgSave1.FileName);
end;
end;
begin
begin
if dlgSave1.Execute then
begin
if fileexists(dlgSave1.FileName) then
if Application.MessageBox(Pchar(dlgSave1.FileName +' 已存在,你要替换它吗?'),'另存为',MB_YESNO+MB_ICONWARNING )=IDNO then
Exit;
redt1.lines.savetofile(dlgSave1.FileName);
end;
end;
end;