[DllImport("user32.dll", SetLastError=true)]
static extern uint TrackPopupMenuEx(IntPtr hMenu, uint uFlags, int x, int y, IntPtr hWnd, IntPtr tpmParams);
uFlags:
uint TPM_LEFTALIGN = 0x0000;
uint TPM_CENTERALIGN = 0x0004;
uint TPM_RIGHTALIGN = 0x0008;
uint TPM_TOPALIGN = 0x0000;
uint TPM_VCENTERALIGN = 0x0010;
uint TPM_BOTTOMALIGN = 0x0020;
uint TPM_HORIZONTAL = 0x0000;
uint TPM_VERTICAL = 0x0040;
uint TPM_RETURNCMD = 0x0100;
Do you know one? Please contribute it!
Use TrackPopupMenuEx with the TPM_RETURNCMD flag to return the ID of the selected Menu Item.
MessageWindow eventSink = new MessageWindow();
IntPtr hMenu = CreatePopUpMenu();
// Add some items...
AppendMenu(hMenu, MF_STRING, 1001, "Item 1");
// Display a Pop Up menu at the bottom right corner of the working area of the screen
// growing from bottom to top
uint menuItemID = TrackPopupMenuEx(hMenu, TPM_BOTTOMALIGN | TPM_RETURNCMD, Screen.PrimaryScreen.WorkingArea.Width, Screen.PrimaryScreen.WorkingArea.Height, eventSink.Hwnd, IntPtr.Zero);
// Use the menuItemID to fire some event...