• Delphi在StatusBar上绘制ProgressBar


    首先,在TForm的私有域,也就是private下设置两个变量ProgressBar、ProgressBarRect,其中ProgressBar为 TProgressBar类型,ProgressBarRect为TRect类型,完整的定义如下:

    type
      TForm1 = class(TForm)
        ......
      private
        ProgressBar: TProgressBar;
        ProgressBarRect: TRect;
      end;

    然后在StatusBar的DrawPanel事件中添加代码:

      ProgressBarRect := Rect;

    完整代码如下:

    procedure TForm1.StatusBar1DrawPanel(StatusBar: TStatusBar;
      Panel: TStatusPanel; const Rect: TRect);
    begin
      ProgressBarRect := Rect;
    end;

    最后我们用一个Button组件来测试,代码如下:

    procedure TForm1.Button1Click(Sender: TObject);
    var
      i, StepCount: integer;
    begin
      ProgressBar := TProgressBar.Create(Form1);
      StepCount := 10000;
      with ProgressBar do
      begin
        Top := ProgressBarRect.Top;
        Left := ProgressBarRect.Left;
        Width := ProgressBarRect.Right - ProgressBarRect.Left;
        Height := ProgressBarRect.Bottom - ProgressBarRect.Top;
        Visible := True;
        //Smooth := True;

        try
          Parent := StatusBar1;
          Min := 0;
          Max := StepCount;
          for i := 1 to stepCount do
          begin
            StepIt;
          end;
          MessageDlg('状态栏进度条演示操作已完成!', mtInformation, [mbOK], 0);
        finally
          Free;
        end;
      end;
    end;

  • 相关阅读:
    html抽取文本信息-java版(适合lucene建立索引)
    【LeetCode with Python】 Sort List
    POJ 2533 Longest Ordered Subsequence(dp LIS)
    Activity 之间 传递 List 封装的对象或者对象
    mongo数据库--非关系型数据库
    cocos2d-x的声音控制
    CSDN博客积分规则
    怎样使用递归实现归并排序
    android中9-patch图片的使用
    Cocos2d-x-3.0环境搭建
  • 原文地址:https://www.cnblogs.com/yzryc/p/6398396.html
Copyright © 2020-2023  润新知