Recent

Author Topic: fpgui close not the same as close  (Read 5508 times)

dieselnutjob

  • Full Member
  • ***
  • Posts: 217
fpgui close not the same as close
« 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

Edson

  • Hero Member
  • *****
  • Posts: 1312
Re: fpgui close not the same as close
« Reply #1 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().
Lazarus 2.2.6 - FPC 3.2.2 - x86_64-win64 on Windows 10

Fred vS

  • Hero Member
  • *****
  • Posts: 3362
    • StrumPract is the musicians best friend
Re: fpgui close not the same as close
« Reply #2 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
« Last Edit: October 21, 2014, 08:23:08 pm by Fred vS »
I use Lazarus 2.2.0 32/64 and FPC 3.2.2 32/64 on Debian 11 64 bit, Windows 10, Windows 7 32/64, Windows XP 32,  FreeBSD 64.
Widgetset: fpGUI, MSEgui, Win32, GTK2, Qt.

https://github.com/fredvs
https://gitlab.com/fredvs
https://codeberg.org/fredvs

 

TinyPortal © 2005-2018