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


  • Full Member
  • ***
  • Posts: 208
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);

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?



  • Hero Member
  • *****
  • Posts: 1252
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.0.10 - FPC 3.2.0 - x86_64-win64 on Windows 8

Fred vS

  • Hero Member
  • *****
  • Posts: 2836
    • StrumPract is the musicians best friend
Re: fpgui close not the same as close
« Reply #2 on: October 21, 2014, 08:18:06 pm »

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;
OnClose := @onCloseMyForm;     

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

« 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.


TinyPortal © 2005-2018