2012-03-20 73 views
1

想使使用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); 
} 

,但它給了我這個錯誤:

1 IntelliSense: no instance of overloaded function "AfxBeginThread" matches the argument list 
    argument types are: (UINT (LPVOID pParam), ThreadParam *) 

idk最新錯誤它應該是正確的!

回答

1

從文檔AfxBeginThread()你需要的第二個參數轉換爲LPVOID

AfxBeginThread(Test, (LPVOID) param); 

,並設置呼叫的Test__cdecl約定:

UINT __cdecl Test(LPVOID lParam) 
+0

我想,它仍然給我的錯誤智能感知:沒有重載函數的實例「AfxBeginThread」匹配參數列表 參數類型是:(UINT(LPVOID pParam),LPVOID )' – Abanoub 2012-03-20 17:20:03

+0

有關調用約定的更新答案。 – hmjd 2012-03-20 17:22:35

+0

即使加入後'__cdecl'它仍然給我的論點錯誤'1 \t智能感知:沒有重載函數的實例 「AfxBeginThread」 相匹配的參數列表 參數類型有:(UINT __cdecl(LPVOID pParam),LPVOID)' – Abanoub 2012-03-20 17:26:15

相關問題