Recent

Author Topic: Initial process that starts after open form  (Read 5850 times)

dek

  • New member
  • *
  • Posts: 9
Initial process that starts after open form
« on: June 11, 2008, 10:32:34 pm »
I would like to start an initial process when the program starts.
The form does not appear until finish the process if I put it in TForm1.FormCreate procedure. Since it takes a time, I would like to open or show the form first.

How can I open the form first? Is there any procedure to execute after open the form?

Please advise.

Leledumbo

  • Hero Member
  • *****
  • Posts: 8757
  • Programming + Glam Metal + Tae Kwon Do = Me
RE: Initial process that starts after open form
« Reply #1 on: June 12, 2008, 10:08:50 am »
You can use either OnShow or OnActivate event. Declare a local typed constant so that the process isn't repeated everytime (i.e. only once).

Bart

  • Hero Member
  • *****
  • Posts: 5290
    • Bart en Mariska's Webstek
RE: Initial process that starts after open form
« Reply #2 on: June 12, 2008, 10:23:37 pm »
You can do something like:

declare the procedure like:
procedure DoIt(DummyParam: PtrInt);

then in OnActivate do
  Application.QueueAsyncCall(@DoIt, 0);

It will queue DoIt in the Apllication queue, so it will be executed after all items in the queue are handled. In effect this means that DoIt will be executed after the form has been drawn on the screen.

Bart

dek

  • New member
  • *
  • Posts: 9
RE: Initial process that starts after open form
« Reply #3 on: June 13, 2008, 07:42:46 pm »
Thanks, Bart.

That is what I am looking for!
It works well for me.

Thanks again.

Phil

  • Hero Member
  • *****
  • Posts: 2737
Re: RE: Initial process that starts after open form
« Reply #4 on: June 13, 2008, 08:10:21 pm »
Quote from: "dek"
Thanks, Bart.

That is what I am looking for!
It works well for me.

Thanks again.


Here's what I use, which looks a bit cleaner:

  Application.Initialize;
  Application.CreateForm(TMainForm, MainForm);
  MainForm.Show;  {Display main form as backdrop}
  if MainForm.StartUpProgram then  {your routine here}
    Application.Run;

Thanks.

-Phil

 

TinyPortal © 2005-2018