views:

487

answers:

3

I wanted to see if I could bring this defunct open source project called MouseTool up to date with Windows Vista. It's a dwell-clicker to help people (like myself) who experience pain when they click the mouse. This software simulates a click when the mouse pauses at a location on the screen.

It seems like no one has touched this project in a few years so when I open it up in Visual Studio 2008, I get a ton of errors. I know very little about Visual Studio and was hoping these errors might ring a bell for someone here. Any tips that someone could provide on how I might go about starting to address some of these errors would be appreciated.

To excerpt an example, this error . . .

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

. . . corresponds to 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()

Ring a bell for anyone?

+3  A: 

The member signatures for certain MFC event handlers were not properly checked in vc6 - code that compiled in error in VC6 needs to be fixed to compile in the updated compiler you are using.

The handler for an ON_MESSAGE target needs to conform to this signature:

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

Your signature is this:

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

CWnd already has this member anyway:

afx_msg void OnNcLButtonDown(UINT nHitTest, CPoint point);

Use that signature instead of your own hand rolled OnNclDown.

Edit: Use ON_WM_NCLBUTTONDOWN instead of ON_MESSAGE for OnNclButtonDown.

sean e
+1  A: 
crashmstr
Ok. So, for example, with this one: ON_MESSAGE( WM_NCLBUTTONDOWN, OnNCLDown ), I assume you mean it needs to match the signature: 'LRESULT (__thiscall CWnd::* )(WPARAM,LPARAM)', just as the error message says. Any suggestion on how to do that specifically?
A: 

I ran into the same problem, but my class that is receiving the messages is not derived from CWnd (derived from CWinThread).

Any ideas on what what macro will let me receive a message?

Thanks in advance!

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 one...).

RunOfTheShipe