本帖最后由 水木子 于 2016-11-23 11:42 编辑
善用搜索功能吧!
http://www.autoitx.com/forum.php ... amp;fromuid=7644217
#include <GuiTab.au3>
#include 'GUIScrollbars_Ex.au3'
$hGui1 = GUICreate('标签页控件 GUI', 800, 400)
GUISetFont(9)
$Tab = GUICtrlCreateTab(10, 10, 780, 380)
$hTab = GUICtrlGetHandle($Tab)
_GUICtrlTab_SetMinTabWidth($Tab, 80)
$TabItem1 = GUICtrlCreateTabItem('第一页')
$Button1_1 = GUICtrlCreateButton('测试按钮1-1', 420, 350, 85, 25)
$TabItem2 = GUICtrlCreateTabItem('第二页')
$Button2_1 = GUICtrlCreateButton('测试按钮2-1', 420, 350, 85, 25)
$Button2_2 = GUICtrlCreateButton('测试按钮2-2', 550, 350, 85, 25)
$TabItem3 = GUICtrlCreateTabItem('第三页')
$Button3_1 = GUICtrlCreateButton('测试按钮3-1', 420, 350, 85, 25)
$Button3_2 = GUICtrlCreateButton('测试按钮3-2', 550, 350, 85, 25)
$Button3_3 = GUICtrlCreateButton('测试按钮3-3', 680, 350, 85, 25)
GUICtrlCreateTabItem('')
Global $aCtrlCount1[20]
Global $iNumber = 4
Global $iSpacingX = 200, $iSpacingY = 50
$hGui2 = GUICreate('', 760, 300, 11, 31, $WS_CHILD, -1, $hTab)
GUISetBkColor(0xFFFFFF, $hGui2)
For $i = 0 To UBound($aCtrlCount1) - 1
$aCtrlCount1[$i] = GUICtrlCreateCheckbox('复选框 1 - ' & $i + 1, $iSpacingX * Mod($i, $iNumber) + 30, $iSpacingY * Floor($i / $iNumber) + 40, 100, 20)
Next
GUICtrlCreateGroup('组框 1 - 1', 10, 10, 740, UBound($aCtrlCount1) * 12.5 + 40)
If UBound($aCtrlCount1) > 20 Then _GUIScrollbars_Generate($hGui2, 0, UBound($aCtrlCount1) * 12.5 + 40, 0, 0, True)
Global $aCtrlCount2[50]
$hGui3 = GUICreate('', 760, 300, 11, 31, $WS_CHILD, -1, $hTab)
GUISetBkColor(0xFFFFFF, $hGui3)
For $i = 0 To UBound($aCtrlCount2) - 1
$aCtrlCount2[$i] = GUICtrlCreateCheckbox('复选框 2 - ' & $i + 1, $iSpacingX * Mod($i, $iNumber) + 30, $iSpacingY * Floor($i / $iNumber) + 40, 100, 20)
Next
GUICtrlCreateGroup('组框 2 - 1', 10, 10, 740, UBound($aCtrlCount2) * 12.5 + 40)
If UBound($aCtrlCount2) > 20 Then _GUIScrollbars_Generate($hGui3, 0, UBound($aCtrlCount2) * 12.5 + 40, 0, 0, True)
Global $aCtrlCount3[100]
$hGui4 = GUICreate('', 760, 300, 11, 31, $WS_CHILD, -1, $hTab)
GUISetBkColor(0xFFFFFF, $hGui4)
For $i = 0 To UBound($aCtrlCount3) - 1
$aCtrlCount3[$i] = GUICtrlCreateCheckbox('复选框 3 - ' & $i + 1, $iSpacingX * Mod($i, $iNumber) + 30, $iSpacingY * Floor($i / $iNumber) + 40, 100, 20)
Next
GUICtrlCreateGroup('组框 3 - 1', 10, 10, 740, UBound($aCtrlCount3) * 12.5 + 40)
If UBound($aCtrlCount3) > 20 Then _GUIScrollbars_Generate($hGui4, 0, UBound($aCtrlCount3) * 12.5 + 40, 0, 0, True)
GUISetState(@SW_SHOW, $hGui2)
GUISetState(@SW_SHOW, $hGui1)
GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")
While 1
$nMsg = GUIGetMsg()
Switch $nMsg
Case -3
Exit
Case $Button1_1
MsgBox(0, 0, 'Test')
EndSwitch
WEnd
Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam)
Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndTab
$hWndTab = GUICtrlGetHandle($Tab)
$tNMHDR = DllStructCreate($tagNMHDR, $ilParam)
$hWndFrom = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
$iIDFrom = DllStructGetData($tNMHDR, "IDFrom")
$iCode = DllStructGetData($tNMHDR, "Code")
Switch $hWndFrom
Case $hWndTab
Switch $iCode
Case $NM_CLICK
$iTabItemIndex = _GUICtrlTab_GetCurFocus($hWndTab)
Switch $iTabItemIndex
Case 0
GUISetState(@SW_HIDE, $hGui3)
GUISetState(@SW_HIDE, $hGui4)
GUISetState(@SW_SHOW, $hGui2)
Case 1
GUISetState(@SW_HIDE, $hGui2)
GUISetState(@SW_HIDE, $hGui4)
GUISetState(@SW_SHOW, $hGui3)
Case 2
GUISetState(@SW_HIDE, $hGui2)
GUISetState(@SW_HIDE, $hGui3)
GUISetState(@SW_SHOW, $hGui4)
EndSwitch
EndSwitch
EndSwitch
Return $GUI_RUNDEFMSG
EndFunc ;==>WM_NOTIFY
|