[StructLayout(LayoutKind.Sequential)]
struct COLORREF {
public byte R;
public byte G;
public byte B;
}
Structure COLORREF
Public R As Byte
Public G As Byte
Public B As Byte
Public Overrides Function ToString() As String
Return String.Format("({0},{1},{2})", R, G, B)
End Function
End Structure
None.
Actually, there's no COLORREF structure in native Win32. It is typedef-ed to DWORD, which means that in the managed world its direct counterpart is System.Int32 (aka int in C#). So, when faced with interop involving COLORREF'S you'd better treat them as int's. Also have in mind that the color components are stored in reverse order, i.e. the Red component is in the lowest-byte. In short, the format is 0x00BBGGRR. You can use a code similar to the following to obtain a COLORREF:
private static int MakeCOLORREF(byte r, byte g, byte b)
{
return (int) (((uint)r) | ( ((uint)g) <<8 ) | ( ((uint)b) << 16 ));
}