Convert COLORREF to Color

  • Thread starter Thread starter Dan Buck
  • Start date Start date
D

Dan Buck

I would like to convert the COLORREF returned by the
GetThemeColor function to a Color type using C#. I would
appreciate any guidance on the best way to accomplish
this.

Thanks,
Dan
 
Dan,
I would like to convert the COLORREF returned by the
GetThemeColor function to a Color type using C#.

System.Drawing.ColorTranslator.FromWin32(colorrefValue)



Mattias
 
Dan Buck said:
I would like to convert the COLORREF returned by the
GetThemeColor function to a Color type using C#. I would
appreciate any guidance on the best way to accomplish
this.

A color ref is a DWORD (4 bytes) in this format: 0x00bbggrr

Dim ColorRef as Integer
Dim HexColor as String
Dim NetColor as Drawing.Color = Drawing.Color.Blue

HexColor = "&H00"
HexColor += NetColor.B.ToString.PadLeft(2, "0")
HexColor += NetColor.G.ToString.PadLeft(2, "0")
HexColor += NetColor.R.ToString.PadLeft(2, "0")

ColorRef = Val(HexColor)

There is probably an easier way of doing this, but this is the first thing
that came to mind.

HTH,
Jeremy
 
Back
Top