private void WmDrawItemMenuItem(ref Message m) { System.Windows.Forms.NativeMethods.DRAWITEMSTRUCT lParam = (System.Windows.Forms.NativeMethods.DRAWITEMSTRUCT)m.GetLParam(typeof(System.Windows.Forms.NativeMethods.DRAWITEMSTRUCT)); MenuItem menuItemFromItemData = MenuItem.GetMenuItemFromItemData(lParam.itemData); if (menuItemFromItemData != null) { menuItemFromItemData.WmDrawItem(ref m); } }
private void WmDrawItemMenuItem(ref Message m) { // Obtain the menu item object NativeMethods.DRAWITEMSTRUCT dis = (NativeMethods.DRAWITEMSTRUCT)m.GetLParam(typeof(NativeMethods.DRAWITEMSTRUCT)); // A pointer to the correct MenuItem is stored in the draw item // information sent with the message. // (See MenuItem.CreateMenuItemInfo) MenuItem menuItem = MenuItem.GetMenuItemFromItemData(dis.itemData); // Delegate this message to the menu item if (menuItem != null) { menuItem.WmDrawItem(ref m); } }