Home > Software engineering >  Vc create a thread display types are not compatible
Vc create a thread display types are not compatible

Time:09-28

Severity code shows the project file line Suppression State
Error (activities) E0167 "DWORD (__stdcall CAAADlg: : *) (LPVOID pPram)" type of real participation "LPTHREAD_START_ROUTINE type parameter is not compatible with"

The above is the error message
Below is the header file statement
DWORD WINAPI th (LPVOID pPram);
The following is the function
DWORD WINAPI CAAADlg: : th (LPVOID pPram)
{
MessageBox (" aaaaaaaaa ");
return 0;
}
Here is where the problems
M_hListenThread=CreateThread (NULL, 0, th, this, 0, NULL);

CodePudding user response:

//XXXX. H
Combined with the static
The class CAAADlg:
{
.
The static DWORD WINAPI th (LPVOID pPram);

.
};

CodePudding user response:

After add static statement variables prompt non-static member references must be as opposed to a particular object, how to solve this? Where to declare variables?

CodePudding user response:

M_hListenThread=CreateThread (NULL, 0, th, this, 0, NULL);//passed this

DWORD WINAPI CAAADlg: : th (LPVOID pPram)
{
PThis CAAADlg *=(CAAADlg *) pParam;
//pThis - & gt; XXXXX
}

CodePudding user response:

Thread function must be defined in the class and the static

The static DWORD WINAPI th (LPVOID pPram);

CodePudding user response:

refer to the second floor Peyote_ response:
statement after the static variables prompt non-static member references must be as opposed to a particular object, how to solve this? Where to declare variables?


Create a thread CreateThread object pointer must be (usually this) passed to lpParameter parameter, in the thread function, through LPVOID pPram (=was introduced into this) to access the class members

CodePudding user response:

Will this through the thread function parameters passed in (note!!!!! Not for the UI operation)
  • Related