Jump to content
Xtreme .Net Talk

Recommended Posts

  • Leaders
Posted (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 by dynamic_sysop

  • Leaders
Posted
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.

  • *Experts*
Posted

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

"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
Posted

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.

  • *Experts*
Posted

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

"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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...