| 发表于:2007-11-28 16:13:271楼 得分:0 |
有些控件我已经知道如何设置了,方法如下: option explicit private initwidth as long ' form 的原始大小 private initheight as long private sub form_load() initwidth = scalewidth initheight = scaleheight dim ctl as control ' 记录每个 control 的原始位置、大小、字型大小, 放在 tag 属性中 on error resume next '确保left, top, width, height, tag属性没有全有的control for each ctl in me '也能正常执行 ctl.tag = ctl.left & " " & ctl.top & " " & ctl.width & " " & ctl.height & " " ctl.tag = ctl.tag & ctl.fontsize & " " next ctl on error goto 0 end sub private sub form_resize() dim d(4) as double dim i as long dim temppos as long dim startpos as long dim ctl as control dim tempvisible as boolean dim scalex as double dim scaley as double scalex = scalewidth / initwidth scaley = scaleheight / initheight on error resume next for each ctl in me tempvisible = ctl.visible ctl.visible = false startpos = 1 ' 读取 control 的原始位置、大小、字型大小 for i = 0 to 4 temppos = instr(startpos, ctl.tag, " ", vbtextcompare) if temppos > 0 then d(i) = mid(ctl.tag, startpos, temppos - startpos) startpos = temppos + 1 else d(i) = 0 end if ' 根据比例设定 control 的位置、大小、字型大小 ctl.move d(0) * scalex, d(1) * scaley, d(2) * scalex, d(3) * scaley 'ctl.width = d(2) * scalex 'ctl.height = d(3) * scaley if scalex < scaley then ctl.fontsize = d(4) * scalex else ctl.fontsize = d(4) * scaley end if next i ctl.visible = tempvisible next ctl on error goto 0 end sub 但在某些物件上不能使用,例如:line,因为它没有top, left width, height所以在本程式中没有作用.求助高手指点下这种控件该如何设置 | | |
|