简体   繁体   English

解密将Visual C ++ 6项目升级到Visual Studio 2008中的错误

[英]Deciphering errors in upgrading a Visual C++ 6 project to Visual Studio 2008

I wanted to see if I could bring this defunct open source project called MouseTool up to date with Windows Vista. 我想看看是否可以在Windows Vista 中使这个名为MouseTool的开源项目停止工作。 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. 几年来似乎没有人碰过这个项目,因此当我在Visual Studio 2008中打开它时,会遇到很多错误。 I know very little about Visual Studio and was hoping these errors might ring a bell for someone here. 我对Visual Studio知之甚少,希望这些错误可能会给这里的人敲响钟声。 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? 给任何人敲钟?

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. 在vc6中未正确检查某些MFC事件处理程序的成员签名-在VC6中错误编译的代码需要修复才能在您使用的更新的编译器中进行编译。

The handler for an ON_MESSAGE target needs to conform to this signature: ON_MESSAGE目标的处理程序需要符合以下签名:

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

Your signature is this: 您的签名是这样的:

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

CWnd already has this member anyway: 无论如何,CWnd已经有此成员:

afx_msg void OnNcLButtonDown(UINT nHitTest, CPoint point);

Use that signature instead of your own hand rolled OnNclDown. 使用该签名代替您自己手动滚动的OnNclDown。

Edit: Use ON_WM_NCLBUTTONDOWN instead of ON_MESSAGE for OnNclButtonDown. 编辑:使用ON_WM_NCLBUTTONDOWN代替OnNclButtonDown的ON_MESSAGE。

The problem is that in the newer versions of Visual Studio, there is tighter checking on the function signatures. 问题在于,在较新版本的Visual Studio中,对函数签名的检查更加严格。 The old MFC macro code would let things slip, but they worked. 旧的MFC宏代码会让事情发生变化,但它们确实起作用。

To fix the errors, you will need to check each of the messages in the message map and change the methods to match the signature. 要修复错误,您将需要检查消息映射中的每条消息,并更改与签名匹配的方法。

Edit: WM_NCLBUTTONDOWN Notification states that it takes a WPARAM and LPARAM , which are treated as an int and a pointer to a POINTS structure. 编辑: WM_NCLBUTTONDOWN通知声明它需要WPARAMLPARAM ,它们被视为int和指向POINTS结构的指针。 So if you change the signature to use WPARAM w, LPARAM l instead of UINT, POINTS and then cast the w and l parameters to the type, it should be fine. 因此,如果将签名更改为使用WPARAM w, LPARAM l而不是UINT, POINTS ,然后 wl参数强制转换为类型,则应该没问题。

This is more about making the signatures and functions match up really than changing how they work. 这更多的是要使签名和功能真正匹配,而不是改变它们的工作方式。

I ran into the same problem, but my class that is receiving the messages is not derived from CWnd (derived from CWinThread). 我遇到了同样的问题,但是接收消息的类不是从CWnd派生的(派生自CWinThread)。

Any ideas on what what macro will let me receive a 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 one...). 编辑:永远带我去挖掘MSDN来找到它,但是对从CWinThread派生的类使用ON_THREAD_MESSAGE()(应该已经想到了这一点...)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM