Function Reference


_GUICtrlMenu_GetMenu

Retrieves the handle of the menu assigned to the given window

#include <GuiMenu.au3>
_GUICtrlMenu_GetMenu ( $hWnd )

Parameters

$hWnd Identifies the window whose menu handle is retrieved

Return Value

Success: the handle of the menu.
Failure: 0.

Remarks

_GUICtrlMenu_GetMenu() does not work on floating menu bars.
Floating menu bars are custom controls that mimic standard menus, but are not menus.

Related

_GUICtrlMenu_FindParent, _GUICtrlMenu_SetMenu

See Also

Search GetMenu in MSDN Library.

Example

#include <GuiMenu.au3>

Example()

Func Example()
        Local $hWnd, $hMain, $hItem1, $hItem2

        ; Open Notepad
        Run("notepad.exe")
        WinWaitActive("[CLASS:Notepad]")
        $hWnd = WinGetHandle("[CLASS:Notepad]")
        $hMain = _GUICtrlMenu_GetMenu($hWnd)

        ; Create subitem menu
        $hItem1 = _GUICtrlMenu_CreateMenu()
        _GUICtrlMenu_InsertMenuItem($hItem1, 0, "SubItem &1", 0x1000)
        _GUICtrlMenu_InsertMenuItem($hItem1, 1, "SubItem &2", 0x1001)

        ; Create menu
        $hItem2 = _GUICtrlMenu_CreateMenu()
        _GUICtrlMenu_InsertMenuItem($hItem2, 0, "Item &1", 0x2000, $hItem1)
        _GUICtrlMenu_InsertMenuItem($hItem2, 1, "Item &2", 0x2001)
        _GUICtrlMenu_InsertMenuItem($hItem2, 2, "", 0)
        _GUICtrlMenu_InsertMenuItem($hItem2, 3, "Item &3", 0x2002)
        _GUICtrlMenu_InsertMenuItem($hItem2, 4, "Item &4", 0x2003)

        ; Insert new menu into Notepad
        _GUICtrlMenu_InsertMenuItem($hMain, 6, "&AutoIt", 0, $hItem2)
        _GUICtrlMenu_DrawMenuBar($hWnd)
EndFunc   ;==>Example