-
October 30th, 2005, 09:14 PM
#1
About the useness of SetCheck
Hello everyone :
I am doing one application for the SetCheck(); and found one problem occured , that is :
Sometimes I used ((CButton *)GetDlgItem(nID))->SetCheck(1) , that can work successfully and no any erro , but sometimes I use the sme one at somewhere, then get erro as below :
error C2660:'GetDlgItem' : function does not take 1 parameters
error C2227: left of '->SetCheck' must point to class/struct/union
I also try to use :
CWnd *pwnd=GetDlgItem(nID);
(CButton *)pwnd->SetCheck(1);
also get erro :
error C2660: 'GetDlgItem' : function does not take 1 parameters
error C2039: 'SetCheck' : is not a member of 'CWnd'
e:\Visual Studio\VC98\MFC\INCLUDE\afxwin.h(1899) : see declaration of 'CWnd'
I am in doubt now , and Could anyone give me any idea ?
Thanks in advance !
-
October 30th, 2005, 10:11 PM
#2
Re: About the useness of SetCheck
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.
-
October 30th, 2005, 10:37 PM
#3
Re: About the useness of SetCheck
Sorry for my stupid inattention , but if
CWnd *pwnd=GetDlgItem(nID);
((CButton *)pwnd)->SetCheck(1);
then
error C2660: 'GetDlgItem' : function does not take 1 parameters
How to settle this case ?
pls. advise !
Thx in advance !
-
October 30th, 2005, 11:43 PM
#4
Re: About the useness of SetCheck
Mr torfil has already narrated the cause of the error you are getting. You may be calling the function from some classes which are not drived from CWindow or CWnd or any of the classes derived from these.
at these places you can call the function as follows.
HWND GetDlgItem(
HWND hDlg, // handle to dialog box
int nIDDlgItem // control identifier
);
you can get its help from MSDN.
Do rate this post if it find useful to you
-
October 31st, 2005, 12:13 AM
#5
Re: About the useness of SetCheck
Originally Posted by Vinod S
Mr torfil has already narrated the cause of the error you are getting. You may be calling the function from some classes which are not drived from CWindow or CWnd or any of the classes derived from these.
at these places you can call the function as follows.
HWND GetDlgItem(
HWND hDlg, // handle to dialog box
int nIDDlgItem // control identifier
);
you can get its help from MSDN.
Thanks for all post , I have settle this case .
Appreciate any help .
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|