回复 4# netegg $tabWelcome = _GUICtrlTab_Create( $guiWelcome, 1, 27, 598, 230)
;$tabWelcome = GUICtrlCreateTab( 1, 27, 598, 230) ;不能响应 $WM_NOTIFY
$itemWorkerInTabWelcome = _GUICtrlTab_InsertItem ( $tabWelcome, 0, "工作日志")
$itemSchoolInTabWelcome = _GUICtrlTab_InsertItem ( $tabWelcome, 1, "学习信息")
$itemSchool2InTabWelcome = _GUICtrlTab_InsertItem ( $tabWelcome, 2, "学习信息2")
$itemSchool3InTabWelcome = _GUICtrlTab_InsertItem ( $tabWelcome, 3, "学习信息3")
_GUICtrlTab_Create创建的标签卡控件可以在$WM_NOTIFY中获取左键、右键点击事件,但不知道如何获取其中的单个标签项目;GUICtrlCreateTab创建的标签卡不能响应$WM_NOTIFY。#include <GUIConstantsEx.au3>
#include <GuiTab.au3>
#include <TabConstants.au3>
#include <WinAPI.au3>
#include <WindowsConstants.au3>
Opt("GUIOnEventMode", 1)
Global $itemInTab
$guiWelcome = GUICreate("仿SciTE标签卡", 600, 300)
GUISetOnEvent($GUI_EVENT_CLOSE, "Func_GUI_EVENT_CLOSE")
$tabWelcome = _GUICtrlTab_Create( $guiWelcome, 1, 27, 598, 230)
;$tabWelcome = GUICtrlCreateTab( 1, 27, 598, 230) ;不能响应 $WM_NOTIFY
$itemWorkerInTabWelcome = _GUICtrlTab_InsertItem ( $tabWelcome, 0, "工作日志")
$itemSchoolInTabWelcome = _GUICtrlTab_InsertItem ( $tabWelcome, 1, "学习信息")
$itemSchool2InTabWelcome = _GUICtrlTab_InsertItem ( $tabWelcome, 2, "学习信息2")
$itemSchool3InTabWelcome = _GUICtrlTab_InsertItem ( $tabWelcome, 3, "学习信息3")
GUISetState(@SW_SHOW, $guiWelcome)
GUIRegisterMsg($WM_NOTIFY, "_WM_NOTIFY")
;-------------------------------- 分割线 -----------------------------
While 1
Sleep(200)
WEnd
Func Func_GUI_EVENT_CLOSE ()
Exit
EndFunc
Func _WM_NOTIFY($hWndGUI, $MsgID, $wParam, $lParam)
Local $tNMHDR, $hwndFrom, $code, $i_idOld, $i_idNew
Local $tNMTBHOTITEM
$tNMHDR = DllStructCreate($tagNMHDR, $lParam)
$hwndFrom = DllStructGetData($tNMHDR, "hWndFrom")
$code = DllStructGetData($tNMHDR, "Code")
Switch $hwndFrom
Case $tabWelcome
Switch $code
Case $NM_CLICK
$itemIndex = GUICtrlRead($tabWelcome, 1)
ConsoleWrite("左键了"& $itemIndex & @CRLF)
$indexItemInTab = GUICtrlRead ( $tabWelcome, 1 ) ;--------------- 无效?
ConsoleWrite("标签页索引:" & $indexItemInTab & @CRLF)
Switch $indexItemInTab
Case 0
ConsoleWrite("左击标签:00000")
Case 1
ConsoleWrite("左击标签:11111")
Case 2
ConsoleWrite("左击标签:22222")
Case 3
ConsoleWrite("左击标签:33333")
EndSwitch
Case $NM_RCLICK
$itemIndex = GUICtrlRead($tabWelcome, 1)
ConsoleWrite("右键了"& $itemIndex & @CRLF)
Switch $itemIndex
Case 0
ConsoleWrite("右击标签:00000")
Case 1
ConsoleWrite("右击标签:11111")
Case 2
ConsoleWrite("右击标签:22222")
Case 3
ConsoleWrite("右击标签:33333")
EndSwitch
EndSwitch
EndSwitch
Return $GUI_RUNDEFMSG
EndFunc
期待回复! |