WEB开发网
开发学院软件开发Delphi 状态栏显示进度条 阅读

状态栏显示进度条

 2006-02-04 13:42:44 来源:WEB开发网   
核心提示: {***}{ }{ Delphi ESite : http://yckxzjj.vip.sina.com }{ KingLong Studio:刀剑如梦软件创作室 }{ QQ:20775028 E-Mail : yckzxjj@vip.sina.com }{ Copyright (c) 2003 Kin
 {*******************************************************}
{                                                 }
{            Delphi ESite : http://yckxzjj.vip.sina.com         }
{            KingLong Studio:刀剑如梦软件创作室          }
{          QQ:20775028  E-Mail : yckzxjj@vip.sina.com      }
{         Copyright (c) 2003 KingLong Software Studio        }
{                                                 }
{*******************************************************}
unit UAddPRogressbar;

interface

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

type
  TAddProgressbarFrm = class(TForm)
   Status: TStatusBar;
   Button1: TButton;
   procedure StatusDrawPanel(StatusBar: TStatusBar;
    Panel: TStatusPanel; const Rect: TRect);
   procedure Button1Click(Sender: TObject);
  private
   { Private declarations }
   FProgress: TProgressbar; //TProgressbar类型的变量
   FStatusDrawRect: TRect;  //记录要插入状态条的坐标范围
   procedure AddProgressToStatus;
  public
   { Public declarations }
  end;

var
  AddProgressbarFrm: TAddProgressbarFrm;

implementation

{$R *.dfm}

procedure TAddProgressbarFrm.StatusDrawPanel(StatusBar: TStatusBar;
  Panel: TStatusPanel; const Rect: TRect);
begin
  {记录要实现状态条的坐标范围}
  FStatusDrawRect := Rect;
end;

procedure TAddProgressbarFrm.AddProgressToStatus;
var
  i,Count,StatusPanelWidth: Integer;
begin
  FProgress := TProgressbar.Create(AddProgressbarFrm);
  {定义进程条的最大值}
  Count := 3000;
  StatusPanelWidth := Status.Panels.Items[2].Width;
  {改变进度条宽度}
  Status.Panels.Items[2].Width := 150;
  Status.Repaint;
  with FProgress do
  begin
   Top := FStatusDrawRect.Top;
   Left := FStatusDrawRect.Left;
   {设定进程条的宽度和高度}
   Width := FStatusDrawRect.Right - FStatusDrawRect.Left;
   Height := FStatusDrawRect.Bottom - FStatusDrawRect.Top;
   Visible := True;
   try
    Parent := Status;
    {进程条的最小和最大值}
    Min := 0;
    Max := Count;
    Step := 1;
    for i := 1 to Count do
    Stepit;
    MessageBox(Handle,#13+'现在,进程条将要从内存中被释放'+#13+#13
         +'   [刀剑如梦软件创作室]','信息提示',MB_OK+MB_ICONINFORMATION);
   finally
    {从内存中释放进程条}
    Free;
   end;
  end;
  {恢复状态条的宽度}
  Status.Panels.Items[2].Width := StatusPanelWidth;
end;

procedure TAddProgressbarFrm.Button1Click(Sender: TObject);
begin
  AddProgressToStatus;
end;

end.

Tags:状态 显示 进度

编辑录入:爽爽 [复制链接] [打 印]
赞助商链接