473,325 Members | 2,712 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,325 software developers and data experts.

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

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
2 2397
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Yarik | last post by:
Hello, When I open an HTML document by Internet Explorer 6 and then print the document on a color inkjet printer, some of the colors are rendered incorrectly (they appear much darker than they...
3
by: Viken Karaguesian | last post by:
Hello all, Me again :>) Can I modify certain attributes in a style within a stylesheet? Example: I have a style sheet that looks like this: body { background-color: black; font-family: Arial;...
6
by: Danny Lesandrini | last post by:
I'm using an Access database to drive a web site and the colors of various table backgrounds are stored in Access. I want users of the Access database to be able to select colors for the site, but...
8
by: Todd Smith | last post by:
I'm wondering if anyone knows where I can learn a good programming method for creating windows apps. I'm just starting to learn windows programming with MSVC++ 6.0. I want to learn low level...
4
by: MC D | last post by:
I have a aspx page that outputs an image to the response.outputstream. This works great. However, I want to be able to make the image it outputs a .gif file. I can change the output type to...
3
by: jrhoads23 | last post by:
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...
3
by: Jerry Camel | last post by:
Is there a simple way to get a lighter or darker version of a color? I can convert to HSL and change the L value and then convert back. Or I can just bump the RGB values up or down by a...
4
by: Jmc | last post by:
Hi Need some advice on how to get all colors in an image. I wish to have an input file, in my case it will be a scanned piece of fabric. I would like to first of all gen an array with all the...
9
by: Adam | last post by:
I am working on the following site: http://bricktroop60.awardspace.com/ for my scout troop. It looks good in Firefox and Opera, but Internet Exploder renders the colors differently. Does anyone...
6
by: =?Utf-8?B?bGpsZXZlbmQy?= | last post by:
Is there any way to change or turn off the border of an Windows.Forms.MdiClient control? In my opinion the 3D bevel that the control uses is outdated and looks poor in my app. The best would be a...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.