AppendMenu (coredll)
Last changed: esquijarosa-167.206.235.141

.
Summary
This function appends a new item to the end of the specified menu. You can use AppendMenu to specify the content, appearance, and behavior of the menu item.

C# Signature:

[DllImport("coredll.dll", SetLastError=true)]
static extern uint AppendMenu(IntPtr hMenu, uint uFlags, uint uIDNewItem, string lpNewItem);

User-Defined Types:

[uFlags]

uint MF_BYCOMMAND = 0x00000000;

uint MF_BYPOSITION = 0x00000400;

uint MF_SEPARATOR = 0x00000800;

uint MF_ENABLED = 0x00000000;

uint MF_GRAYED = 0x00000001;

uint MF_UNCHECKED = 0x00000000;

uint MF_CHECKED = 0x00000008;

uint MF_STRING = 0x00000000;

uint MF_OWNERDRAW = 0x00000100;

uint MF_POPUP = 0x00000010;

Alternative Managed API:

Do you know one? Please contribute it!

Notes:

None.

Tips & Tricks:

To add a submenu use MF_STRING in conjunction with MF_POPUP passing to the [uIDNewItem] parameter the handle to the submenu parent item as illustrated in the Sample Code section.

Sample Code:

IntPtr hMenu = CreatePopupMenu();

uint flags = MF_STRING;

AppendMenu(hMenu, flags, 1001, "Simple Menu Item");

IntPtr subMenuParentItem = CreatePopupMenu();

flags |= MF_POPUP;

AppendMenu(hMenu, flags, (uint) subMenuParentItem, "Pop-up Parent Item");

AppendMenu(subMenuParentItem, MF_STRING, 1010, "Submenu Simple Item");

Documentation
AppendMenu on MSDN