Hello,
How could I get the equivalent in RGB of the COLORREF 4276545?
Printable View
Hello,
How could I get the equivalent in RGB of the COLORREF 4276545?
As far as I remember, a COLORREF is just like an RGB value but ordered the other way.
So, assuming that in a 4-byte (32-bit) integer they are packed like this:
RGB packed as - RGBx
COLORREF packed as - BGRx
Then all you have to do is switch the red and blue components.
If I remembered the format right (no guarantees), that should convert the COLORREF to an RGB.Code:RGB rgbval = 0;
COLORREF colorref = 4276545;
rgbval = ((colorref & 0xFF) >> 16) & (colorref & 0xFF00) & ((colorref & 0xFF0000) << 16) & (colorref & 0xFF000000);
Use GetGValue, GetRValue and GetBValue on COLORREF values to extract the colors.
Thank you for the help.
Just curious, aren't these vb specific functions, because I don't see them in the API viewer?Quote:
Originally posted by CornedBee
Use GetGValue, GetRValue and GetBValue on COLORREF values to extract the colors.
they need to be VB functions because in C they are macros (so you can't get them via declare)
But since I've never programmed in VB you can be sure that everything I say is either completly wrong or it works for C :)
Er, how did you end up at a VB site then? :rolleyes:
Like many others here - searching for a way to use C dlls in VB (I coded the dll and felt responsible for making it available to the VB programmer I worked with)