函数学习

弄个函数学习++
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
BOOL 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;
}
// //