Form MenuStrip Toolbar

Anti-Rich

Well-known member
Joined
Jul 1, 2006
Messages
325
Location
Perth, Australia
Programming Experience
1-3
hi guys

with my menu, i have the background set to dark grey and the font color set to white (the whole awesome contrast thing going.. :p), which i think looks pretty good. the only thing is, when i hover over clicking a button, the item is selected with the color orange, which does not work with white as a forecolor... is there anyway to change this color?

cheers all
adam
 
change the "RenderMode" property to "System"...

Edit
When you say "contrast thing" do you mean the shading of the menu bar itself? I know that setting to System gets rid of the highlighting colour, but thinks it takes the shading away as well (so you have a flat color menu...)
 
I haven't looked into this thorougly but i am going to say yes, but not as easily as setting a property. I think you will have to create your own renderer that inherits from the abstract base class ToolStripRenderer. From there to should be able to manipulate just about any kind of painting that will be performed on the toolstrip.
 
ok then, cheers for the replies guys. vis, i have never had to do anything like that before, would you be able to point me in the right direction? i have no idea how to start it, how to name the class, etc etc...

if you could help me id be greatly appreciative ...

cheers mate
adam
 
Well the every renderer for the toolstrip inherits from The Class TooStripRenderer so if you add a class to yuor project and change the inherits statement to

Inherits ToolStripRenderer

Then you will be able to set that class as the renderer for your toolstrip. Assuming microsoft haven't made it really difficult. You should find methods in there that you can override and implement your own custom painting. Best thing to start with is get a copy of reflector and have a look at the toolstriprenderer class in the framework.
 
cheers vis,

ok i have this...

VB.NET:
[SIZE=2][COLOR=#0000ff]Public[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]Class[/COLOR][/SIZE][SIZE=2] PaintMenuClass
[/SIZE][SIZE=2][COLOR=#0000ff]Inherits[/COLOR][/SIZE][SIZE=2] ToolStripRenderer
 
 
 
[/SIZE][SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]Class[/COLOR][/SIZE]
[SIZE=2][COLOR=black]
[/COLOR][/SIZE]

but now i have aboslutely no clue on where to go from here, i was having a look at the object browser, and i found a couple of methods that i think would be useful, but even if i did create them (DrawToolStripBackGround for instance), i have no idea how to use them?

sorry if i dont sound like the most intelligent person at the moment... i have never needed to actually customize a gui to this extent before.. :(

cheers
adam

 
I haven't examined that class in detail, but seeing as it is an abstract base class and every renderer for the toolstrip inherits from it there must be methods in there that you can overrides, also (and i guessing here) the overidden methds should have some kind of graphics object as a parameter. Or an eventargs parameter that contains a graphics object with which to draw.
It's a matter of playing around with to see what it does.
 
thanks for the reply again vis,

i was having a play around with it, and i also found an old post related to this thread (i searched 'toolstrip' in the search box)

in this i actually found out to draw a basic gradient, which looks pretty spiffy :)

the only problem im having now (and still the orginal one), is how do i change the color of the selected item that the mouse would be hovering over when browsing the menu.

i attached a picture of what i mean... (the blue selected item... how do i change that blue color?)

cheers for your feedback mate, its been a great help!! now that i know the basics, im already seeing ways to expand other controls... :)
 

Attachments

  • sample.JPG
    sample.JPG
    9.6 KB · Views: 40
*sigh*... the simplicity of these things tends to punch you in the face once you get the hang of it... :(

for any interested (from the msdn site, after a bit of digging around)...

VB.NET:
[SIZE=2][COLOR=#0000ff]Protected [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Overrides [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE][SIZE=2] OnRenderMenuItemBackground([/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] e [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] ToolStripItemRenderEventArgs)[/SIZE]
[SIZE=2][COLOR=#0000ff]  If[/COLOR][/SIZE][SIZE=2] e.Item.Selected [/SIZE][SIZE=2][COLOR=#0000ff]Then[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]  Dim[/COLOR][/SIZE][SIZE=2] b [/SIZE][SIZE=2][COLOR=#0000ff]As [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] Drawing2D.LinearGradientBrush(e.Item.ContentRectangle, Color.LightBlue, Color.DarkBlue, Drawing2D.LinearGradientMode.Vertical)[/SIZE]
[SIZE=2][COLOR=#0000ff]  Try[/COLOR][/SIZE]
[SIZE=2]        e.Graphics.FillRectangle(b, e.Item.ContentRectangle)[/SIZE]
[SIZE=2][COLOR=#0000ff]  Finally[/COLOR][/SIZE]
[SIZE=2]        b.Dispose()[/SIZE]
[SIZE=2][COLOR=#0000ff]  End [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Try[/COLOR][/SIZE]
 
[SIZE=2][COLOR=#0000ff]  End [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]If[/COLOR][/SIZE]
[SIZE=2][COLOR=#0000ff]End [/COLOR][/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE]

cheers for everything vis, if it wasnt for you i would have had no clue where to start. :)

regards
adam
 
Back
Top