jftuga Posted February 15, 2008 Posted February 15, 2008 (edited) Is there a way to make GUICtrlCreateTab & GUICtrlCreateTabItem handle right clicking? The functionality that I am looking for would be similar to TrayCreateMenu & TrayCreateItem. I would like to be able to right-click on a TabItem and then see a dropdown menu that I had created. Thanks, -John Edited February 15, 2008 by jftuga Admin_Popup, show computer info or launch shellRemote Manager, facilitates connecting to RDP / VNCProc_Watch, reprioritize cpu intensive processesUDF: _ini_to_dict, transforms ini file entries into variablesUDF: monitor_resolutions, returns resolutions of multiple monitorsReport Computer Problem, for your IT help deskProfile Fixer, fixes a 'missing' AD user profile
GaryFrost Posted February 15, 2008 Posted February 15, 2008 expandcollapse popup#include <GuiConstantsEx.au3> #include <GuiTab.au3> #include <GuiMenu.au3> #include <WindowsConstants.au3> Opt('MustDeclareVars', 1) $Debug_TAB = False ; Check ClassName being passed to functions, set to True and use a handle to another control to see it work Global Enum $idOpen = 1000, $idSave, $idInfo Global $hTab _Main() Func _Main() Local $tab0, $tab0input, $tab0OK, $tab1, $tab1combo, $tab1OK, $tab2, $tab2OK ; Create GUI GUICreate("Tab Control Create", 400, 300) $hTab = GUICtrlCreateTab(2, 2, 396, 296) GUISetState() GUIRegisterMsg($WM_NOTIFY, "WM_NOTIFY") $tab0 = GUICtrlCreateTabItem("tab0") GUICtrlCreateLabel("label0", 30, 80, 50, 20) $tab0OK = GUICtrlCreateButton("OK0", 20, 50, 50, 20) $tab0input = GUICtrlCreateInput("default", 80, 50, 70, 20) $tab1 = GUICtrlCreateTabItem("tab----1") GUICtrlCreateLabel("label1", 30, 80, 50, 20) $tab1combo = GUICtrlCreateCombo("", 20, 50, 60, 120) GUICtrlSetData(-1, "Trids|CyberSlug|Jon|Tylo", "Jon"); default Jon $tab1OK = GUICtrlCreateButton("OK1", 80, 50, 50, 20) $tab2 = GUICtrlCreateTabItem("tab2") GUICtrlSetState(-1, $GUI_SHOW); will be display first GUICtrlCreateLabel("label2", 30, 80, 50, 20) $tab2OK = GUICtrlCreateButton("OK2", 140, 50, 50) GUICtrlCreateTabItem(""); end tabitem definition ; Loop until user exits Do Until GUIGetMsg() = $GUI_EVENT_CLOSE GUIDelete() EndFunc ;==>_Main Func _Tab_RClick($iIndex, $hWnd) _DebugPrint("Right Clicked: " & $iIndex) Local $hMenu, $iSelected Switch $iIndex Case 0 $hMenu = _GUICtrlMenu_CreatePopup() _GUICtrlMenu_InsertMenuItem($hMenu, 0, "Open", $idOpen) _GUICtrlMenu_InsertMenuItem($hMenu, 1, "Save", $idSave) _GUICtrlMenu_InsertMenuItem($hMenu, 3, "", 0) _GUICtrlMenu_InsertMenuItem($hMenu, 3, "Info", $idInfo) $iSelected = _GUICtrlMenu_TrackPopupMenu($hMenu, $hWnd, -1, -1, 1, 1, 2) _DebugPrint("$iSelected = " & $iSelected) _GUICtrlMenu_DestroyMenu($hMenu) Case 1 Case 2 EndSwitch EndFunc ;==>_Tab_RClick Func WM_NOTIFY($hWnd, $iMsg, $iwParam, $ilParam) #forceref $hWnd, $iMsg, $iwParam Local $hWndFrom, $iIDFrom, $iCode, $tNMHDR, $hWndTab $hWndTab = $hTab If Not IsHWnd($hTab) Then $hWndTab = GUICtrlGetHandle($hTab) $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_RCLICK ; The user has clicked the right mouse button within the control _DebugPrint("$NM_RCLICK" & @LF & "--> hWndFrom:" & @TAB & $hWndFrom & @LF & _ "-->IDFrom:" & @TAB & $iIDFrom & @LF & _ "-->Code:" & @TAB & $iCode) _Tab_RClick(_GUICtrlTab_GetCurSel($hWndFrom), $hWndFrom) ;~ Return 1 ; nonzero to not allow the default processing Return 0 ; zero to allow the default processing EndSwitch EndSwitch Return $GUI_RUNDEFMSG EndFunc ;==>WM_NOTIFY Func _DebugPrint($s_text, $line = @ScriptLineNumber) ConsoleWrite( _ "!===========================================================" & @LF & _ "+======================================================" & @LF & _ "-->Line(" & StringFormat("%04d", $line) & "):" & @TAB & $s_text & @LF & _ "+======================================================" & @LF) EndFunc ;==>_DebugPrint SciTE for AutoItDirections for Submitting Standard UDFs Don't argue with an idiot; people watching may not be able to tell the difference.
jftuga Posted February 16, 2008 Author Posted February 16, 2008 Thanks Gary, this works great. I would have never been able to figure this out on my own. I really appreciate you help. -John Admin_Popup, show computer info or launch shellRemote Manager, facilitates connecting to RDP / VNCProc_Watch, reprioritize cpu intensive processesUDF: _ini_to_dict, transforms ini file entries into variablesUDF: monitor_resolutions, returns resolutions of multiple monitorsReport Computer Problem, for your IT help deskProfile Fixer, fixes a 'missing' AD user profile
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now