Recent

Author Topic: OnCreate and OnActivate  (Read 10215 times)

howardpc

  • Hero Member
  • *****
  • Posts: 3785
Re: OnCreate and OnActivate
« Reply #15 on: September 13, 2021, 05:41:34 pm »
A typical linux has GUI form events in this order:
Code: Pascal  [Select][+][-]
  1. TForm1.FormCreate
  2. TForm1.FormShow
  3. TForm1.FormPaint
  4. TForm1.FormResize
  5. TForm1.FormActivate
  6. TForm1.FormPaint
  7. TForm1.FormClose
  8. TForm1.FormDestroy
However, the order of paint (and other) events may be widgetset dependent, as well as dependent on event-manipulating code your app may add.

wp

  • Hero Member
  • *****
  • Posts: 8897
Re: OnCreate and OnActivate
« Reply #16 on: September 13, 2021, 07:40:17 pm »
Test code :
Code: Pascal  [Select][+][-]
  1. procedure TForm1.FormCreate(Sender: TObject);// 1
  2. begin
  3.   showmessage('create');
  4.   caption := 'create'; // not seen coz' form not displayed
  5.   application.ProcessMessages;
  6. end;
  7. [...]
I would not use ShowMessage in an event logging test program because in order to show the message the message dialog will get focus and may change the normal flow of events in Form1. It is much better to add a Memo to Form1 and call "Memo.Lines.Add(---message---)" in the event handlers rather than ShowMessage.
Mainly Lazarus trunk / fpc 3.2.0 / all 32-bit on Win-10, but many more...

Mr.Madguy

  • Hero Member
  • *****
  • Posts: 718
Re: OnCreate and OnActivate
« Reply #17 on: September 14, 2021, 04:58:41 pm »
It's much easier to understand this events on Windows, because they're just equivalents of corresponding window messages.
WM_CREATE
WM_ACTIVATE
07.10.2021 - Major bug is fixed in main project, that was causing random crashes in 64bit version.
My project still requires full Delphi 2009 support to be ported to Lazarus.
It's time to finally do it, because Delphi 2009 is 12 years old.

jipété

  • New Member
  • *
  • Posts: 13
Re: OnCreate and OnActivate
« Reply #18 on: September 17, 2021, 12:06:52 am »
It is much better to add a Memo to Form1 and call "Memo.Lines.Add(---message---)" in the event handlers rather than ShowMessage.
Thx for that idea, it's ok.
I got that :
Code: Pascal  [Select][+][-]
  1. create
  2. resize
  3. show
  4. activate
  5. paint
  6. paint
  7. ...
Regards,
--
jp

dbannon

  • Hero Member
  • *****
  • Posts: 1601
    • tomboy-ng, a rewrite of the classic Tomboy
Re: OnCreate and OnActivate
« Reply #19 on: September 17, 2021, 02:53:16 am »
As jipété appears to be a Linux user, a far simpler approach is possible, put writeln('<Event Name>') in each event handler, that way, they appear even before the form is shown and in the actual order. See the printout in View->DebugWindows->ConsoleIn/Out.

You can do the same in Windows using debugln() but need to capture that output to a file (or tell the app it does really have a console...).

Davo
Lazarus 2, Linux (and reluctantly Win10, OSX)
My Project - https://github.com/tomboy-notes/tomboy-ng

 

TinyPortal © 2005-2018