zoukankan      html  css  js  c++  java
  • 状态条中添加进度条

    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;

        =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即可显示进度信息

  • 相关阅读:
    南邮NOJ没有被接待的童鞋
    南邮NOJ 1014 数据的插入与删除
    Absolute C++ 2.10题目
    Absolute C++ 2.10题目
    Absolute C++ 2.10题目
    Absolute C++ 2.10题目
    南邮NOJ开灯问题
    南邮NOJ偷吃可耻
    【HDOJ】1166 敌兵布阵
    【HDOJ】1180 诡异的楼梯
  • 原文地址:https://www.cnblogs.com/huking/p/1694217.html
Copyright © 2011-2022 走看看