colorref
-
upon the following tutorials http://codeproject.com/miscctrl/#Colour+Selection+Controls[^] and especially http://codeproject.com/miscctrl/colour_picker.asp[^] and http://codeproject.com/miscctrl/colourpickerxp.asp[^] I could successfully use te classes, but I want to ask, upon these two articles, is the any way to get the value of the COLORREF and disploay it in a MessageBox or in an editbox using SetWindowText() thanks in advance...
-
upon the following tutorials http://codeproject.com/miscctrl/#Colour+Selection+Controls[^] and especially http://codeproject.com/miscctrl/colour_picker.asp[^] and http://codeproject.com/miscctrl/colourpickerxp.asp[^] I could successfully use te classes, but I want to ask, upon these two articles, is the any way to get the value of the COLORREF and disploay it in a MessageBox or in an editbox using SetWindowText() thanks in advance...
From MSDN:
When specifying an explicit RGB color, the COLORREF value has the following hexadecimal form:
0x00bbggrr
The low-order byte contains a value for the relative intensity of red; the second byte contains a value for green;
and the third byte contains a value for blue. The high-order byte must be zero. The maximum value for a single byte is 0xFF.So just use masks to retrieve the colors:
COLORREF Color = ....; int BlueValue = Color&0x00FF0000; int GreenValue = Color&0x0000FF00; int RedValue = Color&0x000000FF;
-
From MSDN:
When specifying an explicit RGB color, the COLORREF value has the following hexadecimal form:
0x00bbggrr
The low-order byte contains a value for the relative intensity of red; the second byte contains a value for green;
and the third byte contains a value for blue. The high-order byte must be zero. The maximum value for a single byte is 0xFF.So just use masks to retrieve the colors:
COLORREF Color = ....; int BlueValue = Color&0x00FF0000; int GreenValue = Color&0x0000FF00; int RedValue = Color&0x000000FF;
or use the
GetRValue
,GetGValue
,GetBValue
functions.
Maximilien Lincourt Your Head A Splode - Strong Bad
-
or use the
GetRValue
,GetGValue
,GetBValue
functions.
Maximilien Lincourt Your Head A Splode - Strong Bad
True, because I just realized my version was completely bugged :~ . It works well for the red component but for this other ones, the bits needs to be shifted...
-
or use the
GetRValue
,GetGValue
,GetBValue
functions.
Maximilien Lincourt Your Head A Splode - Strong Bad
-
oki, but how can I use the GetRValue, GetGValue, GetBValue functions to display the colorref value in a messagebox or an editbox? an example code? thanks alot
Just use printf:
char szText[255]; printf(szText,"Red value: %i, Blue value: %i, Green value: %i",GetRValue(...),GetBValue(...),GetGValue(...));
Of course, you have to replace the...
by your COLORREF variable ;) -
True, because I just realized my version was completely bugged :~ . It works well for the red component but for this other ones, the bits needs to be shifted...
Cedric Moonen wrote:
True, because I just realized my version was completely bugged
yeah, you forgot the shifts...
int BlueValue = Color&0x00FF0000 >> 16;
int GreenValue = Color&0x0000FF00 >> 8;
int RedValue = Color&0x000000FF;;)
TOXCCT >>> GEII power
[toxcct][VisualCalc 2.20] -
Just use printf:
char szText[255]; printf(szText,"Red value: %i, Blue value: %i, Green value: %i",GetRValue(...),GetBValue(...),GetGValue(...));
Of course, you have to replace the...
by your COLORREF variable ;)yes I got it, but how can I use it with the following classes http://codeproject.com/miscctrl/colour_picker.asp[^] and http://codeproject.com/miscctrl/colourpickerxp.asp[^] I mean, I want the color value of the chosen color from the drop button. thanks alot
-
yes I got it, but how can I use it with the following classes http://codeproject.com/miscctrl/colour_picker.asp[^] and http://codeproject.com/miscctrl/colourpickerxp.asp[^] I mean, I want the color value of the chosen color from the drop button. thanks alot
For the first one, just use
COLORREF GetColour();
from the control. Dude, when you use classes from an article here, first read how to use it (and there is also example source code with the article). If we don't use this control, we don't know how to use. It just took me 30 seconds looking at the text of the article to find how to use it. -
For the first one, just use
COLORREF GetColour();
from the control. Dude, when you use classes from an article here, first read how to use it (and there is also example source code with the article). If we don't use this control, we don't know how to use. It just took me 30 seconds looking at the text of the article to find how to use it.