zoukankan      html  css  js  c++  java
  • 如何用弹出窗口显示进度


    准备工作: 在空白窗体上添加 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.

  • 相关阅读:
    Linux修改root密码报错
    Python中的排序---冒泡法
    Python随机数
    Python中的深拷贝和浅拷贝
    Couldn’t download https://raw.githubusercontent.com/certbot/certbot/ 问题解决
    Python内置数据结构----list
    Python内置数据结构
    Vue指令
    computed 和 watch
    Vue的数据响应式
  • 原文地址:https://www.cnblogs.com/wanqian/p/3116113.html
Copyright © 2011-2022 走看看