tags:

views:

592

answers:

3

I need to put a control to the right of my MenuStrip. The MenuStrip fades in colour away from the BackColor on the left hand side to something whiter on the right, and ideally I would like to make my small control blend in by having the same backColor as the menustrip has on that side. Does anyone know how that colour is computed?

Worst case, can you recomment a tiny app for sampling colours off the screen?

[Update] Sampling is not a useful approach if the menustrip can be resized

A: 

I sample colours using Paint.Net: Make a screendump of the whole screen, or window, and then use Paint.Net to sample the color.

GvS
+2  A: 

The tool strip renderer draws a gradient between two colors that are defined in the ProfessionalColorTable that is passed into the ToolStripProfessionalRenderer constructor. It uses the MenuStripGradientBegin and MenuStripGradientEnd values.

So you need to recover these two values and then draw your background appropriately as a linear gradient.

Phil Wright
A: 

The background of ToolStrip ( i.e. MenuStrip, StatusStrip, etc... ) is not hard-coded. Look for "ToolStripRender" class and derived classes "ToolStripSystemRenderer" and "ToolStripProfessionalRender". They have several method for drawing parts of ToolStrip.

TcKs