private void NotifyCustomDrawMenuBar(ref Message m)
{
m.Result = (IntPtr) NativeMethods.CDRF_DODEFAULT;
NativeMethods.LPNMTBCUSTOMDRAW tbcd = (NativeMethods.LPNMTBCUSTOMDRAW) m.GetLParam(typeof(NativeMethods.LPNMTBCUSTOMDRAW));
bool hot = ((tbcd.nmcd.uItemState & NativeMethods.CDIS_HOT) != 0);
bool selected = ((tbcd.nmcd.uItemState & NativeMethods.CDIS_SELECTED) != 0);
if (hot || selected)
{
NativeMethods.RECT rect = tbcd.nmcd.rc;
using (Graphics graphics = Graphics.FromHdc(tbcd.nmcd.hdc))
{
graphics.FillRectangle(SystemBrushes.Highlight, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top);
}
using (TextGraphics textGraphics = new TextGraphics(tbcd.nmcd.hdc))
{
Font font = this.Font;
string text = this.items[tbcd.nmcd.dwItemSpec].Text;
Size size = textGraphics.MeasureText(text, font);
Point point = new Point(rect.left + ((rect.right - rect.left - size.Width) / 2), rect.top + ((rect.bottom - rect.top - size.Height) / 2));
textGraphics.DrawText(text, point, font, SystemColors.HighlightText);
}
m.Result = (IntPtr) NativeMethods.CDRF_SKIPDEFAULT;
}
}