Integer Values for system.drawing.colors?

dynamic_sysop

Senior Contributor
Joined
Oct 1, 2002
Messages
1,039
Location
Ashby, Leicestershire.
Hi could someone tell me if it's possible to convert a system.drawing.color ( or just color ) to a numerical value ( integer ) eg: system.drawing.color.blue to it's 00100000 value
STATUS.bmp

^^^ this picture probably wont show because it's using geocities, this is a link that opens it in a new window usually ( showing an example of what i'm trying to acheive )
status bar coloured through .net you have to right click this *** and open in new window.
 
Last edited:
thanks Divil:) that returns a numeric value with a - like -1956007 etc... when i use
Visual Basic:
MsgBox(Color.Blue.ToArgb)'Numeric for colour returned in a MessageBox
, altho if i use that value to colour my statusbar it gives a different colour lol, but hey nevermind atleast it does something.
 
You should be using FromArgb(...) when setting the color of your status bar.

Are you converting to a number because you're storing something in the registry, a file, or someplace else? Otherwise you can set the color property on a control to another control's property...

Either way, you should have the exact same color. The ARGB format contains everything there is to know about a color. One value used on multiple controls should not be any different. If used on separate machines, there might be a difference (for any number of reasons).

-ner
 
there isn't a colour property for a statusbar, i can colour it with an integer in the following way...
Visual Basic:
 Private Const SB_SETBKCOLOR As Integer = 8193'this is the numeric value for setting the colour of the statusbar
Private Const SETCOLOR As Integer = 3776961'This is the actuall colour you are setting the statusbar to, the number being the colour ( eg:3776961 would return a mustard colour )
i use that in combination with the SendMessage function.
however if you send a colour value as colour.red etc or system.drawing.color.red , it wont work because it needs to be a numerical value for some reason.
 
You'll have to tweak it slightly. The .NET colors are in the format AARRGGBB, the ones that the SETCOLOR message wants is in the format 00BBGGRR. Use this format:

// The first param, 0, is the alpha - needs to be 0 for SETCOLOR messages
Color.FromArgb(0, Color.Red.B, Color.Red.G, Color.Red.R).ToArgb()

From the FromArgb method, you can see what you'd need to do to get a color converted from one format to another...

-Nerseus
 
Back
Top