ON_WM_KILLFOCUS
-
The following code snips relate to code that successfully compiled using Visual Studio 6.0. This same implementation does not compile in Visual Studio .Net 7.0. Here is the error message ConfigTSAControlsFView.cpp(200) : error C2440: 'static_cast' : cannot convert from 'void (__thiscall CConfigTSAControlsFView::* )(UINT)' to 'void (__thiscall CWnd::* )(CWnd *)' //Function Declaration afx_msg void OnKillFocus(UINT uiCtrlID); //Message Map Entry ON_WM_KILLFOCUS() //Function Implementation void CConfigTSAControlsFView::OnKillFocus(UINT uiCtrlID) { //the code } Now this is what confuses me the most. The MSDN library implies that the OnKillFocus method takes a CWnd*, not a UINT. Visual studio 6.0, somehow was able to compile this and perform a cast. However, Visual Studio .net is complaining that the static_cast is not possible. So can someone explain to me how visual studio 6.0 can make the cast and why visual studio .Net cannot? The uiCntrlId is used in a switch statement so the actual value being used is equal to the resource Id of the window. How did visual studio cast from a CWnd* to a resource Id automatically? This seems like quite a stretch. If anyone has any ideas, I'd appreciate it. Personally, I think the error message makes perfect sense. Of course the compiler won't cast from a CWnd* to a UINT that has a completely different meaning. I just can't imagine how the code ever compiled and worked with visual studio 6.0. The other thing is that if I change the code to use a CWND*, then it seems to invalidate the existing switch statements, within the function, that expects a controller id.
-
The following code snips relate to code that successfully compiled using Visual Studio 6.0. This same implementation does not compile in Visual Studio .Net 7.0. Here is the error message ConfigTSAControlsFView.cpp(200) : error C2440: 'static_cast' : cannot convert from 'void (__thiscall CConfigTSAControlsFView::* )(UINT)' to 'void (__thiscall CWnd::* )(CWnd *)' //Function Declaration afx_msg void OnKillFocus(UINT uiCtrlID); //Message Map Entry ON_WM_KILLFOCUS() //Function Implementation void CConfigTSAControlsFView::OnKillFocus(UINT uiCtrlID) { //the code } Now this is what confuses me the most. The MSDN library implies that the OnKillFocus method takes a CWnd*, not a UINT. Visual studio 6.0, somehow was able to compile this and perform a cast. However, Visual Studio .net is complaining that the static_cast is not possible. So can someone explain to me how visual studio 6.0 can make the cast and why visual studio .Net cannot? The uiCntrlId is used in a switch statement so the actual value being used is equal to the resource Id of the window. How did visual studio cast from a CWnd* to a resource Id automatically? This seems like quite a stretch. If anyone has any ideas, I'd appreciate it. Personally, I think the error message makes perfect sense. Of course the compiler won't cast from a CWnd* to a UINT that has a completely different meaning. I just can't imagine how the code ever compiled and worked with visual studio 6.0. The other thing is that if I change the code to use a CWND*, then it seems to invalidate the existing switch statements, within the function, that expects a controller id.
The Visual C++ 6 compiler was not particular standards-compliant, while the Visual C++.NET compiler is much moer compliant. There is a lot of code that compiles under Visual C++ 6 that won't compile under the .NET compiler (and vice-versa).
Ryan
"Punctuality is only a virtue for those who aren't smart enough to think of good excuses for being late" John Nichol "Point Of Impact"
-
The following code snips relate to code that successfully compiled using Visual Studio 6.0. This same implementation does not compile in Visual Studio .Net 7.0. Here is the error message ConfigTSAControlsFView.cpp(200) : error C2440: 'static_cast' : cannot convert from 'void (__thiscall CConfigTSAControlsFView::* )(UINT)' to 'void (__thiscall CWnd::* )(CWnd *)' //Function Declaration afx_msg void OnKillFocus(UINT uiCtrlID); //Message Map Entry ON_WM_KILLFOCUS() //Function Implementation void CConfigTSAControlsFView::OnKillFocus(UINT uiCtrlID) { //the code } Now this is what confuses me the most. The MSDN library implies that the OnKillFocus method takes a CWnd*, not a UINT. Visual studio 6.0, somehow was able to compile this and perform a cast. However, Visual Studio .net is complaining that the static_cast is not possible. So can someone explain to me how visual studio 6.0 can make the cast and why visual studio .Net cannot? The uiCntrlId is used in a switch statement so the actual value being used is equal to the resource Id of the window. How did visual studio cast from a CWnd* to a resource Id automatically? This seems like quite a stretch. If anyone has any ideas, I'd appreciate it. Personally, I think the error message makes perfect sense. Of course the compiler won't cast from a CWnd* to a UINT that has a completely different meaning. I just can't imagine how the code ever compiled and worked with visual studio 6.0. The other thing is that if I change the code to use a CWND*, then it seems to invalidate the existing switch statements, within the function, that expects a controller id.
Let me clarify my question. I need to understand why visual studio 6.0 was able make the static_cast so that I can understand how to get this code to work under visual studio.net. Obviously, visual studio .net is more standards compliant since it is complaining. Since I can't imagine how the compiler performs the implicit cast from CWnd* to UINT iResourceId, I have no idea how to do the cast manually. There must be a way.