VC++ 6 to VC++ 2008 migration error

I am trying to migrate my VC++ 6 source code to Visual Studio 2008.  while compiling the project, I am geeting the following error in VC++ 2008

c:\lnb vs 2008\source\lnbdesktop\lnbframework\MyTestAPp.cpp(154) : error C2440: 'static_cast' : cannot convert from 'LRESULT (__thiscall MyTestAPp::* )(WPARAM,LPARAM)' to 'LRESULT (__thiscall CWnd::* )(WPARAM,LPARAM)'

VC++ 6 code

. H File
afx_msg long OnOpenNextWorkItem(UINT uiParam1, LONG lParam2);

.cpp file
BEGIN_MESSAGE_MAP(MyTestAPp, CWinApp)
ON_REGISTERED_MESSAGE(wm_OpenNextWorkItem,      OnOpenNextWorkItem)
END_MESSAGE_MAP()
long MyTestAPp::OnOpenNextWorkItem(UINT uiParam1, LONG lParam2)
{

}
****************************VC++ 2008 source code******************************************

.H file

afx_msg LRESULT OnOpenNextWorkItem(WPARAM uiParam1, LPARAM lParam2);

cpp file

BEGIN_MESSAGE_MAP(MyTestAPp, CWinApp)
ON_REGISTERED_MESSAGE(wm_OpenNextWorkItem,      OnOpenNextWorkItem)
END_MESSAGE_MAP()



LRESULT MyTestAPp::OnOpenNextWorkItem(WPARAM uiParam1, LPARAM lParam2)
{


}

Thanks in advance.
bobbeyAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

AndyAinscowFreelance programmer / ConsultantCommented:
Does htis help?

ON_REGISTERED_MESSAGE(wm_OpenNextWorkItem,       MyTestAPp::OnOpenNextWorkItem)
0
bobbeyAuthor Commented:
ON_REGISTERED_MESSAGE(wm_OpenNextWorkItem,       MyTestAPp::OnOpenNextWorkItem)

ON_REGISTERED_MESSAGE(wm_OpenNextWorkItem,       &MyTestAPp::OnOpenNextWorkItem)

Didn't work both of the above.
MyTestAPp is derived from CWinAp.  I am not sure any thing related to that
class MyTestAPp: public CWinApp

0
AndyAinscowFreelance programmer / ConsultantCommented:
I just don't like the CWnd* in the error message you get.

Give this a quick try, instead of:
afx_msg LRESULT OnOpenNextWorkItem(WPARAM uiParam1,  LPARAM lParam2);

use this:
LRESULT OnOpenNextWorkItem(WPARAM uiParam1,  LPARAM lParam2);
0
Cloud Class® Course: Microsoft Windows 7 Basic

This introductory course to Windows 7 environment will teach you about working with the Windows operating system. You will learn about basic functions including start menu; the desktop; managing files, folders, and libraries.

bobbeyAuthor Commented:
changed to  LRESULT OnOpenNextWorkItem(WPARAM uiParam1,  LPARAM lParam2);
Again not working
0
bobbeyAuthor Commented:
when I moved the function
afx_msg LRESULT OnOpenNextWorkItem(WPARAM uiParam1,  LPARAM lParam2);

to the frame class, I am able to compile the file. But  not sure th impct of this move.
0
AndyAinscowFreelance programmer / ConsultantCommented:
From a programming point of view it ought to be OK.  (Really depends on what the function does).

I'll try to duplicate the problem here to see if I can work out what is going wrong
0
AndyAinscowFreelance programmer / ConsultantCommented:
// for Registered Windows messages
#define ON_REGISTERED_MESSAGE(nMessageVariable, memberFxn) \
    { 0xC000, 0, 0, 0, (UINT_PTR)(UINT*)(&nMessageVariable), \
        /*implied 'AfxSig_lwl'*/ \
        (AFX_PMSG)(AFX_PMSGW) \
        (static_cast< LRESULT (AFX_MSG_CALL CWnd::*)(WPARAM, LPARAM) > \
        (memberFxn)) },



Above is how ON_REGISTERED_MESSAGE is defined (in VS 2005, I guess the same in VS2008) - it looks like the registered message can only be handled by a CWnd based object.  
Microsoft made numbers of changes to make the compiler more compliant to standards.
0
bobbeyAuthor Commented:
VS++ 2008 Registered Windows messages

// for Registered Windows messages
#define ON_REGISTERED_MESSAGE(nMessageVariable, memberFxn) \
      { 0xC000, 0, 0, 0, (UINT_PTR)(UINT*)(&nMessageVariable), \
            /*implied 'AfxSig_lwl'*/ \
            (AFX_PMSG)(AFX_PMSGW) \
            (static_cast< LRESULT (AFX_MSG_CALL CWnd::*)(WPARAM, LPARAM) > \
            (memberFxn))

so  what is the right approach to resolve the issue.
0
AndyAinscowFreelance programmer / ConsultantCommented:
Well, the ON_REGISTERED_MESSAGE seems to require a CWnd based object as a recipient.  So handling the message in the CFrameWnd based window is the most likely place.  (Registered messages are typically between apps and an app should have only one CMainFrame).  
In your case then call the CWinApp function you want to run directly from the frame handler.  
0
itsmeandnobodyelseCommented:
>>>> Well, the ON_REGISTERED_MESSAGE seems to require a CWnd based object as a recipient.

Andy is right. Some messages can only be handled by window classes. So choose the CMainFrame class instead of the application class to catch teh message. You easily can call an app function from there

// mainfrm.cpp

BEGIN_MESSAGE_MAP(CMainFrame, CMDIMainFrm)
   ...
   ON_REGISTERED_MESSAGE(wm_OpenNextWorkItem,      OnOpenNextWorkItem)
END_MESSAGE_MAP()

LRESULT CMainFrm::OnOpenNextWorkItem(WPARAM wp, LPARAM lp)
{
    return ((MyTestAPp*)AfxGetApp())->OnOpenNextWorkItem(wp, lp);
}




0
AndyAinscowFreelance programmer / ConsultantCommented:
I think this question is worth keeping.  Please change to accepting your comment as the solution with my comment ID#30646412 as an assist - the implementation of the macro.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Editors IDEs

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.