How can I close TIDEDialog without user intervention?
Is there any way to simulate IDEDielog1.Close?
Thank you
wlandgraf
(Wagner Landgraf)
February 2, 2020, 8:15pm
2
You can simply send a WM_CLOSE message to the scripter IDE window:
SendMessage(FindWindow(PChar('TIDEEditorForm'), nil), WM_CLOSE, 0, 0);
I need to close the IDE without the dialog screens asking the user if he wants to save the files that have been changed.
For this, I'm using the code:
for i:=IDEEngine1.Files.Count - 1 downto 0 do
IDEEngine1.Files[i].Free;
SendMessage(FindWindow(PChar('TIDEEditorForm'), nil), WM_CLOSE, 0, 0);
Is this the best way to do this?
wlandgraf
(Wagner Landgraf)
February 5, 2020, 1:54pm
5
There are several ways. What you've done is not wrong.
Alternatively you can set TIDEEngine.OnConfirmSaveFile event handler like this:
procedure TForm4.IDEEngine1ConfirmSaveFile(Sender: TObject;
IDEFileType: TIDEFileType; AFileName: string; AFile: TIDEProjectFile;
var Action: TIDEConfirmSaveType; var Handled: Boolean);
begin
Action := cstDontSave;
end;
Or you can set a property in TIDEDialog:
IDEDialog1.IDECloseAction := icaNothing;
Thank you, but there are some problems with your suggestions:
In the first suggestion, I must be include a "Handled:=True;" for it to work.
In the second suggestion, sometimes I need to keep the messages in the Save dialog box and if I change the "IDECloseAction" property at run time the messages are still displayed.
Apparently the IDECloseAction property cannot be changed after the IDE is displayed.
wlandgraf
(Wagner Landgraf)
February 6, 2020, 11:25am
7
Yes, all are statements are correct.