Question

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.

Was it helpful?

Solution

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);
   .......
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top