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); } }
internal void WmDrawItem(ref Message m) { System.Windows.Forms.NativeMethods.DRAWITEMSTRUCT lParam = (System.Windows.Forms.NativeMethods.DRAWITEMSTRUCT)m.GetLParam(typeof(System.Windows.Forms.NativeMethods.DRAWITEMSTRUCT)); IntPtr handle = Control.SetUpPalette(lParam.hDC, false, false); try { using (Graphics graphics = Graphics.FromHdcInternal(lParam.hDC)) { this.OnDrawItem(new DrawItemEventArgs(graphics, SystemInformation.MenuFont, Rectangle.FromLTRB(lParam.rcItem.left, lParam.rcItem.top, lParam.rcItem.right, lParam.rcItem.bottom), this.Index, (DrawItemState)lParam.itemState)); } } finally { if (handle != IntPtr.Zero) { System.Windows.Forms.SafeNativeMethods.SelectPalette(new HandleRef(null, lParam.hDC), new HandleRef(null, handle), 0); } } m.Result = (IntPtr)1; }