NO

Author Topic: Get just B as int from RGB??  (Read 5982 times)

jcarr

  • Guest
Get just B as int from RGB??
« on: September 02, 2007, 11:40:50 AM »
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...:
Code: [Select]
CHOOSECOLOR cc;
COLORREF done;
cc.lStructSize = sizeof(CHOOSECOLOR);
cc.hwndOwner = hwnd;
cc.rgbResult = done;
cc.Flags = CC_SOLIDCOLOR;

ChooseColor(&cc);

Thanks in advance

~~Jden

Offline TimoVJL

  • Global Moderator
  • Member
  • *****
  • Posts: 2115
Re: Get just B as int from RGB??
« Reply #1 on: September 02, 2007, 12:13:20 PM »
With macro:
Code: [Select]
BYTE b = GetBValue(done);
May the source be with you

jcarr

  • Guest
Re: Get just B as int from RGB??
« Reply #2 on: September 03, 2007, 06:50:04 AM »
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

Offline frankie

  • Global Moderator
  • Member
  • *****
  • Posts: 2113
Re: Get just B as int from RGB??
« Reply #3 on: September 03, 2007, 10:20:40 AM »
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

  • Guest
Re: Get just B as int from RGB??
« Reply #4 on: September 03, 2007, 11:28:23 PM »
Ok thanks ill try it and if it doesnt work, im right back here :P

~~Jden/Zyotah

jcarr

  • Guest
Re: Get just B as int from RGB??
« Reply #5 on: September 03, 2007, 11:33:58 PM »
Code: [Select]
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

Offline TimoVJL

  • Global Moderator
  • Member
  • *****
  • Posts: 2115
Re: Get just B as int from RGB??
« Reply #6 on: September 04, 2007, 06:28:19 AM »
b = GetBValue(cc.rgbResult);
May the source be with you

jcarr

  • Guest
Re: Get just B as int from RGB??
« Reply #7 on: September 07, 2007, 03:30:06 AM »
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:
Code: [Select]
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

  • Guest
Re: Get just B as int from RGB??
« Reply #8 on: September 08, 2007, 01:47:58 AM »
Try adding:

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

jcarr

  • Guest
Re: Get just B as int from RGB??
« Reply #9 on: September 09, 2007, 11:17:00 AM »
Thanks it works now