I want to have a message handler in MFC which accepts whatever parameters I define in the message-map.
For example,
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);
}
Is such a thing possible?