Function Reference


Retrieves the default menu item on the specified menu

#include <GuiMenu.au3>
_GUICtrlMenu_GetMenuDefaultItem ( $hMenu [, $bByPos = True [, $iFlags = 0]] )


$hMenu Handle of the menu
$bByPos [optional] Determines whether to retrive the menu items's identifer of it's position:
    True - Return menu item position
    False - Return menu item identifier
$iFlags [optional] Specifies how the function searches for menu items:
    0 - No special search parameters
    1 - Specifies that the function will return a default item even if it is disabled
    2 - Specifies that if the default item is one that opens a submenu the function is to search recursively in the corresponding submenu.

Return Value

Success: the identifier or position of the menu item.
Failure: -1.



See Also

Search GetMenuDefaultItem in MSDN Library.


#include <GuiMenu.au3>


Func Example()
    Local $hWnd, $hMain, $hFile

    ; Open Notepad
    $hWnd = WinGetHandle("[CLASS:Notepad]")
    $hMain = _GUICtrlMenu_GetMenu($hWnd)
    $hFile = _GUICtrlMenu_GetItemSubMenu($hMain, 0)

    ; Get/Set File menu default item
    Writeln("File menu default item: " & _GUICtrlMenu_GetMenuDefaultItem($hFile))
    _GUICtrlMenu_SetMenuDefaultItem($hFile, 1)
    Writeln("File menu default item: " & _GUICtrlMenu_GetMenuDefaultItem($hFile))
EndFunc   ;==>Example

; Write a line of text to Notepad
Func Writeln($sText)
    ControlSend("[CLASS:Notepad]", "", "Edit1", $sText & @CRLF)
EndFunc   ;==>Writeln