函数学习 发表于 2015-11-26 | 分类于 Windows 弄个函数学习++123456789101112131415161718192021BOOL WINAPI PostThreadMessage(_In_ DWORD idThread,_In_ UINT Msg,_In_ WPARAM wParam,_In_ LPARAM lParam);//向指定线程ID,发送消息,高低字节参数。//嘿嘿,线程可以完全像消息机制;DWORD ThreadProc(LPVOID lParam){ MSG msg; while(GetMessage(&msg,0,0,0)) { if(msg.message == TALK_MESSAGE) { MessageBox(NULL,L"Hi",L"Worker Thread",MB_OK); } DispatchMessage(&msg);//下发消息,好像线程没有消息注册窗口。 } MessageBox(NULL,L"Thread will close by pressing OK",L"From Worker Thread",MB_OK); AfxGetApp()->m_pMainWnd->PostMessageW(TALK_MESSAGE+1,0,0); return 0;}