在VB和Delphi等语言中都提供了“进度条”控件,PB中没有现成的控件提供,但我们可以做一个“进度条”的用户定义对象(user object),象控件一样在程序中调用。具体方法如下:新建一个用户对象UO_PROGRESSBAR,加上两个长方形(rectangle)控件r_1和r_2,同时加上两条线(line)控件ln_1和ln_2。线用于增加r_1的立体效果,r_2颜色为兰色,用于显示进度。R_1属性为:
X=5
y=4
width=1408
height=64
Visible=true
LineColor=33554431
FillColor=33554431
FillPattern=solid!
LineStyle=continuous!
LineThickness=12
R_2属性为:
X=5
y=4
width=41
height=60
Visible=true
LineColor=16777215
FillColor=16711680
FillPattern=vertical!
LineStyle=continuous!
LineThickness=12
先定义窗口的实例变量(Instance Variables):
private:int thick; //进度条与外框的距离
int bpublic:long max,min; //max,min
long pos; //poslong color;
窗口Constructor的Script:
long w,h
thick=5
b=1
w=this.width
h=this.height
r_1.x=thick
r_1.y=thick
r_2.x=thick
r_2.y=thick
r_1.width=w
r_1.height=h
r_2.height=hln_1.begin
x=thickln_1.begin
y=thickln_1.end
x=w - 2*thickl n_1.end
y=thickln_2.begin
x=thickln_2.begin
y=thickln_2.end
x=thickln_2.end
y=h - 2*thick
窗口Progress的Script:
long bet
bet=(max - min)/10
if min>max then
return
end if
if pos=max then
r_2.width=r_1.width
b=1return
end if
if pos>=min and pos<max
then
if pos>=b*bet then
r_2.resize(r_1.width*(abs((pos - min)/(max - min))),r_2.height)
b=b+1
end if
end if
以上便完成了用户对象,以后只需调用即可,比如:
int iuo_1.min=0
uo_1.max=10000
for i=1 to 10000
uo_1.pos=iuo_1.triggerevent("progress")
next
其中,uo_1为进度条用户对象。
X=5
y=4
width=1408
height=64
Visible=true
LineColor=33554431
FillColor=33554431
FillPattern=solid!
LineStyle=continuous!
LineThickness=12
R_2属性为:
X=5
y=4
width=41
height=60
Visible=true
LineColor=16777215
FillColor=16711680
FillPattern=vertical!
LineStyle=continuous!
LineThickness=12
先定义窗口的实例变量(Instance Variables):
private:int thick; //进度条与外框的距离
int bpublic:long max,min; //max,min
long pos; //poslong color;
窗口Constructor的Script:
long w,h
thick=5
b=1
w=this.width
h=this.height
r_1.x=thick
r_1.y=thick
r_2.x=thick
r_2.y=thick
r_1.width=w
r_1.height=h
r_2.height=hln_1.begin
x=thickln_1.begin
y=thickln_1.end
x=w - 2*thickl n_1.end
y=thickln_2.begin
x=thickln_2.begin
y=thickln_2.end
x=thickln_2.end
y=h - 2*thick
窗口Progress的Script:
long bet
bet=(max - min)/10
if min>max then
return
end if
if pos=max then
r_2.width=r_1.width
b=1return
end if
if pos>=min and pos<max
then
if pos>=b*bet then
r_2.resize(r_1.width*(abs((pos - min)/(max - min))),r_2.height)
b=b+1
end if
end if
以上便完成了用户对象,以后只需调用即可,比如:
int iuo_1.min=0
uo_1.max=10000
for i=1 to 10000
uo_1.pos=iuo_1.triggerevent("progress")
next
其中,uo_1为进度条用户对象。