delphi 实现程序放放多个进程条


本文整理自网络,侵删。

 delphi 实现程序放放多个进程条

很不错的一个 方法,可以同时实现两个同时进行 ! 呵呵 看代码

Delphi 中TStatusbar上通常不允许放其它组件。但是经常有需求要在右下角的状态栏上放置进程条以达到更好的显示效果,下面介绍如何将多个进程条组件添加到一个状态栏 TStatusbar上,以及如何适应状态栏的大小来调整进程条的大小。

//状态栏可以自定义为多个panel,我们首先要取得放进程条在那个panel的尺寸大小
//以下函数需要引用 单元 commctrl
//第二个参数中 0是取得状态栏第一个panel 依次 1为取得第二个panel
Statusbar1.Perform(SB_GETRECT, 0, Integer(@R));
Statusbar1.Perform(SB_GETRECT, 2, Integer(@R2));
//我们设定在状态栏放两个进程条,分别放在第一个与第三个panel中,当然状态栏你要先设好为三个

//设置进程控件的parent为状态栏,即可将进程条放在状态栏上
progressbar1.Parent := Statusbar1;
progressbar2.Parent := Statusbar1;

//设置第一个进程条在状态栏第一个panel的位置
progressbar1.Top := r.Top; //set size of
progressbar1.Left := r.Left; //Progressbar to
progressbar1.Width := r.Right ?C r.Left; //fit with panel
progressbar1.Height := r.Bottom ?C r.Top;

//设置第二个进程条在状态栏第三个个panel的位置
progressbar2.Top := r2.Top; //set size of
progressbar2.Left := r2.Left; //Progressbar to
progressbar2.Width := r2.Right ?C r2.Left; //fit with panel
progressbar2.Height := r2.Bottom ?C r2.Top;
//以上我们设定进程条充满各自的panel,当然你可以设定进程条的top,left等属性来调整显示位置

unit Unit1;

interface

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

type
TForm1 = class(TForm)
StatusBar1: TStatusBar;
ProgressBar1: TProgressBar;
ProgressBar2: TProgressBar;
Button1: TButton;
procedure FormShow(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

{$R *.dfm}

procedure TForm1.FormShow(Sender: TObject);
var
r,r2: TRect;
begin
//状态栏可以自定义为多个panel,我们首先要取得放进程条在那个panel的尺寸大小
//以下函数需要引用 单元 commctrl
//第二个参数中 0是取得状态栏第一个panel 依次 1为取得第二个panel
Statusbar1.Perform(SB_GETRECT, 0, Integer(@R));
Statusbar1.Perform(SB_GETRECT, 2, Integer(@R2));
//我们设定在状态栏放两个进程条,分别放在第一个与第三个panel中,当然状态栏你要先设好为三个

//设置进程控件的parent为状态栏,即可将进程条放在状态栏上
progressbar1.Parent := Statusbar1;
progressbar2.Parent := Statusbar1;

//设置第一个进程条在状态栏第一个panel的位置
progressbar1.Top := r.Top; //set size of
progressbar1.Left := r.Left; //Progressbar to
progressbar1.Width := r.Right - r.Left; //fit with panel
progressbar1.Height := r.Bottom - r.Top;

//设置第二个进程条在状态栏第三个个panel的位置
progressbar2.Top := r2.Top; //set size of
progressbar2.Left := r2.Left; //Progressbar to
progressbar2.Width := r2.Right - r2.Left; //fit with panel
progressbar2.Height := r2.Bottom - r2.Top;
//以上我们设定进程条充满各自的panel,当然你可以设定进程条的top,left等属性来调整显示位置
end;
procedure TForm1.Button1Click(Sender: TObject);
var
i:integer;
begin
for i:=0 to 100 do
begin
Sleep(100);
ProgressBar1.Position:=i;
ProgressBar2.Position:=i;
end;
end;

end.

相关阅读 >>

Delphi命令行窗口实现9*9乘法表

Delphi 取出一个字符在字符串出现的次数

Delphi隐藏系统托盘tray图标

Delphi防止同时出现多个应用程序实例

Delphi setformfullscreen()窗体全屏显示

tsqlconnection连接mysql(utf8)的问题

Delphi tlistview(tlistbox+图标显示)

Delphi使用indy组件http上传文件

Delphi 绘制精美的签名图片

Delphi 创建新的messagebox窗口前,先关掉之前已经创建好的

更多相关阅读请进入《Delphi》频道 >>



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...