By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
443,890 Members | 1,226 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 443,890 IT Pros & Developers. It's quick & easy.

How do I modify colors like Windows does to make 3D border slightly darker or lighter?

P: n/a
If you look at a standard Button in a .NET Windows Forms app, you will
notice its default BackColor is "Control" and it has a 3D raised border
which is 2 pixels wide. The outer edge on the left and top is
"ControlLightLight" color and the inner edge on the left and top is
"ControlLight". The outer edge on the right and bottom is
"ControlDarkDark" and the inner edge on the right and bottom is
"ControlDark". All of these colors are defined as KnownColors in the
System.Drawing namespace.

My question is this, when you change the BackColor of the button to
"Red", the border colors are adjusted as well. The top and left is made
slightly lighter versions of red while the bottom and right are made
slightly darker versions of red.

How can I take a given color such as Red, Green, ... and get their
slightly lighter and darker versions? There doesnt appear to be any
methods in the Color structure or ColorConverter class.

Any ideas?

Nov 16 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
I just finished doing this and it is fairly complicated if you want to handle
all the different FlatStyles...Button push styles, Border HighLights etc..

The short imperfect answer is to look at ControlPaint and the various
shades..such a Light, Dark etc..

It gets tricky when you start handling Flat and where is it Hot or
Defaulted(focused) as it doesn't use any of the control paint values that I
can find. You also have to check the brightness of the base color and if
below .5 use a different shade...

Not as easy as it looks...

I ended up using 15 shades of base colors as follows..

"jr*******@hotmail.com" wrote:
If you look at a standard Button in a .NET Windows Forms app, you will
notice its default BackColor is "Control" and it has a 3D raised border
which is 2 pixels wide. The outer edge on the left and top is
"ControlLightLight" color and the inner edge on the left and top is
"ControlLight". The outer edge on the right and bottom is
"ControlDarkDark" and the inner edge on the right and bottom is
"ControlDark". All of these colors are defined as KnownColors in the
System.Drawing namespace.

My question is this, when you change the BackColor of the button to
"Red", the border colors are adjusted as well. The top and left is made
slightly lighter versions of red while the bottom and right are made
slightly darker versions of red.

How can I take a given color such as Red, Green, ... and get their
slightly lighter and darker versions? There doesnt appear to be any
methods in the Color structure or ColorConverter class.

Any ideas?

Nov 16 '05 #2

P: n/a
AWESOME! Works perfect. Thank you.
jr*******@hotmail.com wrote:
If you look at a standard Button in a .NET Windows Forms app, you will notice its default BackColor is "Control" and it has a 3D raised border which is 2 pixels wide. The outer edge on the left and top is
"ControlLightLight" color and the inner edge on the left and top is
"ControlLight". The outer edge on the right and bottom is
"ControlDarkDark" and the inner edge on the right and bottom is
"ControlDark". All of these colors are defined as KnownColors in the
System.Drawing namespace.

My question is this, when you change the BackColor of the button to
"Red", the border colors are adjusted as well. The top and left is made slightly lighter versions of red while the bottom and right are made
slightly darker versions of red.

How can I take a given color such as Red, Green, ... and get their
slightly lighter and darker versions? There doesnt appear to be any
methods in the Color structure or ColorConverter class.

Any ideas?


Nov 16 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.