Thread question??
-
a Dialog-Based project i begin a thread in OnInitialDialog() m_list is a variable related with a CListCtrl widget when compiling it shows that error C2065: 'USES_CONVERSION' : undeclared identifier error C2065: 'ReadDirectoryChangesW' : undeclared identifier error C2065: 'm_list' : undeclared identifier error C2227: left of '->InsertItem' must point to class/struct/union error C2227: left of '->GetItemCount' must point to class/struct/union error C2227: left of '->SetItemText' must point to class/struct/union How can i deal with it ?? And why ?? thanks
-
a Dialog-Based project i begin a thread in OnInitialDialog() m_list is a variable related with a CListCtrl widget when compiling it shows that error C2065: 'USES_CONVERSION' : undeclared identifier error C2065: 'ReadDirectoryChangesW' : undeclared identifier error C2065: 'm_list' : undeclared identifier error C2227: left of '->InsertItem' must point to class/struct/union error C2227: left of '->GetItemCount' must point to class/struct/union error C2227: left of '->SetItemText' must point to class/struct/union How can i deal with it ?? And why ?? thanks
york528 wrote:
error C2065: 'USES_CONVERSION' : undeclared identifier
See here.
york528 wrote:
error C2065: 'ReadDirectoryChangesW' : undeclared identifier
See here.
york528 wrote:
error C2065: 'm_list' : undeclared identifier
See here. What does any of what you posted have to do with threads?
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
-
a Dialog-Based project i begin a thread in OnInitialDialog() m_list is a variable related with a CListCtrl widget when compiling it shows that error C2065: 'USES_CONVERSION' : undeclared identifier error C2065: 'ReadDirectoryChangesW' : undeclared identifier error C2065: 'm_list' : undeclared identifier error C2227: left of '->InsertItem' must point to class/struct/union error C2227: left of '->GetItemCount' must point to class/struct/union error C2227: left of '->SetItemText' must point to class/struct/union How can i deal with it ?? And why ?? thanks
Can you show your code and it seems you forgot to include header file or your program?
-
a Dialog-Based project i begin a thread in OnInitialDialog() m_list is a variable related with a CListCtrl widget when compiling it shows that error C2065: 'USES_CONVERSION' : undeclared identifier error C2065: 'ReadDirectoryChangesW' : undeclared identifier error C2065: 'm_list' : undeclared identifier error C2227: left of '->InsertItem' must point to class/struct/union error C2227: left of '->GetItemCount' must point to class/struct/union error C2227: left of '->SetItemText' must point to class/struct/union How can i deal with it ?? And why ?? thanks
Basix. 1.include atlbase.h 2.You cannot access member variables from a static thread function. Pass the this(Dlg) pointer into the thread param and access it inside the function or do it in one of the 100 ways.
OK,. what country just started work for the day ? The ASP.NET forum is flooded with retarded questions. -Christian Graus Best wishes to Rexx[^]
-
a Dialog-Based project i begin a thread in OnInitialDialog() m_list is a variable related with a CListCtrl widget when compiling it shows that error C2065: 'USES_CONVERSION' : undeclared identifier error C2065: 'ReadDirectoryChangesW' : undeclared identifier error C2065: 'm_list' : undeclared identifier error C2227: left of '->InsertItem' must point to class/struct/union error C2227: left of '->GetItemCount' must point to class/struct/union error C2227: left of '->SetItemText' must point to class/struct/union How can i deal with it ?? And why ?? thanks
i expect that the threadFunction improperly tries to access the list object, etc which are own by the main thread. pass the this value to the param field of beginthread, then receive it inside your functionbloc and cast it to a main dialog pointer by wich you access things.
Our Philosophy, Mohammed Baqir Al Sadr
-
i expect that the threadFunction improperly tries to access the list object, etc which are own by the main thread. pass the this value to the param field of beginthread, then receive it inside your functionbloc and cast it to a main dialog pointer by wich you access things.
Our Philosophy, Mohammed Baqir Al Sadr
He is not even able to compile the code? Read the question carefully again. -Saurabh
-
He is not even able to compile the code? Read the question carefully again. -Saurabh
1- I should be wrong 2- I should be always treated and faced with interventions like yours 3- I should suffer from the most punishment for persisting not to clear my behaviour and at least accept the fact that if I have to tell someone something, or that if I have to help him, then I have to speak properly, explain with evidence , and not throw an answer or a solution in a way that make the person not believe in it or hesistate to believe that it will solve his problem. 4- I have problem with myself as you can see becvuase you are intelligent. 5- I am correct (not to your disappointment of course). So here I created a sample MFC Dlg project, and I created a memberfunction of the main dialog class (CThreadQuestionDlg) which is passed as parameter to teh createThread function somewhere in order to be executed by that would-be-thread. I coded the function such it access the m_list member of the dialog class in two ways :
// ThreadQuestionDlg.h : header file
//#pragma once
#include "afxcmn.h"// CThreadQuestionDlg dialog
class CThreadQuestionDlg : public CDialog
{
// Construction
public:
CThreadQuestionDlg(CWnd* pParent = NULL); // standard constructor// Dialog Data
enum { IDD = IDD_THREADQUESTION_DIALOG };protected: virtual void DoDataExchange(CDataExchange\* pDX); // DDX/DDV support
// Implementation
protected:
HICON m_hIcon;// Generated message map functions virtual BOOL OnInitDialog(); afx\_msg void OnSysCommand(UINT nID, LPARAM lParam); afx\_msg void OnPaint(); afx\_msg HCURSOR OnQueryDragIcon(); DECLARE\_MESSAGE\_MAP()
public:
CListCtrl m_list;// static UINT ThreadProc(LPVOID pParam) { CThreadQuestionDlg\* pMe = reinterpret\_cast<CThreadQuestionDlg\*>(pParam); pMe->m\_list.DeleteAllItems(); /\*This is the case number 1\*/ //m\_list.DeleteAllItems(); /\*This is the case number 2\*/ return 0; } void StartThread() { AfxBeginThread(ThreadProc, this); }
};
Look at the code and you will find two particular lines within the ThreadProc member. If we keep things as they are there are no problems. But if We uncomment the case number 2 and we comment the case number 1 Then soon when we try to compile we get C2228 compilation code errors ! 1>Compiling... 1>ThreadQuestionDlg.cpp 1>c:\documents and settings\administrateur\mes documents\visual studio 2005\projects\threadquestion\threadquestion\threadquestiondlg.h(44) : error C2228: left of '.DeleteAllItems' must have class/str
-
1- I should be wrong 2- I should be always treated and faced with interventions like yours 3- I should suffer from the most punishment for persisting not to clear my behaviour and at least accept the fact that if I have to tell someone something, or that if I have to help him, then I have to speak properly, explain with evidence , and not throw an answer or a solution in a way that make the person not believe in it or hesistate to believe that it will solve his problem. 4- I have problem with myself as you can see becvuase you are intelligent. 5- I am correct (not to your disappointment of course). So here I created a sample MFC Dlg project, and I created a memberfunction of the main dialog class (CThreadQuestionDlg) which is passed as parameter to teh createThread function somewhere in order to be executed by that would-be-thread. I coded the function such it access the m_list member of the dialog class in two ways :
// ThreadQuestionDlg.h : header file
//#pragma once
#include "afxcmn.h"// CThreadQuestionDlg dialog
class CThreadQuestionDlg : public CDialog
{
// Construction
public:
CThreadQuestionDlg(CWnd* pParent = NULL); // standard constructor// Dialog Data
enum { IDD = IDD_THREADQUESTION_DIALOG };protected: virtual void DoDataExchange(CDataExchange\* pDX); // DDX/DDV support
// Implementation
protected:
HICON m_hIcon;// Generated message map functions virtual BOOL OnInitDialog(); afx\_msg void OnSysCommand(UINT nID, LPARAM lParam); afx\_msg void OnPaint(); afx\_msg HCURSOR OnQueryDragIcon(); DECLARE\_MESSAGE\_MAP()
public:
CListCtrl m_list;// static UINT ThreadProc(LPVOID pParam) { CThreadQuestionDlg\* pMe = reinterpret\_cast<CThreadQuestionDlg\*>(pParam); pMe->m\_list.DeleteAllItems(); /\*This is the case number 1\*/ //m\_list.DeleteAllItems(); /\*This is the case number 2\*/ return 0; } void StartThread() { AfxBeginThread(ThreadProc, this); }
};
Look at the code and you will find two particular lines within the ThreadProc member. If we keep things as they are there are no problems. But if We uncomment the case number 2 and we comment the case number 1 Then soon when we try to compile we get C2228 compilation code errors ! 1>Compiling... 1>ThreadQuestionDlg.cpp 1>c:\documents and settings\administrateur\mes documents\visual studio 2005\projects\threadquestion\threadquestion\threadquestiondlg.h(44) : error C2228: left of '.DeleteAllItems' must have class/str
Wow you have some serious issues!!!
hINTModuleState wrote:
CListCtrl m_list; // static UINT ThreadProc(LPVOID pParam) { CThreadQuestionDlg* pMe = reinterpret_cast(pParam); pMe->m_list.DeleteAllItems(); /*This is the case number 1*/ //m_list.DeleteAllItems(); /*This is the case number 2*/ return 0; } void StartThread() { AfxBeginThread(ThreadProc, this); }
Uncommenting second case will lead to compiling error because ThreadProc is a static function and a static function can only access static members of a class. Since m_list is not a static variable you cannot access it directly from with the function. For you profiling needs try http://www.codeproject.com/KB/datetime/perftimer.aspx[^] Saurabh
-
Can you show your code and it seems you forgot to include header file or your program?
-
Basix. 1.include atlbase.h 2.You cannot access member variables from a static thread function. Pass the this(Dlg) pointer into the thread param and access it inside the function or do it in one of the 100 ways.
OK,. what country just started work for the day ? The ASP.NET forum is flooded with retarded questions. -Christian Graus Best wishes to Rexx[^]
-
york528 wrote:
error C2065: 'USES_CONVERSION' : undeclared identifier
See here.
york528 wrote:
error C2065: 'ReadDirectoryChangesW' : undeclared identifier
See here.
york528 wrote:
error C2065: 'm_list' : undeclared identifier
See here. What does any of what you posted have to do with threads?
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
-
Can you show your code and it seems you forgot to include header file or your program?
-
after include atlbase.h only error C2065: 'ReadDirectoryChangesW' : undeclared identifier do i miss other head file??
-
define this :
#define _WIN32_WINNT 0x400
in stdafx.h. What OS are you using?
OK,. what country just started work for the day ? The ASP.NET forum is flooded with retarded questions. -Christian Graus Best wishes to Rexx[^]
-
york528 wrote:
error C2065: 'USES_CONVERSION' : undeclared identifier
See here.
york528 wrote:
error C2065: 'ReadDirectoryChangesW' : undeclared identifier
See here.
york528 wrote:
error C2065: 'm_list' : undeclared identifier
See here. What does any of what you posted have to do with threads?
"Love people and use things, not love things and use people." - Unknown
"To have a respect for ourselves guides our morals; to have deference for others governs our manners." - Laurence Sterne
-
Can you show your code and it seems you forgot to include header file or your program?
-
i expect that the threadFunction improperly tries to access the list object, etc which are own by the main thread. pass the this value to the param field of beginthread, then receive it inside your functionbloc and cast it to a main dialog pointer by wich you access things.
Our Philosophy, Mohammed Baqir Al Sadr
-
windows XP thank you so much #define _WIN32_WINNT 0x400 what's that for i am new and my English is not so good
Few APIs would be supported to specific OS. That's the OS version. Windows NT 4.0 -> _WIN32_WINNT =0x0400. The error is gone or not?
OK,. what country just started work for the day ? The ASP.NET forum is flooded with retarded questions. -Christian Graus Best wishes to Rexx[^]
-
Few APIs would be supported to specific OS. That's the OS version. Windows NT 4.0 -> _WIN32_WINNT =0x0400. The error is gone or not?
OK,. what country just started work for the day ? The ASP.NET forum is flooded with retarded questions. -Christian Graus Best wishes to Rexx[^]