如何对一个window中的所有控件进行操作

yuxia 2001-07-20 02:44:14
如何对一个window中的所有控件进行操作
我写了一段代码实现拉大缩小window时使window中的控件随之变化,现我想把window的名字作为参数,写一个函数,传过去,使之变化,不知该如何写?
举例:
有一个window名字为w_window1,w_window1中有控件st_1,st_2,dw_1,dw_2等等,
我在window open事件中写了如此代码:
inv_resize.of_Register(st_1, "Scale")
inv_resize.of_Register(st_2, "Scale")
inv_resize.of_Register(dw_1, "Scale")
inv_resize.of_Register(dw_2, "Scale")
函数of_register的参数为控件
我想写个函数名为f_resize(),参数为window的名字或以window为参数,
然后在不知这个window中的控件的数量和类型时对所有的该window中的控件进行操作.
我已试过,如下的写法,不知为什么没起作用,这是直接在window的open事件中写的
d_jjr_dykhcx为window的名称
"
powerobject p_control
string the_class[],l,l_name
l="d_jjr_dykhcx"
int i
windowobject the_object[]
window l_window
l_window=create using l
inv_resize = create n_cst_resize
inv_resize.of_SetOrigSize (l_window.WorkSpaceWidth(), l_window.WorkSpaceHeight())
FOR i = 1 TO UpperBound(l_window.control[])
the_object[i] = l_window.control[i]
the_class[i] = the_object[i].ClassName()
p_control=create using the_class[i]
// l_name=p_control.classname()
inv_resize.of_Register(p_control, "Scale")
next
"
我最终想写成函数,请各位指正
...全文
139 15 打赏 收藏 转发到动态 举报
写回复
用AI写文章
15 条回复
切换为时间正序
请发表友善的回复…
发表回复
yuxia 2001-07-23
  • 打赏
  • 举报
回复
我是按control[]数组进行注册的,不过pfc中的 inv_resize.of_Register(the_object[i], "Scale")好像不支持windowobject这种类型
jakey_yang 2001-07-22
  • 打赏
  • 举报
回复
pb7.0有例程,看看window的方法,有一个窗口中的控件及字体的大小位置都发生变化的例子,
你看看就知道了。
咖啡 2001-07-21
  • 打赏
  • 举报
回复
上面说的都对,但是你为什么不用PFC?
lqh178 2001-07-20
  • 打赏
  • 举报
回复
这个你可以使用WindowObject类型来直接完成任务。

使用递归查找出所有的windowobject(在window,tab,userobject的control[]数组中),然后依次将它们注册即可呀。当然你在调整比例时可以直接针对windowobject类型来调整,或是调用typeof()后再做相应调整。

zls0303 2001-07-20
  • 打赏
  • 举报
回复
我来学一学
yuxia 2001-07-20
  • 打赏
  • 举报
回复
谁能告诉我呢
yanlu 2001-07-20
  • 打赏
  • 举报
回复
想弄清楚
wangsw 2001-07-20
  • 打赏
  • 举报
回复
?
shawnguo 2001-07-20
  • 打赏
  • 举报
回复
gz
yuxia 2001-07-20
  • 打赏
  • 举报
回复
我已实现了控件的放大和缩小,不过只是需要写函数inv_resize.of_Register(st_1, "Scale"),对每一个控件注册一把,我想问的是如何对window中的所有控件进行inv_resize.of_Register()函数操作
linxp 2001-07-20
  • 打赏
  • 举报
回复
////////////////////////////////////////////////////////////////////////////////////////////////////
// function: wf_resize_it
////////////////////////////////////////////////////////////////////////////////////////////////////


// loop through off of the objects captured in the wf_size_it function and resize them
// Note !! radio buttons and checkboxes do not size properly as they are of fixed size.

dragobject temp
int cnt,i

ib_exec = false // keep the function from being called recursively
this.hide()

// resize the window
this.width = (( ii_win_width - ii_win_frame_w) * size_factor) + ii_win_frame_w

this.height = (( ii_win_height - ii_win_frame_h) * size_factor) + ii_win_frame_h

// for each control in the list, resize it and it's textsize (as applicable)
cnt = upperbound(this.control)
for i = cnt to 1 step -1
temp = this.control[i]
temp.x = size_ctrl[i].x * size_factor
temp.width = size_ctrl[i].width * size_factor
temp.y = size_ctrl[i].y * size_factor
temp.height = size_ctrl[i].height * size_factor


choose case typeof(temp)
case commandbutton!
commandbutton cb
cb = temp
cb.textsize = size_ctrl[i].fontsize * size_factor

case singlelineedit!
singlelineedit sle
sle = temp
sle.textsize = size_ctrl[i].fontsize * size_factor

case editmask!
editmask em
em = temp
em.textsize = size_ctrl[i].fontsize * size_factor

case statictext!
statictext st
st = temp
st.textsize = size_ctrl[i].fontsize * size_factor

case datawindow! // datawindows get zoomed
datawindow dw
dw = temp
dw.Object.DataWindow.zoom = string(int(size_factor*100))

case picturebutton!
picturebutton pb
pb = temp
pb.textsize = size_ctrl[i].fontsize * size_factor

case checkbox!
checkbox cbx
cbx = temp
cbx.textsize = size_ctrl[i].fontsize * size_factor

case dropdownlistbox!
dropdownlistbox ddlb
ddlb = temp
ddlb.textsize = size_ctrl[i].fontsize * size_factor

case groupbox!
groupbox gb
gb = temp
gb.textsize = size_ctrl[i].fontsize * size_factor

case listbox!
listbox lb
lb = temp
lb.textsize = size_ctrl[i].fontsize * size_factor

case multilineedit!
multilineedit mle
mle = temp
mle.textsize = size_ctrl[i].fontsize * size_factor

case radiobutton!
radiobutton rb
rb = temp
rb.textsize = size_ctrl[i].fontsize * size_factor

end choose
next


this.Show()
ib_exec = true
return 1
rjcludy 2001-07-20
  • 打赏
  • 举报
回复
用树组
dragcontrol idc[]
idc[1] = dw_1
idc[2] = dw_2
....

函数中
for li_loop to upperbound(idc[]) ......
.....
不写了
weiqihp 2001-07-20
  • 打赏
  • 举报
回复
不太好控制,有一个控件号称能实现该功能,但我试了多次不行,在VB下倒可以。
zhuzhichao 2001-07-20
  • 打赏
  • 举报
回复
這個問題提得好,關注.
caolei1974 2001-07-20
  • 打赏
  • 举报
回复
不太好控制

604

社区成员

发帖
与我相关
我的任务
社区描述
PowerBuilder 控件与界面
社区管理员
  • 控件与界面社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧