Delphi 下 TProgressBar的使用

通过例子来简单了解下TProgressBar的使用。

pas文件程序如下

unit Unit4;

interface

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

type
  TForm4 = class(TForm)
    progress: TProgressBar;
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form4: TForm4;

implementation

{$R *.dfm}

procedure TForm4.FormCreate(Sender: TObject);
var
  I: Integer;
begin
  try
    progress.Max := 100;
    for I := 0 to 100 - 1 do
    begin
      Application.ProcessMessages;
      progress.Position := I;
      Sleep(50);
    end;
  finally
    //progress.Max := 0;
  end;
  
end;

end.
fram文件如下:

object Form4: TForm4
  Left = 0
  Top = 0
  Caption = 'Form4'
  ClientHeight = 300
  ClientWidth = 635
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'Tahoma'
  Font.Style = []
  OldCreateOrder = False
  OnCreate = FormCreate
  PixelsPerInch = 96
  TextHeight = 13
  object progress: TProgressBar
    Left = 0
    Top = 283
    Width = 635
    Height = 17
    Align = alBottom
    TabOrder = 0
  end
end

实际运行结果如图所示:



以上程序即可简单的使用TProgressBar。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值