本文介绍了MFC dlg类链接错误为MyClass :: GetMessageMap()和MyClass :: GetRuntimeClass(MSVC 2008)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我复制了dlg框类(使用dlg类向导/ mfc向导创建)的现有头。所有似乎都很好,直到我添加了cpp文件到项目。现在我得到奇怪的链接错误一些mfc魔术方法:

I copied an existing header for a dlg box class (created with the dlg class wizard/mfc wizard). All seemed to go fine until I added the cpp file to the project. Now i get odd link errors for some mfc magic methods:

错误LNK2001:未解析的外部
符号protected:virtual struct
AFX_MSGMAP const * __thiscall
DlgGapWindow :: GetMessageMap(void)const

GetMessageMap @ DlgGapWindow @@ MBEPBUAFX_MSGMAP @@ XZ)

error LNK2001: unresolved external symbol "protected: virtual struct AFX_MSGMAP const * __thiscall DlgGapWindow::GetMessageMap(void)const " (?GetMessageMap@DlgGapWindow@@MBEPBUAFX_MSGMAP@@XZ)

为什么会这样?

以下是标题中的相关代码

Here is the relevant code in the header

class DlgGapWindow : public CDialog
{
    DECLARE_DYNAMIC(DlgGapWindow)

public:

    DlgGapWindow(CWnd* pParent = NULL);

    virtual ~DlgGapWindow();
    virtual BOOL PreTranslateMessage(MSG* pMsg);


protected:
    virtual BOOL OnInitDialog();
    enum { IDD = IDD_DIALOG_GAP_VIEW };// Dialog Data

    GapViewer m_chart;

protected:
    virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support

    afx_msg void OnSize(UINT nType, int cx, int cy);
    afx_msg void OnSizing(UINT fwSide, LPRECT pRect) ;
    afx_msg void OnTimer(ONTIMER_TYPE nIDEvent);
    afx_msg void OnDestroy();
    afx_msg void OnClose();
    afx_msg void OnActivate(UINT,CWnd *,BOOL);
    afx_msg void OnRButtonDown(UINT nFlags, CPoint point);
    afx_msg void OnLButtonDblClk(UINT nFlags, CPoint point);

    DECLARE_MESSAGE_MAP()

};

我没有看到类中的任何东西,我没有发现任何有用的谷歌或其他搜索,以指示为什么这些魔法mfc的东西丢失。我的其他类不明确定义它们,他们没有错误。

I don't see anything from the class I modeled it after that seems to be missing. I have not found anything useful with google or other searches to indicate why these magic mfc things are missing. My other classes don't explicitly define them and they don't have errors.

RC文件有相应的dlg定义。

The RC file does have a corresponding dlg definition.

编辑:

感谢DECLARE_DYNAMIC帮助 - 现在我没有GetRuntimClass()错误 - 只是GetMessagemap()错误。

Thanks for the DECLARE_DYNAMIC help - now I do not have the GetRuntimClass() error - just the GetMessagemap() error.

推荐答案

您使用了DECLARE_DYNAMIC,但忘记了。

You used DECLARE_DYNAMIC but forgot IMPLEMENT_DYNAMIC.

这篇关于MFC dlg类链接错误为MyClass :: GetMessageMap()和MyClass :: GetRuntimeClass(MSVC 2008)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-06 19:47