本帖最后由 heroxianf 于 2016-5-5 09:11 编辑
下面是我读取INI配置里的东东,然后批量设置按钮名字,主要是想练习一下数组按钮,A大提过一次,求简单举例,我再论坛里搜索出来的是批量创建按钮,而不是创建好了,在去设置名称。我想知道如何计算一个界面上批量创建和设置的边距问题如何处理的,按钮是如何创建的。
$buttonArray = IniReadSection($bIni, "Data")
$oFrme = GUICreate("数组按钮练习", 1009, 609, 164, 66)
$bGroup = GUICtrlCreateGroup("", 6, 120, 130, 470)
$Button1 = GUICtrlCreateButton($buttonArray[1][0], 20, 139, 100, 25)
$Button2 = GUICtrlCreateButton($buttonArray[2][0], 20, 176, 100, 25)
$Button3 = GUICtrlCreateButton($buttonArray[3][0], 20, 213, 100, 25)
$Button4 = GUICtrlCreateButton($buttonArray[4][0], 20, 250, 100, 25)
$Button5 = GUICtrlCreateButton($buttonArray[5][0], 20, 287, 100, 25)
$Button6 = GUICtrlCreateButton($buttonArray[6][0], 20, 324, 100, 25)
$Button7 = GUICtrlCreateButton($buttonArray[7][0], 20, 362, 100, 25)
$Button8 = GUICtrlCreateButton($buttonArray[8][0], 20, 399, 100, 25)
$Button9 = GUICtrlCreateButton($buttonArray[9][0], 20, 436, 100, 25)
$Button10 = GUICtrlCreateButton($buttonArray[10][0], 20, 473, 100, 25)
$Button11 = GUICtrlCreateButton($buttonArray[11][0], 20, 510, 100, 25)
$Button12 = GUICtrlCreateButton($buttonArray[12][0], 20, 547, 100, 25)
GUICtrlCreateGroup("", -99, -99, 1, 1)
搜索出来的结果A大的哦,没看多明白。
Local $BTXL[5], $XLlist = 1, $XLspaceX = 95, $XLspaceY = 80, $XLbjx = 170, $XLbjy = 35
$Form1 = GUICreate('Form1', 623, 442)
Local $aBtn[5][2] = [['运行notepad'],['bbb'],['c'],['d'],['退出']]
For $i = 0 To UBound($BTXL) - 1
$aBtn[$i][1] = GUICtrlCreateButton($aBtn[$i][0], $XLspaceX * Mod($i, $XLlist) + $XLbjx, $XLspaceY * Floor($i / $XLlist) + $XLbjy, 160, 35)
Next
GUISetState()
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case -3, $aBtn[4][1]
Exit
Case $aBtn[0][1]
Run('notepad.exe')
Case $aBtn[1][1] To $aBtn[3][1]
MsgBox(0, '按钮文本', GUICtrlRead($nMsg))
EndSwitch
WEnd
|