Recent

Author Topic: OnCreate and OnActivate  (Read 12380 times)

howardpc

  • Hero Member
  • *****
  • Posts: 4144
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: 11830
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.

Mr.Madguy

  • Hero Member
  • *****
  • Posts: 844
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
Is it healthy for project not to have regular stable releases?
Just for fun: Code::Blocks, GCC 13 and DOS - is it possible?

jipété

  • Full Member
  • ***
  • Posts: 113
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: 2778
    • 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 and my github - https://github.com/davidbannon

 

TinyPortal © 2005-2018