|
-
May 26th, 2009, 02:26 PM
#1
VC++ 6.0 -> .net 2003 conversion issue
Hi all,
I'm having an issue converting some code that compiled in VC++ 6.0 fine, but is not in .net 2003.
I've scoured the internet, and found a lot of solutions to problems were related to this error, but nothing for this particular issue.
The error I'm receiving from the compiler is:
filename.cpp(88): error C2440: 'static_cast' : cannot convert from 'LRESULT (__thiscall ClassName::* )(WPARAM,LPARAM)' to 'LRESULT (__thiscall CWnd::* )(WPARAM,LPARAM)'
The offending line of code is:
Code:
BEGIN_MESSAGE_MAP(ClassName, CWinApp)
.
.
.
ON_MESSAGE(WM_USER,SaveAllModDBTF)
The function's prototype:
Code:
afx_msg LRESULT SaveAllModDBTF(WPARAM, LPARAM);
The function's header:
Code:
LRESULT ClassName::SaveAllModDBTF(WPARAM wParam,LPARAM lParam)
Does anyone have any ideas about what the issue could be? Let me know if any additional information is required.
Last edited by snikeris; May 27th, 2009 at 07:05 AM.
-
May 26th, 2009, 03:51 PM
#2
Re: VC++ 6.0 -> .net 2003 conversion issue
Only WM_COMMAND messages are routed to CWinApp class. user defined messages (WM_USER, WM_APP, register Windows messages and many others) - not!
Victor Nijegorodov
-
May 27th, 2009, 12:06 AM
#3
Re: VC++ 6.0 -> .net 2003 conversion issue
Hmm,
What is ClassName derived from?
... what happens if you cast it to a CWnd? It appears that the compiler wants a CWnd derived class.
-
May 27th, 2009, 06:59 AM
#4
Re: VC++ 6.0 -> .net 2003 conversion issue
 Originally Posted by VictorN
Only WM_COMMAND messages are routed to CWinApp class. user defined messages (WM_USER, WM_APP, register Windows messages and many others) - not!
Is this something that changed w/ .NET 2003?
If not, are you saying that this application has never received those messages, and therefore has never called the corresponding handling functions?
-
May 27th, 2009, 07:04 AM
#5
Re: VC++ 6.0 -> .net 2003 conversion issue
 Originally Posted by CNemo
Hmm,
What is ClassName derived from?
... what happens if you cast it to a CWnd? It appears that the compiler wants a CWnd derived class.
It is derived from CWinApp.
I'm not sure what you mean by cast it. If, in the header file I change:
Code:
class ClassName : public CWinApp
{
to
Code:
class ClassName : public CWnd
{
The error appears to go away, but I get a bunch of new errors since members of CWinApp are no longer available.
Is this what you meant by casting it?
-
May 27th, 2009, 08:31 AM
#6
Re: VC++ 6.0 -> .net 2003 conversion issue
 Originally Posted by snikeris
Is this something that changed w/ .NET 2003?
No!
 Originally Posted by snikeris
If not, are you saying that this application has never received those messages, and therefore has never called the corresponding handling functions?
All window messagescan only be sent/posted to some window.
In MFC you can send/post messages to any CWnd derived class object as lon as this object has already created its window (m_hWnd member).
CWinApp class is NOT derived from CWnd and it does NOT have any window to which you could sent/post message.
However, MFC extends the message routing behaviour for some messages (such as WM_COMMAND), so the message sent to the CMainFrame window might be also handled in one of the CView, CDocument or CWinApp derived classes, if is were not handled in CMainFrame derived class.
Have a look at TN021: Command and Message Routing
Victor Nijegorodov
-
May 27th, 2009, 01:27 PM
#7
Re: VC++ 6.0 -> .net 2003 conversion issue
Hmmm, it sounds like you changed the code somehow when you converted it to 2003.
What Victor is trying to tell you is that the type of message you are trying to send is only works for CWnd derive classes and the message you are using is in a CWinApp.
I believe your code worked in V6 but you changed something.
Try the following:
Create an Empty Project in 2003 and just copy the files from your working V6 project without changing any code. The should work.
If not let us know. But if it worked in V6 then creating an empty project and copying the project files over should work.
You probobly moved that function over from a Wnd derived class or made some other file modes when you went to 2003, again create an empty project and just copy the V6 FILES over.
...other wise you are going to have to rewrite your function to be CWinApp compatible(which you shouldn't have to if it worked in V6)
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|