我在windows下运行是正常的。
::PeekMessage(&pMsg, 0, 0, 0, PM_REMOVE);
但是在wince下就收不到信息。我是在模拟器下运行的
PostThreadMessage返回的是1。
HANDLE thread;
thread=::CreateThread(NULL,0,(LPTHREAD_START_ROUTINE)ThreadFunc1,0,0,&ThreadID);
CloseHandle(thread);
DWORD WINAPI ThreadFunc1(HWND hmodule)
{
MSG pMsg;
while(1)
{
BOOL result = ::PeekMessage(&pMsg, 0, 0, 0, PM_REMOVE);
if(result)
{
if(pMsg.message == WM_LBUTTONDOWN)
MessageBox(NULL, _T("button"), _T("ok"), MB_OK);
}
}
return 0;
}
BOOL result = ::PostThreadMessage(ThreadID, pMsg->message, 0, 0);
这个线程只收到一个最后程序关闭的消息。其他post的消息都收不到,为什么?
我的句柄已经设成0了
If hWnd is NULL, PeekMessage retrieves messages for any window that belongs to the current thread making the call. (PeekMessage does not retrieve messages for windows that belong to other threads.) If hWnd is –1, PeekMessage only returns messages with a hWnd value of NULL, as posted by the PostThreadMessage function.
试试
PeekMessage(&pMsg, -1, 0, 0, PM_REMOVE);
我的postThreadMessage是在dialog里的,如果dialog收到WM_LBUTTONDOWN消息,就发送
而且在windows下用vc是可以的呀,搬到evc下就不行了
我用PeekMessage(&pMsg, -1, 0, 0, PM_NOREMOVE); 好像能收到一条
PeekMessage(&pMsg, 0, 0, 0, PM_NOREMOVE); 可以收到,返回1,PeekMessage(&pMsg, 0, 0, 0, PM_REMOVE);,也收到,但是返回0。
所以我先在两条一起用。