主线程的PreTranslateMessage可以接受子线程的PostThreadMessage
在主线程中重载PreTranslateMessage函数,用于接受子线程的消息:
BOOL CMFCApp::PreTranslateMessage(MSG* pMsg)
{
if (pMsg->message == UM_PICKERELEMENT)
{
osg::Node *pNode = ((osg::Node *)pMsg->lParam);
CEntitySelectTrriger::Instance()->TrrigerEntitySelEvent(pNode);
}
return CBCGPWinApp::PreTranslateMessage(pMsg);
}
在子线程中,用PostThreadMessage向主线程中发送消息:
AfxGetApp()->PostThreadMessage(UM_PICKERELEMENT, 0, (LPARAM)anno);