Decoding errors when upgrading a Visual C ++ 6 project to Visual Studio 2008

I wanted to see if I could bring this existing open source project called MouseTool to Windows Vista. This is a mouse click to help people (like me) who are in pain when they click on the mouse. This software simulates a click when the mouse stops at a location on the screen.

It seems that no one has touched this project in a few years, so when I open it in Visual Studio 2008 I get tons of errors. I know very little about Visual Studio and was hoping these errors might trigger a call for someone here. Any hints someone could provide on how I might get started with some of these errors would be appreciated.

To extract an example, this error ...

Error   18  error C2440: 'static_cast' : 
cannot convert from 'void (__thiscall COptionsSheet::* )(UINT,POINTS)' 
to 'LRESULT (__thiscall CWnd::* )(WPARAM,LPARAM)'   

      

., matches this line:

ON_MESSAGE( WM_NCLBUTTONDOWN,   OnNCLDown )

      

from this block:

BEGIN_MESSAGE_MAP(COptionsSheet, CPropertySheet)
    //{{AFX_MSG_MAP(COptionsSheet)
    ON_WM_HELPINFO()
    ON_WM_MOUSEMOVE()
    ON_WM_SETCURSOR()
    //}}AFX_MSG_MAP
    ON_MESSAGE( WM_NCLBUTTONDOWN,   OnNCLDown )
    ON_MESSAGE( WM_NCLBUTTONUP,     OnNCLUp )
    ON_BN_CLICKED(ID_HELP, OnHelpButton)
END_MESSAGE_MAP()

      

A bell ring for everyone?

0


a source to share


3 answers


Item signatures for certain MFC event handlers have not been validated correctly in vc6 - code that is compiled in error in VC6 must be fixed in order to compile with the updated compiler you are using.

The handler for the ON_MESSAGE target must match this signature:

afx_msg LRESULT (CWnd::*)(WPARAM, LPARAM).

      

Your signature is like this:

void (COptionsSheet::* )(UINT,POINTS)

      



CWnd already has this element:

afx_msg void OnNcLButtonDown(UINT nHitTest, CPoint point);

      

Use this signature instead of your own rollable OnNclDown.

Edit: Use ON_WM_NCLBUTTONDOWN instead of ON_MESSAGE for OnNclButtonDown.

+3


a source


The problem is that newer versions of Visual Studio have stricter validation of function signatures. The old MFC macros allowed things to slide, but they worked.

To fix the errors, you will need to check each message on the message map and change the methods to match the signature.



Edit: The notice states that it is required and which are treated as an int and a pointer to a POINTS structure. So if you change the signature to use instead and then cast the parameters and for the type, that should be fine. WM_NCLBUTTONDOWN

WPARAM

LPARAM

WPARAM w, LPARAM l

UINT, POINTS

w

l

It's more like captions and functions are true to reality rather than changing how they work.

+1


a source


I faced the same problem, but my class receiving messages is not received from CWnd (derived from CWinThread).

Any ideas on which macro will allow me to receive the message?

Edit: Took me forever to dig through MSDN to find this, but use ON_THREAD_MESSAGE () for classes derived from CWinThread (should have figured this out ...).

0


a source







All Articles