Function Reference


_GUICtrlMenu_AppendMenu

Appends a new item to the end of the specified menu bar, drop-down menu, submenu, or shortcut menu

#include <GuiMenu.au3>
_GUICtrlMenu_AppendMenu ( $hMenu, $iFlags, $iNewItem, $vNewItem )

Parameters

$hMenu Handle of the menu
$iFlags Specifies flags to control the appearance and behavior of the new menu item:
    $MF_BITMAP - Uses a bitmap as the menu item
    $MF_CHECKED - Places a check mark next to the menu item. If the application provides check-mark bitmaps, this flag displays the check-mark bitmap next to the menu item.
    $MF_DISABLED - Disables the menu item so that it cannot be selected, but the flag does not gray it.
    $MF_ENABLED - Enables the menu item so that it can be selected, and restores it from its grayed state.
    $MF_GRAYED - Disables the menu item and grays it so that it cannot be selected.
    $MF_MENUBARBREAK - Functions the same as $MF_MENUBREAK for a menu bar. For a drop down menu, submenu, or shortcut menu, the new column is separated from the old column by a vertical line.
    $MF_MENUBREAK - Places the item on a new line (for a menu bar) or in a new column (for a drop down menu, submenu, or shortcut menu) without separating columns.
    $MF_OWNERDRAW - Specifies that the item is an owner drawn item.
        Before the menu is displayed for the first time, the window that owns the menu receives a $WM_MEASUREITEM message to retrieve the width and height of the menu item.
        The $WM_DRAWITEM message is then sent to the window procedure of the owner window whenever the appearance of the menu item must be updated.
    $MF_POPUP - Specifies that the menu item opens a drop down menu or submenu.
        The $iNewItem parameter specifies a handle to the drop down menu or submenu.
        This flag is used to add a menu name to a menu bar, or a menu item that opens a submenu to a drop down menu, submenu, or shortcut menu.
    $MF_SEPARATOR - Draws a horizontal dividing line. This flag is used only in a drop down menu, submenu, or shortcut menu.
        The line cannot be grayed, disabled, or highlighted. The $vNewItem and $iNewItem parameters are ignored.
    $MF_STRING - Specifies that the menu item is a text string. The $vNewItem parameter is a string.
    $MF_UNCHECKED - Does not place a check mark next to the item. If the application supplies check mark bitmaps, this flag displays the clear bitmap next to the menu item.
$iNewItem Specifies either the identifier of the new menu item or, if the $iFlags parameter is set to a popup, a handle to the drop down menu or submenu.
$vNewItem Specifies the content of the new menu item. The interpretation of $vNewItem depends on whether the $iFlags parameter includes the $MF_BITMAP, $MF_OWNERDRAW, or $MF_STRING flag:
    $MF_BITMAP - Contains a bitmap handle
    $MF_OWNERDRAW - Contains an application supplied value that can be used to maintain additional data related to the menu item.
        The value is in the ItemData member of the structure pointed to by the lParam parameter of the $WM_MEASUREITEM or $WM_DRAWITEM message sent when the menu is created or its appearance is updated.
    $MF_STRING - Contains a string

Return Value

Success: True.
Failure: False.

Related

_GUICtrlMenu_InsertMenuItem

See Also

Search AppendMenu in MSDN Library.

Example

#include <GUIConstantsEx.au3>
#include <GuiMenu.au3>

Example()

Func Example()
        Local $hGUI, $hFile, $hEdit, $hHelp, $hMain
        Local Enum $e_idNew = 1000, $e_idOpen, $e_idSave, $e_idExit, $e_idCut, $e_idCopy, $e_idPaste, $e_idAbout

        ; Create GUI
        $hGUI = GUICreate("Menu", 400, 300)

        ; Create File menu
        $hFile = _GUICtrlMenu_CreateMenu()
        _GUICtrlMenu_InsertMenuItem($hFile, 0, "&New", $e_idNew)
        _GUICtrlMenu_InsertMenuItem($hFile, 1, "&Open", $e_idOpen)
        _GUICtrlMenu_InsertMenuItem($hFile, 2, "&Save", $e_idSave)
        _GUICtrlMenu_InsertMenuItem($hFile, 3, "", 0)
        _GUICtrlMenu_InsertMenuItem($hFile, 4, "E&xit", $e_idExit)

        ; Create Edit menu
        $hEdit = _GUICtrlMenu_CreateMenu()
        _GUICtrlMenu_InsertMenuItem($hEdit, 0, "&Cut", $e_idCut)
        _GUICtrlMenu_InsertMenuItem($hEdit, 1, "C&opy", $e_idCopy)
        _GUICtrlMenu_InsertMenuItem($hEdit, 2, "&Paste", $e_idPaste)

        ; Create Help menu
        $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)
        GUISetState(@SW_SHOW)

        ; Add About menu item
        _GUICtrlMenu_AppendMenu($hHelp, $MF_STRING, $e_idAbout, "&About")

        ; Loop until the user exits.
        Do
        Until GUIGetMsg() = $GUI_EVENT_CLOSE
EndFunc   ;==>Example