频道分类

Delphi 动态生成进度条窗体

作者:admin 来源: 日期:2020/3/28 23:09:38 人气: 标签:

 
在implementation加入下面

uses
  Gauges;
 var Gauge1: TGauge;
 
加入Timer1控件,设为false 
 
procedure TForm1.Button1Click(Sender: TObject);
var
  form2: TForm;
begin
  form2 := TForm.Create(nil);
  form2.BorderStyle := bsNone;
  form2.Width := 360;
  form2.Height := 30;
  form2.Position := poMainFormCenter;
  Gauge1 := TGauge.Create(form2);
  Gauge1.MinValue := 0;
  Gauge1.MaxValue := 100;
  Gauge1.Width := form2.ClientWidth - 2;
  Gauge1.Height := 30;
  Gauge1.Left := 10;
  Gauge1.Top := (form2.ClientHeight - Gauge1.Height) div 2;
  Gauge1.Parent := form2;
  Timer1.Interval := 100;
  Timer1.Enabled := True;
  form2.ShowModal;
  form2.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;

上一篇:DELPHI 检测服务器地址是否有效下一篇:没有资料