Show Waiting Status (Without Thread)

{

When user click button, a window will showup with a Animate, progressbar, and a updated time label;

}

 

unit fMain;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;

type
  TForm1 = class(TForm)
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

implementation

uses Unit2;

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var
 i, j: Integer;
begin
 ShowStatus;
 try
   for i := 0 to 500000 do
    begin
     for j := 0 to 8000 do;
      Application.ProcessMessages;
    end;
  finally
   HideStatus;
  end;
end;

end. 

unit Unit2;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ExtCtrls, ComCtrls, MPlayer;

type
  TForm2 = class(TForm)
    Timer1: TTimer;
    Panel1: TPanel;
    Label1: TLabel;
    ProgressBar1: TProgressBar;
    Animate1: TAnimate;
    procedure FormDestroy(Sender: TObject);
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure Timer1Timer(Sender: TObject);
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

  procedure ShowStatus;
  procedure HideStatus;

var
  Form2: TForm2;

implementation

{$R *.dfm}

procedure ShowStatus;
begin
 Form2 := TForm2.Create(Application);
  Form2.Show;

  Screen.Cursor := crHourGlass;
end;

procedure HideStatus;
begin
 Form2.Close;
  Screen.Cursor := crDefault;
end;

procedure TForm2.FormDestroy(Sender: TObject);
begin
 Form2 := nil;
end;

procedure TForm2.FormClose(Sender: TObject; var Action: TCloseAction);
begin
 Action := caFree;
end;

procedure TForm2.Timer1Timer(Sender: TObject);
begin
 Label1.Caption := FormatDateTime('hh:mm:ss', Now);
  ProgressBar1.StepIt;
end;

procedure TForm2.FormCreate(Sender: TObject);
begin
 Label1.Caption := '';

  Animate1.CommonAVI := aviFindFolder;
  Animate1.Active := true;
end;

end.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值