Hello,
I build a tiny app, which do something (communicate via external program to server) when button is clicked and it takes some sec to finish. So I am trying to create simple little window with progress bar (left-right moving rectangle) and "Please, wait" text.
So there is a button which calls showmodal on that please-wait form and on onactivate event of this form is calling to my procedure which does the actual work and in it at the end is a call "hide" on please-wait form.
According to this:
http://wiki.lazarus.freepascal.org/Event_orderOnActivate event means, that form is already up and running and visible, am I right? But when I run my app, after pressing button I know that my working method is fired (app is frozen), then it is finished (I have result) and finally then a gray rectangle of size of my please-wait window just flashes and dissappear without even being paint properly.
I very possible do this wrong way, but I need just simple thing: I have one procedure which does something for some time. That procedure will be fired after button is pressed. And I need immediately after button is pressed to show a please-wait form in a way, that it will block a main window and only after it is visible and up, my working method will be fired.
In mainform there is button event:
procedure TmainForm.ButtonConnectClick(Sender: TObject);
begin
FormWait.Showmodal;
end;
Here is a whole please-wait form unit:
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ComCtrls;
type
{ TFormWait }
TFormWait = class(TForm)
ProgressBar1: TProgressBar;
procedure FormActivate(Sender: TObject);
private
{ private declarations }
public
{ public declarations }
protected
end;
var
FormWait: TFormWait;
implementation
{$R *.lfm}
uses
uMainForm;
{ TFormWait }
procedure TFormWait.FormActivate(Sender: TObject);
begin
mainForm.Reload;
end;
end.
and the reload procedure is the actual working method of mainform and it has at the end:
FormWait.Hide;
Can someone help me with this?
P.S. sorry for grammar and coding style - it is just quick&dirty little app.