Delphi编程中状态条中添加进度条

减小字体 增大字体 作者:佚名  来源:不详  发布时间:2010-12-04 00:13:30

unit Unit6;

interface

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

type
  TForm6 = class(TForm)
    StatusBar1: TStatusBar;
    MaskEdit1: TMaskEdit;
    Label1: TLabel;
    Button1: TButton;
    Timer1: TTimer;
    procedure FormClose(Sender: TObject; var Action: TCloseAction);
    procedure Timer1Timer(Sender: TObject);
    procedure Button1Click(Sender: TObject);
    procedure StatusBar1DrawPanel(StatusBar: TStatusBar; Panel: TStatusPanel;
      const Rect: TRect);
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
    Fprog:TProgressbar;
    DrawRect:TRect;
  public
    { Public declarations }
  end;

var
  Form6: TForm6;

implementation

{$R *.dfm}

procedure TForm6.FormCreate(Sender: TObject);
begin
  Fprog:=TProgressbar.Create(Form6);
end;

procedure TForm6.StatusBar1DrawPanel(StatusBar: TStatusBar; Panel: TStatusPanel;
  const Rect: TRect);
begin
  DrawRect:=rect;
end;

procedure TForm6.Button1Click(Sender: TObject);
begin
  with Fprog do
  begin
    top:=DrawRect.Top;
    left:=DrawRect.Left;
    width:=DrawRect.Right-DrawRect.Left;
    height:=DrawRect.Bottom-DrawRect.Top;
    Visible:=true;
    parent:=StatusBar1;
    Smooth:=true;
  end;
  Fprog.Min:=0;
  Fprog.Max:=100;
  Fprog.Visible:=true;
  Fprog.Position:=0;
 //Fprog.Brush.Color:=clBlue;
  Timer1.Interval:=StrToInt(Trim(MaskEdit1.Text));
  StatusBar1.Panels.Items[1].Width:=150;
  StatusBar1.Repaint;
  Timer1.Enabled:=true;
end;

procedure TForm6.Timer1Timer(Sender: TObject);
begin
if Fprog.Position<100 then
begin
  Fprog.Position:=Fprog.Position+1;
  Fprog.Repaint;
end
else
  begin
  Timer1.Enabled:=false;
  ShowMessage('ok');
  end;
end;

procedure TForm6.FormClose(Sender: TObject; var Action: TCloseAction);
begin
  Fprog.Free;
end;

end.

//第一段的Style 设为 psOwnerDraw即可显示进度信息
 

Tags:

作者:佚名
  • 好的评价 如果您觉得此文章好,就请您
      0%(0)
  • 差的评价 如果您觉得此文章差,就请您
      0%(0)

文章评论评论内容只代表网友观点,与本站立场无关!

   评论摘要(共 0 条,得分 0 分,平均 0 分) 查看完整评论

广告位置B