View Single Post
  #66  
Old 06-01-2007, 04:53 AM
Kayot
Discordant
 
Join Date: Sep 2006
Location: Subsection 185.D354 C.12
Posts: 346
Default

^-^ For Item Tint colors, I figure I should pass along what I've figured out.

The color numbers are huge, Heres why.

I don't suggest hex at all, unless you want to hex and then dehex the number. Instead use a function to break it down.

Here's what I used (Sort of, I'm retyping it from my memory)

Code:
Public Function ItemColor(ByVal Value as Long) as Color
	Dim Alfa as Byte = Value / 16777216
	Dim Red as Byte = (Value - (Byte1 * 16777216)) / 65536
	Dim Green as Byte = (Value - (Byte1 * 16777216) - (Byte2 * 65536)) / 256
	Dim Blue as Byte = (Value - (Byte1 * 16777216) - (Byte2 * 65536)) - (Byte3 *
	Color = Color.FromArgb(Alfa , Red , Green , Blue )
End Function
Then to use it in say, a Label with a right click pop-up color dialog, set it like this (I'm typing this so expect mistakes in the syntax.)

Code:
Private Sub ClickEvent(stuff that gens here) Handles label1.click
	lable1.backgroundcolor = ItemColor(reader.Getstring(#))
End Sub
reader is my SQL reader, The getstring is syntax and the # is the column it pulls the data from. You could replace it with any number that is a Long or smaller. If pulling from a TextBox, don't forget the Clng(TextBox.Text) or else it'll give you a convert error.

If you'd like, I could make a function that puts them back together, though it's easer to just make a one line multiplyer.

Code:
lngValue = lable1.backgroundcolor.color.A * 16777216 + lable1.backgroundcolor.color.R * 65536 + lable1.backgroundcolor.color.G * 256 + lable1.backgroundcolor.color.B
__________________
If at first you don't succeed destroy all evidence that you ever tried.

God doesn't give second chances... Hell, he sets you up the first time.
Reply With Quote