找回密码
 加入
搜索
查看: 1979|回复: 6

[AU3基础] 代码简化

  [复制链接]
发表于 2011-2-14 17:58:17 | 显示全部楼层 |阅读模式
$box1= GUICtrlCreateCheckbox("OFFICE2007", 40, 140, 100, 20)
GUICtrlSetFont($box1,12)
$box2=GUICtrlCreateCheckbox("RTX",220,140,50,20)
GUICtrlSetFont($box2,12)
$box3=GUICtrlCreateCheckbox("FOXMAIL",330,140,70,20)
GUICtrlSetFont($box3,12)
$box4=GUICtrlCreateCheckbox("viso2007",40,180,85,20)
GUICtrlSetFont($box4,12)
$box5=GUICtrlCreateCheckbox("PS",220,180,35,20)
GUICtrlSetFont($box5,12)
$box6=GUICtrlCreateCheckbox("火狐",330,180,50,20)
GUICtrlSetFont($box6,12)
$box7=GUICtrlCreateCheckbox("遨游",40,220,50,20)
GUICtrlSetFont($box7,12)
$box8=GUICtrlCreateCheckbox("电信传真",220,220,85,20)
GUICtrlSetFont($box8,12)
$gui=GUICtrlCreateLabel("",60,280,80,30)
GUICtrlSetData($gui,_NowDate())
GUICtrlSetFont($gui,12)
$gui2=GUICtrlCreateLabel("",200,280,80,30)
GUICtrlSetFont($gui2,12)
$gui3=GUICtrlCreateLabel("",320,280,50,30)
GUICtrlSetData($gui3,$week[@WDAY-1])
GUICtrlSetFont($gui3,12)


这段修改字体的代码可以简化否?
发表于 2011-2-14 18:54:59 | 显示全部楼层
下面试试看
记得Execute可以这样用


$box1= GUICtrlCreateCheckbox("OFFICE2007", 40, 140, 100, 20)
$box2=GUICtrlCreateCheckbox("RTX",220,140,50,20)
$box3=GUICtrlCreateCheckbox("FOXMAIL",330,140,70,20)
$box4=GUICtrlCreateCheckbox("viso2007",40,180,85,20)
$box5=GUICtrlCreateCheckbox("PS",220,180,35,20)
$box6=GUICtrlCreateCheckbox("火狐",330,180,50,20)
$box7=GUICtrlCreateCheckbox("遨游",40,220,50,20)
$box8=GUICtrlCreateCheckbox("电信传真",220,220,85,20)
$gui1=GUICtrlCreateLabel("",60,280,80,30)
GUICtrlSetData($gui,_NowDate())
$gui2=GUICtrlCreateLabel("",200,280,80,30)
$gui3=GUICtrlCreateLabel("",320,280,50,30)
GUICtrlSetData($gui3,$week[@WDAY-1])
For $i=1 To 8
     Execute("GUICtrlSetFont($box" & $i & ",12)")
Next
For $i=1 To 3
     Execute("GUICtrlSetFont($gui" & $i & ",12)")
Next



Dim $Col[11]=["box1","box2","box3","box4","box5","box6","box7","box8","gui","gui2","gui3"]
$box1= GUICtrlCreateCheckbox("OFFICE2007", 40, 140, 100, 20)
$box2=GUICtrlCreateCheckbox("RTX",220,140,50,20)
$box3=GUICtrlCreateCheckbox("FOXMAIL",330,140,70,20)
$box4=GUICtrlCreateCheckbox("viso2007",40,180,85,20)
$box5=GUICtrlCreateCheckbox("PS",220,180,35,20)
$box6=GUICtrlCreateCheckbox("火狐",330,180,50,20)
$box7=GUICtrlCreateCheckbox("遨游",40,220,50,20)
$box8=GUICtrlCreateCheckbox("电信传真",220,220,85,20)
$gui=GUICtrlCreateLabel("",60,280,80,30)
GUICtrlSetData($gui,_NowDate())
$gui2=GUICtrlCreateLabel("",200,280,80,30)
$gui3=GUICtrlCreateLabel("",320,280,50,30)
GUICtrlSetData($gui3,$week[@WDAY-1])
For $i=0 To 10
     Execute("GUICtrlSetFont($" & $Col[$i] & ",12)")
Next
 楼主| 发表于 2011-2-14 19:48:30 | 显示全部楼层
$a=谢谢了,
"非常" & $a
 楼主| 发表于 2011-2-14 19:48:44 | 显示全部楼层
$a=谢谢了,
"非常" & $a
发表于 2011-2-14 20:38:19 | 显示全部楼层
支持数量较多并有一定规律的控件创建,管理.
#include <array.au3>

$gui=GUICreate("测试")
local $box_text[15]=["OFFICE2007","RTX","FOXMAIL","viso2007","PS","火狐","遨游","电信传真","OFFICE2007","RTX","FOXMAIL","viso2007","PS","火狐","遨游"]
local $box[UBound($box_text)]
local $k=0

for $n=0 to int((UBound($box)-1)/3)
        for $i=0 to 2
                if $k>UBound($box_text)-1 then ExitLoop(2)
                $box[$k]=GUICtrlCreateCheckbox($box_text[$k], 40+$i*110, 140+$n*45, 100, 20)
                $k+=1
        Next
Next

$gui1=GUICtrlCreateLabel("",60,280,80,30)
;GUICtrlSetData($gui,_NowDate())
$gui2=GUICtrlCreateLabel("",200,280,80,30)
$gui3=GUICtrlCreateLabel("",320,280,50,30)

for $i=0 to UBound($box)-1
        GUICtrlSetFont($box[$i],12)
Next

GUISetState()
;GUICtrlSetData($gui3,$week[@WDAY-1])


While 1
        $msg=GUIGetMsg()
        if $msg=-3 then Exit
WEnd
发表于 2011-2-14 22:28:56 | 显示全部楼层
本帖最后由 netegg 于 2011-2-14 22:33 编辑

GUISetFont(12)
发表于 2011-2-14 23:11:12 | 显示全部楼层
学习了。。。。
您需要登录后才可以回帖 登录 | 加入

本版积分规则

QQ|手机版|小黑屋|AUTOIT CN ( 鲁ICP备19019924号-1 )谷歌 百度

GMT+8, 2024-11-15 18:49 , Processed in 0.079237 second(s), 23 queries .

Powered by Discuz! X3.5 Licensed

© 2001-2024 Discuz! Team.

快速回复 返回顶部 返回列表