GetDlgItem is a member of CWnd. Are you sure you're calling it from a non-static method of a class derived from CWnd?
If not, then you're calling the 2 parameter version of GetDlgItem, which takes an hwnd in addition to a control id.

Also, in this case:
Code:
CWnd *pwnd=GetDlgItem(nID);
(CButton *)pwnd->SetCheck(1);
it should be:
Code:
CWnd *pwnd=GetDlgItem(nID);
((CButton *)pwnd)->SetCheck(1);
... although that's not the problem in your case.