
August 4th, 2002, 09:00 PM
|
|
Contributing User
|
|
Join Date: Jan 2002
Location: Seattle WA
Posts: 863
  
Time spent in forums: 22 sec
Reputation Power: 8
|
|
|
ON_MESSAGE in C++.net
Has anyone managed to get ON_MESSAGE to work in MSVC++ .net? I've noticed lot's of help requests splattered across the web, but it seems no one knows how to make it work, since none of them get replies. Here's the old-fashioned way of doing it, works in MSVC++ 6.0.
In MainFrm.h
Code:
DECLARE_MESSAGE_MAP()
LRESULT OnMyMessage(LPARAM lParam, WPARAM wParam);
In MainFrm.cpp
Code:
#define UWM_MYMESSAGE (WM_USER + 1)
BEGIN_MESSAGE_MAP(CMainFrame, CFrameWnd)
ON_MESSAGE(UWM_MYMESSAGE, OnMyMessage)
END_MESSAGE_MAP()
LRESULT CMainFrame::OnMyMessage(LPARAM lParam, WPARAM wParam)
{
return 0;
}
And the error:
...\MainFrm.cpp(30): error C2440: 'static_cast' : cannot convert from 'LRESULT (__thiscall CMainFrame::* )(LPARAM,WPARAM)' to 'LRESULT (__thiscall CWnd::* )(WPARAM,LPARAM)'
Why is this a problem now? Evidently, the framework doesn't like messages being handled outside of the CWnd class? It doesn't make sense, since you usually don't modify the CWnd class. CMainFrame is inherits from CWnd, so I don't see how the cast should be causing a problem. I've looked up the docs on c2440, but frankly, it's beyond me how that applies to MFC, since I'm not really familiar with the bowels of the MFC code.
How do you get WM_MESSAGE to work in c++.net?
|