Hey, I'm trying to go check the state of over 100 check boxes. They all are named IDC_CHECK1 - IDC_CHECK121. Is there a way I can do this in a for loop, since checking each one would really suck.
Printable View
Hey, I'm trying to go check the state of over 100 check boxes. They all are named IDC_CHECK1 - IDC_CHECK121. Is there a way I can do this in a for loop, since checking each one would really suck.
if the ids are defined sequentially I don't see why not. Find out where they are defined. most likely resource.h. and see if you can't make sure they are numbered in such a way as to referenced in a for loop. Oh and by the way, that's a lot of freakin' check boxes!
Ensure your control id's are consecutive numbers (or at least regularly spaced).
egbetter still, use an enum to set the id constants:Code:#define IDC_CNTRL01 100
#define IDC_CNTRL02 101
#define IDC_CNTRL03 102
And then:Code:enum {IDC_CNTRL01=100,IDC_CNTRL02,IDC_CNTRL03};
edit: ...and FillYourBrain was way ahead of me here...but I do like to make it pretty :)Code:int i;
for (i=IDC_CNTRL01;i<IDC_CNTRL03;++i)
{
//do stuff
}
oh, ok. So in your sample code i can refer to the checkboxes with i, right?
yes - the id's of the checkboxes are available through 'i'.
BTW, ditto on that's a hell of a lot of checkboxes; perhaps looking at some other method to achieve your goal may be an idea.
lol, don't worry its just for some retarded game i started cause i was bored. Just to see how many check boxes you can click in 10 seconds.