Message Map Problem [modified]
-
Hello, I create a "Windows Form Application" project that names p2pport, in Microsoft visual .NET 2005. I want to use the Message Map. I see it on MSDN. MFC uses it. So I include the #include , and use MFC in a shared DLL. This is my code. BEGIN_MESSAGE_MAP(p2pport::Dlg,public System::Windows::Forms::Form) ON_MESSAGE(WM_UI1, p2pport::Dlg::OnUI1, WPARAM wParam, LPARAM lParam) ON_MESSAGE(WM_UI2, p2pport::Dlg::OnUI2, WPARAM wParam, LPARAM lParam) ON_MESSAGE(MM_MIXM_LINE_CHANGE,p2pport::Dlg::onMixerCallBack) ON_MESSAGE(MM_MIXM_CONTROL_CHANGE,p2pport::Dlg::onMixerCallBack) END_MESSAGE_MAP() p2pport is my project name, and Dlg is the name of my form file. But I get a lots of errors. error C2039: 'GetMessageMap' : is not a member of 'p2pport::Dlg' error C2039: 'GetThisMessageMap' : is not a member of 'p2pport::Dlg' error C2039: 'GetThisMessageMap' : is not a member of 'System::Int32' error C2270: 'GetMessageMap' : modifiers not allowed on nonmember functions error C2365: 'GetThisMessageMap' : redefinition; previous definition was 'formerly unknown identifier' error C2440: 'static_cast' : cannot convert from 'void (__clrcall p2pport::Dlg::* )(WPARAM,LPARAM)' to 'LRESULT (__thiscall CWnd::* )(WPARAM,LPARAM)' error C2440: 'static_cast' : cannot convert from 'void (__clrcall p2pport::Dlg::* )(WPARAM,LPARAM)' to 'LRESULT (__thiscall CWnd::* )(WPARAM,LPARAM)' error C2440: 'static_cast' : cannot convert from 'void (__clrcall p2pport::Dlg::* )(WPARAM,LPARAM)' to 'LRESULT (__thiscall CWnd::* )(WPARAM,LPARAM)' error C2440: 'static_cast' : cannot convert from 'void (__clrcall p2pport::Dlg::* )(WPARAM,LPARAM)' to 'LRESULT (__thiscall CWnd::* )(WPARAM,LPARAM)' error C3861: 'GetThisMessageMap': identifier not found error C4430: missing type specifier - int assumed. Note: C++ does not support default-int I google it, but nothing finds. Can anybody help me to solve it? Appreciate for ur reply. Thx. -- modified at 5:03 Tuesday 6th November, 2007
-
Hello, I create a "Windows Form Application" project that names p2pport, in Microsoft visual .NET 2005. I want to use the Message Map. I see it on MSDN. MFC uses it. So I include the #include , and use MFC in a shared DLL. This is my code. BEGIN_MESSAGE_MAP(p2pport::Dlg,public System::Windows::Forms::Form) ON_MESSAGE(WM_UI1, p2pport::Dlg::OnUI1, WPARAM wParam, LPARAM lParam) ON_MESSAGE(WM_UI2, p2pport::Dlg::OnUI2, WPARAM wParam, LPARAM lParam) ON_MESSAGE(MM_MIXM_LINE_CHANGE,p2pport::Dlg::onMixerCallBack) ON_MESSAGE(MM_MIXM_CONTROL_CHANGE,p2pport::Dlg::onMixerCallBack) END_MESSAGE_MAP() p2pport is my project name, and Dlg is the name of my form file. But I get a lots of errors. error C2039: 'GetMessageMap' : is not a member of 'p2pport::Dlg' error C2039: 'GetThisMessageMap' : is not a member of 'p2pport::Dlg' error C2039: 'GetThisMessageMap' : is not a member of 'System::Int32' error C2270: 'GetMessageMap' : modifiers not allowed on nonmember functions error C2365: 'GetThisMessageMap' : redefinition; previous definition was 'formerly unknown identifier' error C2440: 'static_cast' : cannot convert from 'void (__clrcall p2pport::Dlg::* )(WPARAM,LPARAM)' to 'LRESULT (__thiscall CWnd::* )(WPARAM,LPARAM)' error C2440: 'static_cast' : cannot convert from 'void (__clrcall p2pport::Dlg::* )(WPARAM,LPARAM)' to 'LRESULT (__thiscall CWnd::* )(WPARAM,LPARAM)' error C2440: 'static_cast' : cannot convert from 'void (__clrcall p2pport::Dlg::* )(WPARAM,LPARAM)' to 'LRESULT (__thiscall CWnd::* )(WPARAM,LPARAM)' error C2440: 'static_cast' : cannot convert from 'void (__clrcall p2pport::Dlg::* )(WPARAM,LPARAM)' to 'LRESULT (__thiscall CWnd::* )(WPARAM,LPARAM)' error C3861: 'GetThisMessageMap': identifier not found error C4430: missing type specifier - int assumed. Note: C++ does not support default-int I google it, but nothing finds. Can anybody help me to solve it? Appreciate for ur reply. Thx. -- modified at 5:03 Tuesday 6th November, 2007
Own created messages will be handled this way in >>MFC<<: In header: class MyView { ... LRESULT OnMyMessage(WPARAM w=0,LPARAM l=0); ... }; in .cpp: BEGIN_MESSAGEMAP(MyView,CFormView) ON_MESSAGE(WM_MY_OWN_MESSAGE,OnMyMessage) END_MESSAGE_MAP() LRESULT MyView::OnMyMessage(WPARAM w,LPARAM l) { // Work return TRUE; } I hope this helps you :)
-
Own created messages will be handled this way in >>MFC<<: In header: class MyView { ... LRESULT OnMyMessage(WPARAM w=0,LPARAM l=0); ... }; in .cpp: BEGIN_MESSAGEMAP(MyView,CFormView) ON_MESSAGE(WM_MY_OWN_MESSAGE,OnMyMessage) END_MESSAGE_MAP() LRESULT MyView::OnMyMessage(WPARAM w,LPARAM l) { // Work return TRUE; } I hope this helps you :)
Thx for your reply. It helps me a lot. But I still get some errors. I create a header file that named CMyView and the content is following.
#ifndef CMYVIEW_H #define CMYVIEW_H #include <afxwin.h> #include <afxext.h> public class CMyView : public CFormView { LRESULT OnUI1(WPARAM wParam, LPARAM lParam); LRESULT OnUI2(WPARAM wParam, LPARAM lParam); LRESULT onMixerCallBack(WPARAM wParam, LPARAM lParam); }; #endif
And my code is modified as below.BEGIN_MESSAGE_MAP(CMyView,CFormView) ON_MESSAGE(WM_UI1, OnUI1) ON_MESSAGE(WM_UI2, OnUI2) ON_MESSAGE(MM_MIXM_LINE_CHANGE,onMixerCallBack) ON_MESSAGE(MM_MIXM_CONTROL_CHANGE,onMixerCallBack) END_MESSAGE_MAP()
And there's the error. error C2509: 'GetMessageMap' : member function not declared in 'CMyView' error C2509: 'GetThisMessageMap' : member function not declared in 'CMyView' How could I solve this problem? Appreciate for ur reply. Thx. -
Thx for your reply. It helps me a lot. But I still get some errors. I create a header file that named CMyView and the content is following.
#ifndef CMYVIEW_H #define CMYVIEW_H #include <afxwin.h> #include <afxext.h> public class CMyView : public CFormView { LRESULT OnUI1(WPARAM wParam, LPARAM lParam); LRESULT OnUI2(WPARAM wParam, LPARAM lParam); LRESULT onMixerCallBack(WPARAM wParam, LPARAM lParam); }; #endif
And my code is modified as below.BEGIN_MESSAGE_MAP(CMyView,CFormView) ON_MESSAGE(WM_UI1, OnUI1) ON_MESSAGE(WM_UI2, OnUI2) ON_MESSAGE(MM_MIXM_LINE_CHANGE,onMixerCallBack) ON_MESSAGE(MM_MIXM_CONTROL_CHANGE,onMixerCallBack) END_MESSAGE_MAP()
And there's the error. error C2509: 'GetMessageMap' : member function not declared in 'CMyView' error C2509: 'GetThisMessageMap' : member function not declared in 'CMyView' How could I solve this problem? Appreciate for ur reply. Thx.I got it. I lose DECLARE_MESSAGE_MAP()in the header file. The correct code is as below.
#ifndef CMYVIEW_H #define CMYVIEW_H #include <afxwin.h> #include <afxext.h> public class CMyView : public CFormView { public: afx_msg LRESULT OnUI1(WPARAM wParam, LPARAM lParam); LRESULT OnUI2(WPARAM wParam, LPARAM lParam); LRESULT onMixerCallBack(WPARAM wParam, LPARAM lParam); protected: DECLARE_MESSAGE_MAP(); }; #endif
-
I got it. I lose DECLARE_MESSAGE_MAP()in the header file. The correct code is as below.
#ifndef CMYVIEW_H #define CMYVIEW_H #include <afxwin.h> #include <afxext.h> public class CMyView : public CFormView { public: afx_msg LRESULT OnUI1(WPARAM wParam, LPARAM lParam); LRESULT OnUI2(WPARAM wParam, LPARAM lParam); LRESULT onMixerCallBack(WPARAM wParam, LPARAM lParam); protected: DECLARE_MESSAGE_MAP(); }; #endif