Recent

Author Topic: How run function (button.click) after finish loading form ?  (Read 7066 times)

seba22

  • Full Member
  • ***
  • Posts: 136
How run function (button.click) after finish loading form ?
« on: March 20, 2010, 06:40:32 pm »
Welcome,

How can i run function button.click after fully loading and drawing form ?

When i put into on_create event i's trigger before loading... user don't see window but application running.

I want to display progress bar what i got on form... that's why i need create it first... any idea ?

windy

  • Full Member
  • ***
  • Posts: 186
Re: How run function (button.click) after finish loading form ?
« Reply #1 on: March 20, 2010, 10:26:54 pm »
I would use the onshow event for the forms properties-> events

Ocye

  • Hero Member
  • *****
  • Posts: 518
    • Scrabble3D
Re: How run function (button.click) after finish loading form ?
« Reply #2 on: March 21, 2010, 07:56:24 am »
Actually main form is visible after OnShow. You can make use of OnIdle to do some work after OnCreate, OnActivate and OnShow. I'm not sure if "run function button.click" fits in that concept.

Code: [Select]
type
  TForm1=class(TForm)
  ...
  private
    procedure DoIdle(Sender:TObject;var done:boolean);
  end;

procedure TForm1.OnCreate(...)
begin
  Application.OnIdle:=@DoIdle;
end;

procedure TForm1.DoIdle(Sender:TObject;var done:boolean);
var i:integer;
begin
  for i:=0 to 99 do
  begin
    SomeHardWork;
    ProgressBar1.Progress:=i;
  end;
  done:=true;
  Application.OnIdle:=nil;
end;
Lazarus 1.7 (SVN) FPC 3.0.0

 

TinyPortal © 2005-2018