Get just B as int from RGB??

Started by jcarr, September 02, 2007, 11:40:50 AM

Previous topic - Next topic

jcarr

What i am doing is opening a choosecolor() dialog then from the colour the user selects i want to just pick out the BLUE value, and convert it to a integer...

Can someone help?
This is what i have so far...:
CHOOSECOLOR cc;
COLORREF done;
cc.lStructSize = sizeof(CHOOSECOLOR);
cc.hwndOwner = hwnd;
cc.rgbResult = done;
cc.Flags = CC_SOLIDCOLOR;

ChooseColor(&cc);


Thanks in advance

~~Jden

TimoVJL

May the source be with you

jcarr

Hmmm... ok i see what you mean... Am i able to then say multiply thay number as a BYTE? or do i have to convert first to INT..??

~~Jden

frankie

Just store the result in a int variable and the compiler will automatically converti it to int.
"It is better to be hated for what you are than to be loved for what you are not." - Andre Gide

jcarr

Ok thanks ill try it and if it doesnt work, im right back here :P

~~Jden/Zyotah

jcarr

CHOOSECOLOR cc;
COLORREF done;
cc.lStructSize = sizeof(CHOOSECOLOR);
cc.hwndOwner = hwnd;
cc.rgbResult = done;
cc.Flags = CC_SOLIDCOLOR;

ChooseColor(&cc);

//BYTE b = GetBValue(done);
int b = GetBValue(done);
char f[10];
_itoa(b, f, 10);
notice(f);

That is what i put in... No matter what colour i choose, 'b' and 'f' become 0...
btw notice(char) is just a shorter messageboxa() function i made... its not thats the porb :P

~~Jden

TimoVJL

May the source be with you

jcarr

So now that that works... i have run into a problem with the CHOOSECOLOR dialog. When i hit 'Ok' it comes up with that message that it has to close, sorry for the BEEPING inconvenience.... :P
heres me code:CHOOSECOLOR cc;
cc.lStructSize = sizeof(CHOOSECOLOR);
cc.hwndOwner = hwnd;
cc.Flags = CC_SOLIDCOLOR| CC_FULLOPEN;
ChooseColor(&cc);
notice("done");


That "done" notice never appears... It errors right before that...

~~Jden

MikeH

Try adding:

static COLORREF custcolors[16];
cc.lpCustColors = custcolors;

jcarr