RGB for Control color from System.Colors

mechwarrior3

Well-known member
Joined
Dec 19, 2005
Messages
67
Programming Experience
Beginner
I am trying to create a bitmap image that will be used over a Radio Button. This image, well actually two of them, will simulate a Radio Button. There is an "unclicked" image and a "clicked" image. I'm drawing these images in Paint (the application, not the event handler) and I need the color around the circles to be the same as the color of the form. The color of the form is "Control" under the System color choices. I am trying to match that with making a custom color in Paint, however, I have no idea what the RGB components of the "Control" color are.

Does anyone know or know how I can find out?

I greatly appreciate any help. :)
 
it's 212,208,200
VB.NET:
Dim clr As Color = Me.BackColor
MsgBox(clr.R.ToString & "," & clr.G.ToString & "," & clr.B.ToString)
 
What happens if the user changes their theme? Not a problem in a highly controlled corporate environment but it would be in many other situations. If matching colours with the rest of the form is important you might be better off using GDI+ to paint the appropriate colour at run time.
 
If a user changes their theme, wouldn't all appropriate default colors change too so the problem would already be solved? Or do you mean using GDI+ would change the image to correctly match the new theme?

Quick question: How do you set it up so that an image drawn using the Paint method automatically scales the image based on the size of the control?
 
Right now, what I am doing is specifying the points of the triangle I want drawn on the control so I'm specifying the image to be a triangle drawn at specific points.
 
You can specify those points inside a graphicspath then use the setclip method of the graphicspath so the image is displayed only inside your triangle. something like...

VB.NET:
e.graphics.setclip(your graphics path)
then the draw image code as in my previous post.
 
Well, I am not drawing an image, exactly. I'm drawing a graphics object onto the control. Here is the code I'm using to draw this graphic.

VB.NET:
[SIZE=2]
[/SIZE][SIZE=2][COLOR=#0000ff]Private[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]Sub[/COLOR][/SIZE][SIZE=2] DownButton_Paint([/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] sender [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]Object[/COLOR][/SIZE][SIZE=2], [/SIZE][SIZE=2][COLOR=#0000ff]ByVal[/COLOR][/SIZE][SIZE=2] e [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] System.Windows.Forms.PaintEventArgs)
[/SIZE][SIZE=2][COLOR=#008000]' This function paints the down arrow onto the respective button
[/COLOR][/SIZE][SIZE=2][/SIZE][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] g [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] Graphics = e.Graphics
[/SIZE][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] myBrush [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]New[/COLOR][/SIZE][SIZE=2] SolidBrush(Color.Black)
[/SIZE][SIZE=2][COLOR=#0000ff]Dim[/COLOR][/SIZE][SIZE=2] myPoints(2) [/SIZE][SIZE=2][COLOR=#0000ff]As[/COLOR][/SIZE][SIZE=2] System.Drawing.Point
myPoints(0).X() = 1
myPoints(0).Y() = 10
myPoints(1).X() = 40
myPoints(1).Y() = 50
myPoints(2).X() = 78
myPoints(2).Y() = 10
g.FillPolygon(myBrush, myPoints)
[/SIZE][SIZE=2][COLOR=#0000ff]End[/COLOR][/SIZE][SIZE=2] [/SIZE][SIZE=2][COLOR=#0000ff]Sub [COLOR=black]
[/COLOR][/COLOR][/SIZE]

And, in using your code, I would need to create a bitmap or jpeg as an image and then use that, right?
 
mechwarrior3 said:
If a user changes their theme, wouldn't all appropriate default colors change too so the problem would already be solved? Or do you mean using GDI+ would change the image to correctly match the new theme?
I'm saying that if you create an image and hard-code that image into your app then if the user changes their theme your image won't match. If you use GDI+ to draw at run time then you can use the SystemColors class or just get individual colours from controls at run time.
 
Back
Top