|
-
Dec 4th, 2001, 05:00 PM
#1
Thread Starter
Addicted Member
Get the RGB code
Hello,
How could I get the equivalent in RGB of the COLORREF 4276545?
-
Dec 4th, 2001, 05:17 PM
#2
Frenzied Member
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.
Code:
RGB rgbval = 0;
COLORREF colorref = 4276545;
rgbval = ((colorref & 0xFF) >> 16) & (colorref & 0xFF00) & ((colorref & 0xFF0000) << 16) & (colorref & 0xFF000000);
If I remembered the format right (no guarantees), that should convert the COLORREF to an RGB.
Harry.
"From one thing, know ten thousand things."
-
Dec 4th, 2001, 05:41 PM
#3
Use GetGValue, GetRValue and GetBValue on COLORREF values to extract the colors.
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Dec 4th, 2001, 05:45 PM
#4
Thread Starter
Addicted Member
-
Dec 4th, 2001, 07:07 PM
#5
PowerPoster
Originally posted by CornedBee
Use GetGValue, GetRValue and GetBValue on COLORREF values to extract the colors.
Just curious, aren't these vb specific functions, because I don't see them in the API viewer?
-
Dec 5th, 2001, 10:06 AM
#6
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
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
-
Dec 5th, 2001, 11:15 AM
#7
Frenzied Member
Er, how did you end up at a VB site then?
Harry.
"From one thing, know ten thousand things."
-
Dec 5th, 2001, 11:25 AM
#8
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)
All the buzzt
 CornedBee
"Writing specifications is like writing a novel. Writing code is like writing poetry."
- Anonymous, published by Raymond Chen
Don't PM me with your problems, I scan most of the forums daily. If you do PM me, I will not answer your question.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|