Re: how to change the color of the bar of MainMenu?

From: phoenix (patient0_at_skynetWORK.be)
Date: 05/28/04


Date: Fri, 28 May 2004 23:58:15 +0200

He asked for the bar of the mainmenu, that's the top level one and not the
menuitems. You can indeed draw the menuitems with a different background but
then you'll see that the rest of the bar (e.g. the part to the right of
'Help' in most cases) which doesn't contain items is still painted in the
same old color. AFAIK there really is no way to color that last part unless
you create a whole new mainmenu.

Yves

"Rhy Mednick" <rhy@rhy.com> schreef in bericht
news:e2MiTabREHA.3420@TK2MSFTNGP11.phx.gbl...
There's not a built-in way to change the background color, but if you create
an owner-drawn menu then you can draw a new background yourself. The
downside to this is that you have to manually draw the text for each of the
menu items yourself.

In addition to drawing the menu items yourself, you'll want to add the
following code to the DrawItem event of your menu item.

  private void menuItem1_DrawItem(object sender,
System.Windows.Forms.DrawItemEventArgs e)
  {
     e.Graphics.FillRectangle (new
SolidBrush(Color.Yellow),e.Bounds.Left,e.Bounds.Top,this.ClientRectangle.Wid
th,e.Bounds.Height);
  }

That'll change the background of the menu to yellow, but you could easily
replace that with any color. As an attractive alternative, you could
replace the SolidBrush object with a LinearGradientBrush and draw a
background that looks more like the Office menus. Below I've included a few
links to some resources for creating owner-drawn menus.

MSDN Magazine article on owner-drawn menus:
http://msdn.microsoft.com/msdnmag/issues/04/02/CuttingEdge/
Simple code example:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemwindowsformsmenuitemclassdrawitemtopic.asp

"Altex" <Altex@yahoo.com> wrote in message
news:uytyN8oMEHA.1272@tk2msftngp13.phx.gbl...
> Hi, how can I change the color of the bar of MainMenu?
> thanks
>
>



Relevant Pages

  • Re: how to change the color of the bar of MainMenu?
    ... When I said "menu item" I was referring to the MainMenu items. ... > He asked for the bar of the mainmenu, that's the top level one and not the ... > an owner-drawn menu then you can draw a new background yourself. ... > background that looks more like the Office menus. ...
    (microsoft.public.dotnet.framework.windowsforms.controls)
  • Re: urgently:How to use the control MSChart?
    ... I'm sorry, no, I don't really know anything about the chart control; ... Plus it's easy to draw horizontal lines. ... Here's some code that can draw a bar. ... When you display a data series in stacked bar format, ...
    (microsoft.public.vc.mfc)
  • Re: How do I draw a floating cluster Gantt Chart with VBA.
    ... Actual and Forecast Finish from the current Report Date. ... Draw Estimated bar from Estimated Start to Estimated Finish [Blue ... Draw Actual Bar from Actual Start to Current Reporting ...
    (microsoft.public.excel.charting)
  • Revisited: CF 2.0 Forms Issue
    ... The problem appears when using forms that have the WindowState property set ... standard Pocket PC title bar. ... The cause for this seems to be the missing MainMenu. ...
    (microsoft.public.dotnet.framework.compactframework)
  • Re: Hiding command bar (or menu bar)
    ... If you don't add a MainMenu to your form, then it won't display a command ... displays a command bar, then it is probably your mistake. ... Note that if you try to use the InputPanel control without a MainMenu you'll ...
    (microsoft.public.dotnet.framework.compactframework)