Recent

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

dieselnutjob

  • Full Member
  • ***
  • Posts: 141
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: 1055
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 1.6 - FPC 3.0.0 - x86_64-win64 on  Windows 7

Fred vS

  • Hero Member
  • *****
  • Posts: 1675
    • miXimum is the DJ's 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 1.8.0 32/64 and FPC 3.0.3 32/64 on Linux Mint Mate 17 32/64, Windows 10, Windows 7 32/64, Windows XP 32,  FreeBSD 64 and Mac OS X Snow Leopard 32.
Widgetset: fpGUI, MSEgui, Win32, GTK2, Qt, Carbon.

https://github.com/fredvs