初学GUI,通过自造函数熟悉一下各种类似语法的控件函数
本帖最后由 cashiba 于 2016-4-21 20:20 编辑#include <GUIConstantsEx.au3>
local $Form1=GUICreate("组框控件 GUI")
GUISetState(@SW_SHOW)
$Gid=CreateGrp("组框1","20-20-90-140")
Local $cbxid1=AddIntoGrp("cbx","复选框 1",$Gid,"10/-120/-20/-120")
Local $edtid2=AddIntoGrp("edt","编辑框 2",$cbxid1,"0/10/0/0")
Local $rdoid3=AddIntoGrp("rdo","单选框 3",$edtid2,"0/10/0/0")
Local $lisid4=AddIntoGrp("lis","列表框 4",$rdoid3,"0/10/0/0")
While 1
Switch GUIGetMsg()
Case $GUI_EVENT_CLOSE
ExitLoop
EndSwitch
WEnd
Func CreateGrp($title,$size);CreateGrp(组框标题,组框尺寸(以"-"分割的字符串))
local $sz=StringSplit($size,"-")
Local $Gid=GUICtrlCreateGroup($title,$sz,$sz,$sz,$sz)
GUICtrlCreateGroup("", -99, -99, 1, 1)
return $Gid
EndFunc ;==>Example
Func AddIntoGrp($Ctl,$txt,$PreCid,$incr);AddIntoGrp(控件类型,文本,参照控件ID,新控件相对参照控件的尺寸增量)
local $sz=ControlGetPos("","",$PreCid)
local $im=StringSplit($incr,"/")
local $CtlID
local $x=$sz+int($im)
local $y=$sz+$sz+int($im)
local $w=$sz+int($im)
local $h=$sz+int($im)
Switch $Ctl
case "btn"
$CtlID=GUICtrlCreateButton($txt,$x, $y,$w,$h)
case "lab"
$CtlID=GUICtrlCreateLabel($txt,$x,$y,$w,$h)
case "grp"
$CtlID=GUICtrlCreateGroup($txt,$x,$y,$w,$h)
case "rdo"
$CtlID=GUICtrlCreateRadio($txt,$x,$y,$w,$h)
case "cbx"
$CtlID=GUICtrlCreateCheckbox($txt,$x,$y,$w,$h)
case "cbo"
$CtlID=GUICtrlCreateCombo($txt,$x,$y,$w,$h)
case "edt"
$CtlID=GUICtrlCreateEdit($txt,$x,$y,$w,$h)
case "inp"
$CtlID=GUICtrlCreateInput($txt,$x,$y,$w,$h)
case "lis"
$CtlID=GUICtrlCreateList($txt,$x,$y,$w,$h)
case "lsv"
$CtlID=GUICtrlCreateListView($txt,$x,$y,$w,$h)
case "dat"
$CtlID=GUICtrlCreateDate($txt,$x,$y,$w,$h)
case "mon"
$CtlID=GUICtrlCreateMonthCal($txt,$x,$y,$w,$h)
EndSwitch
return $CtlID
EndFunc
页:
[1]