public static extern bool TrackPopupMenuEx(HandleRef hmenu, int fuFlags, int x, int y, HandleRef hwnd, System.Windows.Forms.NativeMethods.TPMPARAMS tpm);
private void WmNotifyDropDown(ref Message m) { System.Windows.Forms.NativeMethods.NMTOOLBAR lParam = (System.Windows.Forms.NativeMethods.NMTOOLBAR) m.GetLParam(typeof(System.Windows.Forms.NativeMethods.NMTOOLBAR)); ToolBarButton button = this.buttons[lParam.iItem]; if (button == null) { throw new InvalidOperationException(System.Windows.Forms.SR.GetString("ToolBarButtonNotFound")); } this.OnButtonDropDown(new ToolBarButtonClickEventArgs(button)); Menu dropDownMenu = button.DropDownMenu; if (dropDownMenu != null) { System.Windows.Forms.NativeMethods.RECT lparam = new System.Windows.Forms.NativeMethods.RECT(); System.Windows.Forms.NativeMethods.TPMPARAMS tpm = new System.Windows.Forms.NativeMethods.TPMPARAMS(); base.SendMessage(0x433, lParam.iItem, ref lparam); if (dropDownMenu.GetType().IsAssignableFrom(typeof(ContextMenu))) { ((ContextMenu) dropDownMenu).Show(this, new Point(lparam.left, lparam.bottom)); } else { Menu mainMenu = dropDownMenu.GetMainMenu(); if (mainMenu != null) { mainMenu.ProcessInitMenuPopup(dropDownMenu.Handle); } System.Windows.Forms.UnsafeNativeMethods.MapWindowPoints(new HandleRef(lParam.hdr, lParam.hdr.hwndFrom), System.Windows.Forms.NativeMethods.NullHandleRef, ref lparam, 2); tpm.rcExclude_left = lparam.left; tpm.rcExclude_top = lparam.top; tpm.rcExclude_right = lparam.right; tpm.rcExclude_bottom = lparam.bottom; System.Windows.Forms.SafeNativeMethods.TrackPopupMenuEx(new HandleRef(dropDownMenu, dropDownMenu.Handle), 0x40, lparam.left, lparam.bottom, new HandleRef(this, base.Handle), tpm); } } }