SetCheck for multiple buttons or using converting strings to defines

213 Views Asked by At

I have 32 check boxes and I need to enable all of them. I can do them individually by using:

CButton* button;


button = (CButton *)GetDlgItem(IDC_CHECK1);
button->SetCheck(BST_CHECKED);
button = (CButton *)GetDlgItem(IDC_CHECK2);
button->SetCheck(BST_CHECKED);

...

Is there a way to do this for all at once or in a loop where I can increment the check number even though it is a define.

1

There are 1 best solutions below

2
On BEST ANSWER

IDC_CHECK1 and IDC_CHECK2 are defined as DWORD in resource.h file, you can define them in a sequenced number, and then use a for loop to get them:

for(int index=0;index<100;index++)
{    
  CButton* button = (CButton *)GetDlgItem(baseid+index);
   .......
}