UINT ThreadFunc(LPVOID lpParam) //线程函数
{
int bRet = 0;
MSG msg;
while(true)
{
if ((bRet = PeekMessage(&msg,NULL ,0,0,PM_REMOVE)) != 0)//Peek不阻塞,如果使用GetMessage会阻塞
{
// handle the error and possibly exit
if (msg.message == WM_USERMSG)
{
MessageBox(NULL, "receive from main thread", "", MB_OK);
}
else if (msg.message == WM_CLOSE)
{
return 0;
}
}
//todo something
}
return 0;
}
线程中添加消息循环
最新推荐文章于 2024-08-06 16:37:26 发布