[英]no instance of overloaded function "AfxBeginThread" matches the argument list
am trying to make a worker thread using MFC so here is the codes:我正在尝试使用 MFC 创建一个工作线程,所以这里是代码:
struct ThreadParam
{
HWND mDlg; // Note: A handle.
};
UINT TestMFCThread::Test( LPVOID pParam ){
//do work!
}
void TestMFCThread::OnBnClickedButton2()
{
ThreadParam* param = new ThreadParam;
param->mDlg = m_hWnd;
AfxBeginThread(Test, param);
}
but it gives me this error:但它给了我这个错误:
1 IntelliSense: no instance of overloaded function "AfxBeginThread" matches the argument list
argument types are: (UINT (LPVOID pParam), ThreadParam *)
idk whats wrong it's supposed to be right! idk 怎么了它应该是正确的!
From the documentation for AfxBeginThread() you need to cast the second argument to LPVOID
: 从AfxBeginThread()的文档中,您需要将第二个参数强制转换为
LPVOID
:
AfxBeginThread(Test, (LPVOID) param);
and set calling convention of Test
to __cdecl
: 并将
Test
调用约定设置为__cdecl
:
UINT __cdecl Test( LPVOID lParam)
just declare your member function as static, it will solve the issue只需将您的成员 function 声明为 static,即可解决问题
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.