August 4th, 2002, 08:00 PM
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.
LRESULT OnMyMessage(LPARAM lParam, WPARAM wParam);
And the error:
#define UWM_MYMESSAGE (WM_USER + 1)
LRESULT CMainFrame::OnMyMessage(LPARAM lParam, WPARAM wParam)
...\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?
August 5th, 2002, 12:41 AM
i´m no c++ pro, but from my view:
CMainFrame should be a descendant of CWin, is it? so the declaration should be valid.
oooops, you switched LPARAM and WPARAM
August 5th, 2002, 02:21 AM
Wow, aren't I the fool? I knew it was something trivial. Hehehe...weeeeee!
I guess it's a good thing that the message map macros now catch bad prototypes, they never used to. Handy.