如何用弹出窗口显示进度 - 回复 "嘿嘿嘿" 的问题


问题来源: http://www.cnblogs.com/del/archive/2010/01/08/1642072.html#1820853

准备工作: 在空白窗体上添加 Button 和 Timer, 并分别激活它们的默认事件.

unit Unit1;

interface

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

type
  TForm1 = class(TForm)
    Button1: TButton;
    Timer1: TTimer;
    procedure Button1Click(Sender: TObject);
    procedure Timer1Timer(Sender: TObject);
  end;

var
  Form1: TForm1;

implementation

{$R *.dfm}

uses Gauges;

var Gauge1: TGauge;

procedure TForm1.Button1Click(Sender: TObject);
var
  frm: TForm;
begin
  frm := TForm.Create(nil);
  frm.BorderStyle := bsSizeToolWin;
  frm.Width := 300;
  frm.Height := 80;
  frm.Position := poDesktopCenter;
    Gauge1 := TGauge.Create(frm);
    Gauge1.MinValue := 0;
    Gauge1.MaxValue := 100;
    Gauge1.Width := frm.ClientWidth - 40;
    Gauge1.Height := 20;
    Gauge1.Left := 20;
    Gauge1.Top := (frm.ClientHeight - Gauge1.Height) div 2;
    Gauge1.Parent := frm;
  Timer1.Interval := 100;
  Timer1.Enabled := True;
  frm.ShowModal;
  frm.Free;
  Timer1.Enabled := False;
end;

procedure TForm1.Timer1Timer(Sender: TObject);
begin
  if Assigned(Gauge1) then
  begin
    Gauge1.Progress := Gauge1.Progress + 1;
    if Gauge1.Progress = Gauge1.MaxValue then TForm(Gauge1.Parent).ModalResult := 1;
  end;
end;

end.

 
 
 
 
 

 

 

  

运行效果图:

26153837_7k8k.gif

转载于:https://my.oschina.net/hermer/blog/320675

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值