(MFC)子线程的数据如何传递给主线程中?

阅读 140

2022-06-17

主线程的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);

 


精彩评论(0)

0 0 举报