我想在 MFC 中有一个消息处理程序,它接受我在消息映射中定义的任何参数。
例如,
static UINT UWM_STATUS_MSG = RegisterWindowMessage("Status message");
static UINT UWM_GOT_RESULT= RegisterWindowMessage("Result has been obtained");
//{{AFX_MSG(MyClass)
afx_msg void OnCustomStringMessage(LPCTSTR);
afx_msg void OnStatusMessage();
//}}AFX_MSG
BEGIN_MESSAGE_MAP(MyClass, CDialog)
//{{AFX_MSG_MAP(MyClass)
ON_REGISTERED_MESSAGE(UWM_STATUS_MSG, OnStatusMessage)
ON_REGISTERED_MESSAGE(UWM_GOT_RESULT, OnCustomStringMessage)
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
void MyClass::OnCustomStringMessage(LPCTSTR result)
{
m_result.SetWindowText(result);
}
void MyClass::OnStatusMessage()
{
// Do something
}
DWORD WINAPI MyClass::thread(LPVOID lParam)
{
char result[256] = { 0 };
SendMessage(UWM_STATUS_MSG);
// Do some stuff and store the result
PostMessage(UWM_GOT_RESULT, result);
}
这样的事情可能吗?