Hello,
I am trying to use PostMessage() to send a message to my CView derived class. I have a project that is SDI and my view class is called CMyView, which is derived from CFormView.
Here is the relevent code:
For some reason, after PostMessage() is called, the OnUpdateData() function is never called. Does anyone know why not?
Regards,
Ellay K.
I am trying to use PostMessage() to send a message to my CView derived class. I have a project that is SDI and my view class is called CMyView, which is derived from CFormView.
Here is the relevent code:
Code:
in my MyView.h file:
afx_msg LRESULT OnUpdateData(WPARAM wParam,LPARAM lParam);
in my MyView.cpp file:
BEGIN_MESSAGE_MAP(CMyView, CFormView)
...
ON_MESSAGE(WM_USER_DATA_MESSAGE, OnUpdateData)
END_MESSAGE_MAP()
LRESULT CMyView::OnUpdateData(WPARAM wParam, LPARAM lParam)
{
...
return 0;
}
in my App.cpp file:
#define WM_USER_DATA_MESSAGE 1027
// getting view handle
CMyView* viewHandle = CMyView::GetViewHandle();
CWinThread* pThread1 = AfxBeginThread(MessageHandlerThread, &viewHandle, THREAD_PRIORITY_NORMAL, 0, 0);
UINT MessageHandlerThread(LPVOID lParam)
{
HWND hWnd = ((CMyView*)lParam)->GetSafeHwnd();
PostMessage(hWnd, WM_USER_DATA_MESSAGE, 0, (LPARAM)data);
}
Regards,
Ellay K.