Home > Back-end >  Novice asked about the use of Delphi controls SaveDialog controls
Novice asked about the use of Delphi controls SaveDialog controls

Time:09-27

I write a notepad program then I use SaveDialog controls, why I save Mome inside the file, I don't care click save button or click the cancel button will keep the content, how can you tell me some of what is to save or cancel it, code I can't write hope ace told the novice, here is my code:

Procedure TForm1. N3Click (Sender: TObject);
The begin
If bj. Lines. The Text="' then
MessageBox (Handle, 'save the content cannot be empty', 'Warning:', MB_OK or MB_ICONWARNING)
The else

The begin

DlgSave1. Execute;
Bj. Lines. SaveToFile (dlgSave1 FileName);

The end;


The end;

CodePudding user response:

DlgSave1. Execute;
Bj. Lines. SaveToFile (dlgSave1 FileName);
-->
If dlgSave1. Execute then
Bj. Lines. SaveToFile (dlgSave1 FileName);

CodePudding user response:

 procedure TForm1. Button1Click (Sender: TObject); 
The begin
If Memo1. Text="' then
MessageBox (Handle, 'save the content cannot be empty', 'Warning:', MB_OK or MB_ICONWARNING)
The else begin
If MessageBox (0, 'agreed to save,' tip 'MB_OKCANCEL)=idOK then
If SaveDialog1. Execute then
Memo1. Lines. SaveToFile (SaveDialog1 FileName);
The end;
The end;

The code above, should solve the problem,

CodePudding user response:

If dlgSave1. Execute then
Bj. Lines. SaveToFile (dlgSave1 FileName);

CodePudding user response:

Upstairs have mentioned a few prawns, must first determine whether dlgSave1 execution, the save is to perform,

CodePudding user response:

The key technology is to determine whether to implement save

 
If SaveDialog1. Execute then

CodePudding user response:

I have been writing so
 
If SaveDialog1. Execute then
The Begin
//handle code written here, finally using showmessage statement such as pop-up prompt dialog,
End

CodePudding user response:

Should be written using standard code, everyone is so beneficial to practice!

CodePudding user response:

Procedure TForm1. Button1Click (Sender: TObject);
The begin
If Memo1. Text="' then
The begin
MessageBox (Handle, 'save the content cannot be empty', 'Warning:', MB_OK or MB_ICONWARNING);
exit;
The end;
If SaveDialog1. Execute then
If SaveDialog1. The FileName=' 'then//no input file name
The Exit;
If MessageBox (0, 'agreed to save,' tip 'MB_OKCANCEL)=idOK then
Try
Memo1. Lines. SaveToFile (SaveDialog1 FileName);
MessageBox (Handle, 'save success', 'Warning: ", MB_OK or MB_ICONWARNING);
Except,
MessageBox (Handle, 'save failed', 'Warning: ", MB_OK or MB_ICONWARNING);
The end;

The end;
  • Related