利用PB数据窗口特征制作进度条
- ·利用身份证号码提取个人信息
·在Word中制作表格 充分利用表格空间
·利用Max的Displace再现真实轮胎
·返璞归真DOS利用全接触
·PS CS3揭密:利用消失点轻松精细化
·利用CS2简单几步磨皮
·利用EXCEL进行学生成绩管理
·利用钩子技术控制进程创建(附源代码)
·也谈利用Ghost的多播功能
·充分利用Word中的域
但我们知道,数据窗口内的静态文本的字体属性是有transparent(透明)的,笔者通过研究PowerBuilder的数据窗口控件特征,摸索出一利用数据窗口等制作进度条的方法,充分解决了以上难题,还能任意改变宽度及背景、伸缩块及文字的颜色,并封装成了用户对象以方便调用。下面就介绍这一方法。
1、首先建立一数据源为Enternal(外部)、风格为Freefrom的数据窗口d_schedule_bar,输入一个字段。确定后在数据窗口画板中删除该字段,再增加两个statictext控件,这样数据窗口加上字段标识的那个一共三个statictext控件,分别命名为:st_back、st_move、st_text,调整使其宽、高度相等,设st_back的background.color为ButtonFace,st_move的background.color为Teal,st_text的background.color为transparent,st_text的color为black。表述如下:
控件名 背景色 文字色 x y 高度 宽度 St_back ButtonFace ---- 5 8 76 969 St_move Teal ---- 5 8 76 969 St_test Transparent black 5 8 76 969
保存之前选择st_move,从Edit菜单中选择Bring to Front,再选择st_text重复上述操作,使三个 statictext控件的位置层从外向里按st_text、st_move、st_back排序,以防被显示屏蔽(这一点非常重要!)。
2、新建一可视定制用户对象uo_ schedule_bar,以其中放置一数据窗口dw_1,数? 为d_schedule_bar。定义两个int实例变量 ii_percent、ii_width。
下面就开始骗程吧!
(1)编写函数uf_setwidth(integer ai_width)
参数及类型:integer ai_width
作用:改变进度条宽度:
返回值:无
函数体:
IF ai_width $#@62; 0 THENii_width = ai_width dw_1.resize (ai_width + 15,dw_1.height) dw_1.modify ( "st_back.width=" + string(ai_width) ) dw_1.modify ( "st_text.width=" + string(ai_width) )this.resize ( ai_width + 50, this.height )END IF
(2)编写函数uf_schedule_move(integer ai_schedule)
参数及类型:integer ai_schedule
作用:显示进度
返回值:无
函数体:
int li_AllWidth,li_scheduleIF ai_schedule $#@62; 100 THENai_schedule = 100ii_percent = 100END IFIF ai_schedule $#@60; 0 THENai_schedule = 0END IFii_percent = ai_scheduleli_AllWidth = integer(dw_1.describe ( "st_back.width" ))IF ai_schedule $#@62;= 0 THENli_schedule = li_AllWidth * (ai_schedule / 100)END IFdw_1.modify ( "st_move.width=" + string(li_schedule) )dw_1.modify ( "st_text.text=" + string (ai_schedule) + "%" )
(3)编写三个颜色控制函数以改变背景、伸缩条、文字的颜色。
函数名:uf_change_back_color
参数:double a_color
函数体:
dw_1.modify ( "st_back.background.color = "+string(a_color))
函数名:uf_change_move_bar_color
参数:double a_color
函数体:
dw_1.modify ( "st_move.background.color = "+string(a_color))
函数名:uf_change_text_color
参数:double a_color
函数体:
dw_1.modify ( "st_text.color = "+string(a_color))
(4)在constructor事件中输入以下代码:
dw_1.insertrow (0)this.uf_schedule_move ( 0 )ii_width = this.width
好了,一个标准的进度条用户对象就封象好了!在程序中任意地使用吧!
进入讨论组讨论。- 最新文章
- PowerBuilder应用开发系列讲座(1)[01-04]
- 在POWERBUILDER中使用WINSOCK控件的方法[01-04]
- 在PowerBuilder中动态调用函数[01-04]
- PowerBuilder应用开发系列讲座(6)[01-04]
- PowerBuilder应用开发系列讲座(20)续[01-04]
- 低级键盘钩子屏蔽Win键、Alt+Tab键的响应[01-04]
- 相关文章
