illegal call of non-static member function 
Author Message
 illegal call of non-static member function

//  in CDlg.h

Class CDlg : CDialog {
public:
   static DWORD SockThread(LPVOID);

Quote:
}

//  in CDlg.cpp

DWORD CDlg::SockThread(LPVOID) {
       CDlg::GetDlgItem(IDC_ACCEPT);
//OR         GetDlgItem(IDC_ACCEPT);

Quote:
}

the IDC_ACCEPT is a button, and following compile error occurred
CDlg.cpp(139) : error C2352: 'CWnd::GetDlgItem' : illegal call of non-static
member function


Thu, 08 Jul 2004 22:33:55 GMT  
 illegal call of non-static member function
Hi!
You cannot call non-static function GetDlgItem() from static SockThread()
( no "this" so it know nothing
about current CDlg )
What you need to do is to put CDlg * as parameter to SockThread and and call
there GetDlgItem
In Create thread "this" have to be set as a parameter to thead
and thread function  :
DWORD CDlg::SockThread(LPVOID p) {
       static_cast<CDlg *>(p)->GetDlgItem(IDC_ACCEPT);
    return XX ; // you forgot return code here and my usual error in class
definition of CDlg you forgot ";" after }

Quote:
}

HTH
Arkady


Quote:
> //  in CDlg.h

> Class CDlg : CDialog {
> public:
>    static DWORD SockThread(LPVOID);
> }

> //  in CDlg.cpp

> DWORD CDlg::SockThread(LPVOID) {
>        CDlg::GetDlgItem(IDC_ACCEPT);
> //OR         GetDlgItem(IDC_ACCEPT);
> }

> the IDC_ACCEPT is a button, and following compile error occurred
> CDlg.cpp(139) : error C2352: 'CWnd::GetDlgItem' : illegal call of
non-static
> member function



Thu, 08 Jul 2004 23:46:06 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. illegal call of non-static member function

2. illegal call of non-static member function *HELP*

3. illegal call of non-static member function

4. Illegal call of non-static member function (error)?

5. illegal call of non-static member function

6. Error C2352 - illegal call of non-static member function

7. Compiler Error C2352: illegal call of non-static member function

8. illegal call of non-static member function

9. Nothing declared as static but: illegal call of non-static member function...

10. "illegal call of non-static member function"

11. CWnd::GetClientRect' : illegal call of non-static member function

12. Compiler Error C2352:<Function_Name> illegal call of non-static member function

 

 
Powered by phpBB® Forum Software