回复 1# ahphsautoit
没有特别的要求,还是用au3内建的创建tab吧,因为大量工作都是au3帮你做了。
若用udf,则很多事都需要你自己去做,远没有用默认的那么简单了。
#include <GuiConstantsEx.au3>
#include <GuiTab.au3>
#include <WindowsConstants.au3>
Global $hGui, $hTab, $aCtrl[4]
$hGui = GUICreate("Tab UDF", 400, 300)
$hTab = _GUICtrlTab_Create($hGui, 0, 0, 640, 120)
$aCtrl[0] = GUICtrlCreateLabel ("Label", 50, 50, 100, 20)
$aCtrl[1] = GUICtrlCreateButton("Button", 60, 60, 100, 20)
$aCtrl[2] = GUICtrlCreateCombo('Combo', 70, 70, 100, 20)
$aCtrl[3] = GUICtrlCreateRadio('Radio', 80, 80, 100, 20)
For $i = 0 To 3
_GUICtrlTab_InsertItem($hTab, $i ,'Tab' & $i)
GUICtrlSetState($aCtrl[$i], $GUI_HIDE)
Next
GUISetState(@SW_SHOW, $hGui)
GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY")
Do
Until GUIGetMsg() = $GUI_EVENT_CLOSE
GUIDelete()
Func WM_NOTIFY($hWnd, $Msg, $wParam, $lParam)
Local $hWndTab, $tNMHDR, $hWndGui, $iCode, $iIndex
$hWndTab = $hTab
If Not IsHWnd($hWndTab) Then $hWndTab = GUICtrlGetHandle($hTab)
$tNMHDR = DllStructCreate($tagNMHDR, $lParam)
$hWndGui = HWnd(DllStructGetData($tNMHDR, "hWndFrom"))
$iCode = DllStructGetData($tNMHDR, "Code")
If $hWndGui == $hWndTab And $iCode == $TCN_SELCHANGE Then
$iIndex = _GUICtrlTab_GetCurSel($hTab)
For $i = 0 To UBound($aCtrl) - 1
If $iIndex == $i Then
GUICtrlSetState($aCtrl[$i], $GUI_SHOW)
Else
GUICtrlSetState($aCtrl[$i], $GUI_HIDE)
EndIf
Next
EndIf
Return $GUI_RUNDEFMSG
EndFunc
|