CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Jul 2005
    Location
    E: 120°.6, N: 31°.3′
    Posts
    795

    Arrow 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 !

  2. #2
    Join Date
    Aug 2005
    Posts
    104

    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.

  3. #3
    Join Date
    Jul 2005
    Location
    E: 120°.6, N: 31°.3′
    Posts
    795

    Lightbulb 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 !

  4. #4
    Join Date
    Nov 2001
    Location
    Kerala,India
    Posts
    650

    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

  5. #5
    Join Date
    Jul 2005
    Location
    E: 120°.6, N: 31°.3′
    Posts
    795

    Re: About the useness of SetCheck

    Quote 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
  •  





Click Here to Expand Forum to Full Width

Featured