473,657 Members | 2,287 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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
"ControlLightLi ght" color and the inner edge on the left and top is
"ControlLig ht". The outer edge on the right and bottom is
"ControlDarkDar k" and the inner edge on the right and bottom is
"ControlDar k". 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 2423
I just finished doing this and it is fairly complicated if you want to handle
all the different FlatStyles...Bu tton 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(focus ed) 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*******@hotm ail.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
"ControlLightLi ght" color and the inner edge on the left and top is
"ControlLig ht". The outer edge on the right and bottom is
"ControlDarkDar k" and the inner edge on the right and bottom is
"ControlDar k". 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*******@hotma il.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
"ControlLightLi ght" color and the inner edge on the left and top is
"ControlLig ht". The outer edge on the right and bottom is
"ControlDarkDar k" and the inner edge on the right and bottom is
"ControlDar k". 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
1876
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 should be, almost black). The exact version of IE is 6.0.2800.1106 (with all patches applied). The printer is Canon S330. Examples of "suffering" colors are: "green", "teal", "purple" (and the general impression is that anything near the
3
5248
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; font-size: 13pt; color: white; margin: 5 5 5 5 } p { font-family: Arial; font-size: 13pt; color: white; line-height: 125%; margin-top: 5px; margin-bottom: 5px}
6
6147
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 my mappings between named colors, HEX values and the Long Integer values used in Access are not jibbing. Anyone have a nice list laying around? Danny J Lesandrini dlesandrini@hotmail.com
8
2381
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 windows programming in C first. I don't want to learn any bad habits by hacking away at code until I get something to work. Specifically, I'd like to learn how to set up and plan out a C windows project and break it down into pieces of code that will...
4
3724
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 "image/gif" and save the image by doing: myBitmap.Save(response.outputstream,ImageFormat.Gif) and this works, BUT it uses a horrible halftone palette to reduce the colors. I have been trying for a day and a half to figure out any way to reduce the...
3
420
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 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...
3
2547
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 predetermined amount. Any advice on the best way? Thanks. Jerry
4
3942
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 colors represented in the image. and an percentage of how much the color exists. Lets assume that the color of the fabric is blue, it will probably have pixels that are not #0000FF since the diferent threads in the fabric
9
1260
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 know why this happens and if so, can you explain why and how to fix it in simple terms (I am new at this)? Another question - The xhtml validation link has a border around it in FF and IE, but not Opera. Any ideas on why this happens and how to...
6
7843
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 single line border that custom draw so I can control the color of the border. Thanks for any help! Lance
0
8319
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8837
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
8512
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8612
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7347
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6175
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4329
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
1969
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1732
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.