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);
.......
}