N
Neo
Greetings!
I'm upgrading a VC6 project to VC7.1 (Visual Studio .NET 2003). It is a MFC
project with Doc/View architecture. There is a user-defined message to
handle. Here is the code:
====================================================================
// MainFrm.h
class CMainFrame : public CMDIFrameWnd
{
...
afx_msg void OnParse(UINT wParam, LONG lParam);
...
}
// MainFrm.cpp
BEGIN_MESSAGE_MAP(CMainFrame, CMDIFrameWnd)
...
ON_THREAD_MESSAGE(WM_PARSER_THREAD_CALL, OnParse)
...
END_MESSAGE_MAP()
void CMainFrame::OnParse(UINT wParam, LONG lParam)
{
CDocument *pDoc = (CDocument *)theApp.GetDocument();
ASSERT_VALID(pDoc);
if(pDoc && pDoc->IsKindOf(RUNTIME_CLASS(CDocument)))
{
// Frame receives the message, but document does the work
pDoc->OnParse(wParam, lParam);
}
}
// MyProgram.h
#define WM_PARSER_THREAD_CALL WM_USER+1
// MyProgram.cpp
UINT ParserThread(LPVOID pParam)
{
...
SendMessage(hWndMain, WM_PARSER_THREAD_CALL, 0, 0);
...
}
======================================================================
When I compiled the program, I got the following error:
error C2440: 'static_cast' : cannot convert from 'void (__thiscall
CMainFrame::* )(UINT,LONG)' to 'void (__thiscall
CWinThread::* )(WPARAM,LPARAM)'
I tried to move my message handler to "CWinApp" and built it successfully,
but it doesn't work. Could anyone please give me some advice on how to
correct this? Thanks a lot!
Neo
I'm upgrading a VC6 project to VC7.1 (Visual Studio .NET 2003). It is a MFC
project with Doc/View architecture. There is a user-defined message to
handle. Here is the code:
====================================================================
// MainFrm.h
class CMainFrame : public CMDIFrameWnd
{
...
afx_msg void OnParse(UINT wParam, LONG lParam);
...
}
// MainFrm.cpp
BEGIN_MESSAGE_MAP(CMainFrame, CMDIFrameWnd)
...
ON_THREAD_MESSAGE(WM_PARSER_THREAD_CALL, OnParse)
...
END_MESSAGE_MAP()
void CMainFrame::OnParse(UINT wParam, LONG lParam)
{
CDocument *pDoc = (CDocument *)theApp.GetDocument();
ASSERT_VALID(pDoc);
if(pDoc && pDoc->IsKindOf(RUNTIME_CLASS(CDocument)))
{
// Frame receives the message, but document does the work
pDoc->OnParse(wParam, lParam);
}
}
// MyProgram.h
#define WM_PARSER_THREAD_CALL WM_USER+1
// MyProgram.cpp
UINT ParserThread(LPVOID pParam)
{
...
SendMessage(hWndMain, WM_PARSER_THREAD_CALL, 0, 0);
...
}
======================================================================
When I compiled the program, I got the following error:
error C2440: 'static_cast' : cannot convert from 'void (__thiscall
CMainFrame::* )(UINT,LONG)' to 'void (__thiscall
CWinThread::* )(WPARAM,LPARAM)'
I tried to move my message handler to "CWinApp" and built it successfully,
but it doesn't work. Could anyone please give me some advice on how to
correct this? Thanks a lot!
Neo