Leaders dynamic_sysop Posted March 24, 2003 Leaders Posted March 24, 2003 (edited) 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 http://www.geocities.com/sysop_guss/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. Edited March 24, 2003 by dynamic_sysop Quote
*Gurus* divil Posted March 24, 2003 *Gurus* Posted March 24, 2003 You can use the ToArgb() method of the Color class. Quote MVP, Visual Developer - .NET Now you see why evil will always triumph - because good is dumb. My free .NET Windows Forms Controls and Articles
Leaders dynamic_sysop Posted March 24, 2003 Author Leaders Posted March 24, 2003 thanks Divil:) that returns a numeric value with a - like -1956007 etc... when i use 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. Quote
*Experts* Nerseus Posted March 24, 2003 *Experts* Posted March 24, 2003 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 Quote "I want to stand as close to the edge as I can without going over. Out on the edge you see all the kinds of things you can't see from the center." - Kurt Vonnegut
Leaders dynamic_sysop Posted March 24, 2003 Author Leaders Posted March 24, 2003 there isn't a colour property for a statusbar, i can colour it with an integer in the following way... 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. Quote
*Experts* Nerseus Posted March 24, 2003 *Experts* Posted March 24, 2003 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 Quote "I want to stand as close to the edge as I can without going over. Out on the edge you see all the kinds of things you can't see from the center." - Kurt Vonnegut
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.