程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> 更多編程語言 >> Delphi >> 狀態欄顯示進度條

狀態欄顯示進度條

編輯:Delphi
{*******************************************************}
  {                                                                                                }
  {                      Delphi ESite : http://yckxzjj.vip.sina.com                 }
  {                      KingLong Studio:刀劍如夢軟件創作室                  }
  {                  QQ:20775028  E-Mail : [email protected]          }
  {                 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;

  

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved