Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
520
UltraToolbarManager PopupMenuItemUIElement Selection color
posted

I'm trying to override the color and rectangle size of the selected main menu item. However I can't tell if the mouse is over that element.

In the BeforeDrawBackColor phase of the Drawfilter on the UltraToolbarsManager:

if (drawParams.Element is PopupMenuItemUIElement)
{
   PopupMenuItemUIElement popupMenuItemUIElement = (PopupMenuItemUIElement)drawParams.Element;

   if(true)   // I'd like to replace this with a check if the mouse is over this menu item
   {
      Rectangle originalRect = popupMenuItemUIElement.DrawingRectInsideBorders;
      SolidBrush solidBrush = drawParams.CreateSolidBrush(DefaultHoverMenuBackgroundColor);
      Int32 verticalCenteringShift = (originalRect.Height - 20) / 2;
      Rectangle drawingRect = new Rectangle(originalRect.X+24, originalRect.Y + verticalCenteringShift, originalRect.Width-24, 20);
      drawParams.Graphics.FillRectangle(solidBrush, drawingRect);

      allPaintingHandled = true;
   }
}

Thanks.