retry
December 22nd, 2004, 02:52 PM
I have posting this as a new post since the last one ended up with this:
I am posting message from worker to main thread but I have ran into problem that the message is never recieved in the main application thread.
In the App class, I have added the following code to message map to catch the message.
ON_THREAD_MESSAGE(IDM_USER_MSG1, OnUserMsg1)
and than OnUserMsg1 is defned as:
LRESULT OnUserMsg1(WPARAM wParam, LPARAM lParam)
{
.....
return 0;
}
The PostThreadMessage() in the worker thread does return 1 which means it is posted properly. What am I missing in catching this message? Thanks.
I am posting the message with this call:
AfxGetApp()->PostThreadMessage(IDM_USER_MSG1, ... );
I have tried ON_MESSAGE macro as well but that doesn't catch the message either. In addition I have peeked into PreTranslateMessage() but I cann't that message either.
BOOL CHelloApp::PreTranslateMessage(MSG* pMsg)
{
// TODO: Add your specialized code here and/or call the base class
if (pMsg->hwnd == NULL)
{
if (pMsg->message == IDM_USER_MSG1)
AfxMessageBox("Got it"); // sorry no such message here
}
return CWinApp::PreTranslateMessage(pMsg);
}
I am posting message from worker to main thread but I have ran into problem that the message is never recieved in the main application thread.
In the App class, I have added the following code to message map to catch the message.
ON_THREAD_MESSAGE(IDM_USER_MSG1, OnUserMsg1)
and than OnUserMsg1 is defned as:
LRESULT OnUserMsg1(WPARAM wParam, LPARAM lParam)
{
.....
return 0;
}
The PostThreadMessage() in the worker thread does return 1 which means it is posted properly. What am I missing in catching this message? Thanks.
I am posting the message with this call:
AfxGetApp()->PostThreadMessage(IDM_USER_MSG1, ... );
I have tried ON_MESSAGE macro as well but that doesn't catch the message either. In addition I have peeked into PreTranslateMessage() but I cann't that message either.
BOOL CHelloApp::PreTranslateMessage(MSG* pMsg)
{
// TODO: Add your specialized code here and/or call the base class
if (pMsg->hwnd == NULL)
{
if (pMsg->message == IDM_USER_MSG1)
AfxMessageBox("Got it"); // sorry no such message here
}
return CWinApp::PreTranslateMessage(pMsg);
}