Recent

Author Topic: Procedure to run upon application-start?  (Read 26448 times)

Mike.Cornflake

  • Hero Member
  • *****
  • Posts: 1269
Re: Procedure to run upon application-start?
« Reply #15 on: August 04, 2011, 08:31:02 pm »
Heh - I didn't know about Application.OnActivate.  You live and learn - many thanks :-)
Lazarus Trunk/FPC latest fixes on Windows 11
  I'm getting old and stale.  Slowly getting used to git, I'll get there...

Elmug

  • Hero Member
  • *****
  • Posts: 849
Re: Procedure to run upon application-start?
« Reply #16 on: August 05, 2011, 01:11:38 am »
Thank you Avra for your great explanation on the discovery working only with ONE form, but if more than one form, then it fires when back from the other forms (sound like what Mike was saying).

Since I'm still in the Lazarus Kindergarden, for now I will just save this thread for future reference or use, and be happy that I can use the event when  I only have one fom. :-X ;)

avra

  • Hero Member
  • *****
  • Posts: 2584
    • Additional info
Re: Procedure to run upon application-start?
« Reply #17 on: August 07, 2011, 05:46:13 pm »
Thank you Avra for your great explanation on the discovery working only with ONE form, but if more than one form, then it fires when back from the other forms (sound like what Mike was saying).
I am not sure I quite understand what you were saying here. This code snippet will work with 1 or 101 forms, it doesn't matter:
Code: [Select]
procedure TForm1.FormCreate(Sender: TObject);
begin
  Application.AddOnActivateHandler(@MyAppOnActivateEvent);
end;
If you made event properly as described in my second answer, and register it with Application.AddOnActivateHandler, then it will get fired when ever you application gets active, no matter what number of forms you have. Wasn't that what you were looking for?
« Last Edit: August 07, 2011, 05:48:10 pm by avra »
ct2laz - Conversion between Lazarus and CodeTyphon
bithelpers - Bit manipulation for standard types
pasettimino - Siemens S7 PLC lib

 

TinyPortal © 2005-2018