ON_MESSAGE .NET Issue
-
I am opening and compiling some old code in Visual Studio .NET I've run into a compiling problem..
BEGIN_MESSAGE_MAP(CChildView,CWnd ) //{{AFX_MSG_MAP(CChildView) ON_WM_PAINT() ON_WM_CREATE() ON_WM_ERASEBKGND() ON_WM_SIZE() //}}AFX_MSG_MAP ON_MESSAGE(WM_FLIPWINDOW, OnFlipWindow) END_MESSAGE_MAP()
tells me: error C2440: 'static_cast' : cannot convert from 'void (__thiscall CChildView::* )(void)' to 'LRESULT (__thiscall CWnd::* )(WPARAM,LPARAM)' whats happening here? the Member Function is: void CChildView::OnFlipWindow() Ryan Baillargeon Software Specialist Fuel Cell Technologies Inc.
-
I am opening and compiling some old code in Visual Studio .NET I've run into a compiling problem..
BEGIN_MESSAGE_MAP(CChildView,CWnd ) //{{AFX_MSG_MAP(CChildView) ON_WM_PAINT() ON_WM_CREATE() ON_WM_ERASEBKGND() ON_WM_SIZE() //}}AFX_MSG_MAP ON_MESSAGE(WM_FLIPWINDOW, OnFlipWindow) END_MESSAGE_MAP()
tells me: error C2440: 'static_cast' : cannot convert from 'void (__thiscall CChildView::* )(void)' to 'LRESULT (__thiscall CWnd::* )(WPARAM,LPARAM)' whats happening here? the Member Function is: void CChildView::OnFlipWindow() Ryan Baillargeon Software Specialist Fuel Cell Technologies Inc.
MFC7 (in VS .NET) uses stricter type checking with message map macros. It looks like you need to replace the return from ‘void’ to ‘LRESULT’. Also make sure you supply the correct function parameters, such as (WPARAM, LPARAM) etc. More on this here [click on Microsoft Foundation Class (MFC) link] http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vcedit/html/vcrefWhatsNewLibrariesVisualC70.asp[^] Static Casting and MFC Message Maps Beginning with Visual C++ .NET, MFC provides stricter type checking for return and parameter types of message handler functions. This new behavior notifies the developer of potential problems by flagging potentially unsafe message handlers with an error message. MFC now uses static casts for ON_MESSAGE, ON_REGISTERED_MESSAGE, ON_THREAD_MESSAGE, and ON_REGISTERED_THREAD_MESSAGE. For example, in the past a developer could use a member function that returned void instead of LRESULT for ON_MESSAGE or ON_REGISTERED_MESSAGE and compile without any errors. With Visual C++ .NET, the potential miscast is caught and flagged as an error. The developer can fix the potential problem by replacing the return type (with LRESULT) and recompiling. Hope this helps. // Fazlul
Get RadVC today! Play RAD in VC++ http://www.capitolsoft.com
-
MFC7 (in VS .NET) uses stricter type checking with message map macros. It looks like you need to replace the return from ‘void’ to ‘LRESULT’. Also make sure you supply the correct function parameters, such as (WPARAM, LPARAM) etc. More on this here [click on Microsoft Foundation Class (MFC) link] http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vcedit/html/vcrefWhatsNewLibrariesVisualC70.asp[^] Static Casting and MFC Message Maps Beginning with Visual C++ .NET, MFC provides stricter type checking for return and parameter types of message handler functions. This new behavior notifies the developer of potential problems by flagging potentially unsafe message handlers with an error message. MFC now uses static casts for ON_MESSAGE, ON_REGISTERED_MESSAGE, ON_THREAD_MESSAGE, and ON_REGISTERED_THREAD_MESSAGE. For example, in the past a developer could use a member function that returned void instead of LRESULT for ON_MESSAGE or ON_REGISTERED_MESSAGE and compile without any errors. With Visual C++ .NET, the potential miscast is caught and flagged as an error. The developer can fix the potential problem by replacing the return type (with LRESULT) and recompiling. Hope this helps. // Fazlul
Get RadVC today! Play RAD in VC++ http://www.capitolsoft.com
FYI, this feature alleviates the #1 programmer bug in MFC code. -Nick This posting is provided “AS IS” with no warranties, and confers no rights. You assume all risk for your use. © 2001 Microsoft Corporation. All rights reserved.
-
I am opening and compiling some old code in Visual Studio .NET I've run into a compiling problem..
BEGIN_MESSAGE_MAP(CChildView,CWnd ) //{{AFX_MSG_MAP(CChildView) ON_WM_PAINT() ON_WM_CREATE() ON_WM_ERASEBKGND() ON_WM_SIZE() //}}AFX_MSG_MAP ON_MESSAGE(WM_FLIPWINDOW, OnFlipWindow) END_MESSAGE_MAP()
tells me: error C2440: 'static_cast' : cannot convert from 'void (__thiscall CChildView::* )(void)' to 'LRESULT (__thiscall CWnd::* )(WPARAM,LPARAM)' whats happening here? the Member Function is: void CChildView::OnFlipWindow() Ryan Baillargeon Software Specialist Fuel Cell Technologies Inc.
Look at what the error is telling you. The compiler is expecting a function that takes two params, but you're giving it a function that takes no params. The return type is also wrong. Add the two standard message params (WPARAM and LPARAM) and correct the return value. --Mike-- Just released - RightClick-Encrypt v1.4 - Adds fast & easy file encryption to Explorer My really out-of-date homepage Sonork-100.19012 Acid_Helm