Search the Community
Showing results for tags 'top menu'.
-
If you don't want the standard drop-down menu's from the top menu bar, here's a simple way to catch user clicks there, so you end up with a top button bar instead, without defining actual buttons. No handling is provided other than item ID written to console. Took me about a full day of forum grazing to cobble it together. ; edited Helpfile example script for _GUICtrlMenu_CreateMenu #include <GUIConstantsEx.au3> #include <GuiMenu.au3> #include <WinAPIConv.au3> #include <WindowsConstants.au3> Example() Func Example() Local $hGUI, $hFile, $hEdit, $hHelp, $hMain ; Create GUI $hGUI = GUICreate("Menu", 400, 300) ; Create menu items $hFile = _GUICtrlMenu_CreateMenu() $hEdit = _GUICtrlMenu_CreateMenu() $hHelp = _GUICtrlMenu_CreateMenu() ; Create Main menu $hMain = _GUICtrlMenu_CreateMenu() _GUICtrlMenu_InsertMenuItem($hMain, 0, "&File", 0, $hFile) _GUICtrlMenu_InsertMenuItem($hMain, 1, "&Edit", 0, $hEdit) _GUICtrlMenu_InsertMenuItem($hMain, 2, "&Help", 0, $hHelp) ; Set window menu _GUICtrlMenu_SetMenu($hGUI, $hMain) ; Create memo control $g_idMemo = GUICtrlCreateEdit("", 2, 2, 396, 276, 0) GUICtrlSetFont($g_idMemo, 9, 400, 0, "Courier New") GUISetState(@SW_SHOW) ; ADDED LINES <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< GUIRegisterMsg( $WM_MENUSELECT, "WM_MENUSELECT_Events") GUIRegisterMsg( $WM_ENTERMENULOOP, "WM_ENTERMENULOOP" ) Global $hGuiHandle=WinGetHandle("","") ; get GUI handle too ; Loop until the user exits. Do Until GUIGetMsg() = $GUI_EVENT_CLOSE EndFunc ;==>Example ;========================================================================== ; ADDED Func WM_MENUSELECT_Events($hWndGUI, $MsgID, $wParam, $lParam) Static $first=False $first=Not $first ; to filter out the dummy click that resets detection Local $index = _LoWord($wParam) Local $flags = _HiWord($wParam) If $first And BitAND($flags, $MF_MOUSESELECT) Then ConsoleWrite("top menu ID: " & $index & @CRLF) Return $GUI_RUNDEFMSG EndFunc Func _HiWord($x) Return BitShift($x, 16) EndFunc Func _LoWord($x) Return BitAND($x, 0xFFFF) EndFunc Func WM_ENTERMENULOOP( $hWnd, $iMsg, $iwParam, $ilParam ) ControlClick($hGuiHandle, "", "") ; dummy click at menu item 0 to reset detection Return $GUI_RUNDEFMSG EndFunc