打印本文 打印本文 关闭窗口 关闭窗口
Powerbuilder 中制作进度条
作者:武汉SEO闵涛  文章来源:敏韬网  点击数1019  更新时间:2009/4/24 21:43:00  文章录入:mintao  责任编辑:mintao
在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 b
public:
long max,min; //max,min
long pos; //pos
long 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=h
ln_1.beginx=thick
ln_1.beginy=thick
ln_1.endx=w - 2*thick
ln_1.endy=thick
ln_2.beginx=thick
ln_2.beginy=thick
ln_2.endx=thick
ln_2.endy=h - 2*thick
 
窗口Progress的Script:
long bet
bet=(max - min)/10
if min$#@62;max then
return
end if
if pos=max then
r_2.width=r_1.width
b=1
return
end if
if pos$#@62;=min and pos$#@60;max then
if pos$#@62;=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 i
uo_1.min=0
uo_1.max=10000
for i=1 to 10000
uo_1.pos=i
uo_1.triggerevent("progress")
next
其中,uo_1为进度条用户对象。

打印本文 打印本文 关闭窗口 关闭窗口