Lazarus

Programming => Widgetset => Other => Topic started by: dieselnutjob on October 21, 2014, 06:20:56 pm

Title: fpgui close not the same as close
Post by: dieselnutjob on October 21, 2014, 06:20:56 pm
My app has this code that I snaffled from some example code somewhere.

Code: [Select]
procedure TMainForm.buttonQuitClicked(Sender: TObject);
begin
 Close;
end;

I have noticed that clicking the buttonQuit does not have the same effect as clicking on the windows "X" thing on the type right of the form.

More specifically the difference seems to be in how threads get torn down.

My thread quitting code is in an overridden BeforeDestruction procedure.

Can anyone give me a clue why TfpgBaseForm.close (which is what close above appears to call) is different to clicking the windows X, and what happens when a user does that?

thanks
Title: Re: fpgui close not the same as close
Post by: Edson on October 21, 2014, 07:49:38 pm
According to my Lazarus book ("Lazarus, domando al gatito" :)), one difference is that when you use the X Windows button, you have always the Form with focus, so the sequence of events will always include OnDeactivate().
Title: Re: fpgui close not the same as close
Post by: Fred vS on October 21, 2014, 08:18:06 pm
Hello.

I do not know if it helps but fpGUI uses for Form.onClose => TCloseAction as parameter =>
(caNone, caHide, caFree)

Example how to close a form and free it =>

Code: [Select]
procedure TMyForm.AfterCreate;
begin
....
OnClose := @onCloseMyForm;     
...
end;

procedure TMyForm.onCloseMyForm(Sender: TObject; var CloseAct : TCloseAction);
begin
CloseAct := caFree;
end;
 

Fre;D
TinyPortal © 2005-2018