微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

试图解决MFC BEGIN_EVENT_MAP编译时错误

如何解决试图解决MFC BEGIN_EVENT_MAP编译时错误

我正在将VC ++ 6.0项目转换为Visual Studio2013。遇到此错误

error C2440: cannot convert from const AFX_EVENTMAP *(__thiscall CCmdTargetEx::* )(void) const' to 'const AFX_EVENTMAP *(__stdcall *)(void)'

这是我的代码

BEGIN_EVENT_MAP(CdispatchAccount,CCmdTargetEx) //error locate in here
//{{AFX_EVENT_MAP(CdispatchAccount)
EVENT_CUSTOM( "SetFocus",FireSetFocus,VTS_NONE )
EVENT_CUSTOM( "KillFocus",FireKillFocus,VTS_NONE )
EVENT_CUSTOM( "Tab",FireTab,VTS_NONE )
EVENT_CUSTOM( "EditFull",FireEditFull,VTS_NONE )
EVENT_CUSTOM( "EditEnter",FireEditEnter,VTS_NONE )
EVENT_CUSTOM( "ListSelChanged",FireListSelChanged,VTS_I2   )
EVENT_CUSTOM( "ChangeAccount",FireChangeAccount,VTS_NONE )
EVENT_CUSTOM( "DropDown",FireDropDown,VTS_I2   )
EVENT_CUSTOM( "MSRReceived",FireMSRReceived,VTS_BSTR VTS_BOOL VTS_PVARIANT)
EVENT_CUSTOM( "EmplEditFull",FireEmplEditFull,VTS_NONE )
//}}AFX_EVENT_MAP 
END_EVENT_MAP()

这是我的标题

#ifdef  __BASECLASS_DLL
   #define  __CMDTARGET_API __declspec(dllexport)
#elif _FORMMNGR_DLL
   #define  __CMDTARGET_API 
#elif _DATAMNGR_DLL
    #define __CMDTARGET_API
#elif _CONTROL_DLL  
    #define __CMDTARGET_API __declspec(dllimport)
#else
    #define __CMDTARGET_API
#endif  // __BASECLASS_DLL


class __CMDTARGET_API CCmdTargetEx : public CCmdTarget
{
   DECLARE_DYNCREATE(CCmdTargetEx)

   public:
          CCmdTargetEx();           // protected constructor used by dynamic 
   creation
          virtual ~CCmdTargetEx();

   // Attributes
    protected:
           const IID    *m_piidEvents;  // IID for control events
           const IID    *m_piidPrimary; // IID for primary idispatch
           DWORD        m_dwEventSink;
           CWnd        *m_pContainer;
           UINT         m_nCtrlID;

   // Operations
   public:
          void      AFX_CDECL FireEvent(disPID dispid,BYTE* pbParams,...);
          BOOL      GetdispatchIID(IID *pIID);
          virtual   HRESULT GetClassID(LPCLSID pclsid);
          void      ConnectSinkSelf(CWnd *pContainer,UINT nCtlID=-1);
          void      disconnectSinkSelf();

  // Overrides
 // ClassWizard generated virtual function overrides
 //{{AFX_VIRTUAL(CCmdTargetEx)
   public:
         virtual void OnFinalRelease();
//}}AFX_VIRTUAL

// Implementation
protected:

BOOL    OnEvent(AFX_EVENT* pEvent);

// Events
virtual const AFX_EVENTMAP *GetEventMap() const;
virtual const AFX_EVENTMAP *GetThisEventMap() const;
static const AFX_DATA AFX_EVENTMAP_ENTRY _eventEntries[];
static const AFX_DATA AFX_EVENTMAP eventMap;
const AFX_EVENTMAP_ENTRY *GetEventMapEntry(LPCTSTR pszName,disPID *pdispid) const;
void FireEventV(disPID dispid,BYTE *pbParams,va_list argList);

// Generated message map functions
//{{AFX_MSG(CCmdTargetEx)
    // NOTE - the ClassWizard will add and remove member functions here.
//}}AFX_MSG

DECLARE_MESSAGE_MAP()
// Generated OLE dispatch map functions
//{{AFX_disPATCH(CCmdTargetEx)
    // NOTE - the ClassWizard will add and remove member functions here.
//}}AFX_disPATCH
DECLARE_disPATCH_MAP()
DECLARE_INTERFACE_MAP()

// Connection point container
virtual LPCONNECTIONPOINT GetConnectionHook(REFIID iid);
virtual BOOL GetExtraConnectionPoints(CPtrArray *pConnPoints);

// Connection point for events - from COleControl
BEGIN_CONNECTION_PART(CCmdTargetEx,EventConnPt)
    virtual void OnAdvise(BOOL bAdvise);
    virtual REFIID GetIID();
    virtual LPUNKNowN QuerySinkInterface(LPUNKNowN pUnkSink);
END_CONNECTION_PART(EventConnPt)

BEGIN_INTERFACE_PART(EventSink,Idispatch)
    INIT_INTERFACE_PART(COleControlSite,EventSink)
    STDMETHOD(GetTypeInfoCount)(unsigned int*);
    STDMETHOD(GetTypeInfo)(unsigned int,LCID,ITypeInfo**);
    STDMETHOD(GetIDsOfNames)(REFIID,LPOLESTR*,unsigned int,disPID*);
    STDMETHOD(Invoke)(disPID,REFIID,unsigned short,disPParaMS*,VARIANT*,EXCEPINFO*,unsigned int*);
END_INTERFACE_PART(EventSink)

// IProvideClassInfo2
BEGIN_INTERFACE_PART(ProvideClassInfo,IProvideClassInfo2)
    INIT_INTERFACE_PART(COleControl,ProvideClassInfo)
    STDMETHOD(GetClassInfo)(LPTYPEINFO *ppTypeInfo);
    STDMETHOD(GetGUID)(DWORD dwGuidKind,GUID *pGUID);
END_INTERFACE_PART(ProvideClassInfo)
};

此声明CdispatchAccount

class CCtlAccount;
class CdispatchAccount : public CCmdTargetEx
{
    DECLARE_DYNCREATE( CdispatchAccount )
    DECLARE_OLETYPELIB( CdispatchAccount ) 

public:
    CdispatchAccount();           // protected constructor used by dynamic creation

// Attributes
public:
    CCtlAccount*        m_pConnObj;

// Operations
public:
    void    SetConnObject   ( CCtlAccount* pConnObj ) { m_pConnObj = pConnObj; }
    HRESULT GetClassID      ( LPCLSID pclsid );


// Overrides
    // ClassWizard generated virtual function overrides
    //{{AFX_VIRTUAL(CdispatchAccount)
    public:
    virtual void OnFinalRelease();
    //}}AFX_VIRTUAL

// Implementation
protected:
    virtual ~CdispatchAccount();

    // Generated message map functions
    //{{AFX_MSG(CdispatchAccount)
        // NOTE - the ClassWizard will add and remove member functions here.
    //}}AFX_MSG

    DECLARE_MESSAGE_MAP()
    // Generated OLE dispatch map functions
    //{{AFX_disPATCH(CdispatchAccount)
    afx_msg BOOL GetBranchCodeHide();
    afx_msg void SetBranchCodeHide(BOOL nNewValue);
    afx_msg short GetBorder();
    afx_msg void SetBorder(short nNewValue);
    afx_msg BOOL GetBranchCodeAuto();
    afx_msg void SetBranchCodeAuto(BOOL nNewValue);
    afx_msg BSTR GetItemCodeDefault();
    afx_msg void SetItemCodeDefault(LPCTSTR lpszNewValue);
    afx_msg short GetInputDevice();
    afx_msg void SetInputDevice(short nNewValue);
    afx_msg long GetItemCodeType();
    afx_msg void SetItemCodeType(long nNewValue);
    afx_msg BSTR GetAccNameCtl();
    afx_msg void SetAccNameCtl(LPCTSTR lpszNewValue);
    afx_msg BSTR GetAccPwdCtl();
    afx_msg void SetAccPwdCtl(LPCTSTR lpszNewValue);
    afx_msg BOOL GetAddTrustAccount();
    afx_msg void SetAddTrustAccount(BOOL nNewValue);
    afx_msg BOOL GetAutoNextFocus();
    afx_msg void SetAutoNextFocus(BOOL nNewValue);
    afx_msg BOOL GetUseHistory();
    afx_msg void SetUseHistory(BOOL nNewValue);
    afx_msg BOOL GetRequireinput();
    afx_msg void SetRequireInput(BOOL nNewValue);
    afx_msg long GetHeight();
    afx_msg void SetHeight(long nNewValue);
    afx_msg long GetWidth();
    afx_msg void SetWidth(long nNewValue);
    afx_msg BOOL GetEnabled();
    afx_msg void SetEnabled(BOOL bNewValue);
    afx_msg BSTR GetCaption();
    afx_msg void SetCaption(LPCTSTR lpszNewValue);
    afx_msg OLE_COLOR GetBackColor();
    afx_msg void SetBackColor(OLE_COLOR nNewValue);
    afx_msg OLE_COLOR GetForeColor();
    afx_msg void SetForeColor(OLE_COLOR nNewValue);
    afx_msg BOOL GetVisible();
    afx_msg void SetVisible(BOOL bNewValue);
    afx_msg BSTR GetLinkinformation();
    afx_msg void SetLinkinformation(LPCTSTR lpszNewValue);
    afx_msg BSTR GetHelpMessage();
    afx_msg void SetHelpMessage(LPCTSTR lpszNewValue);
    afx_msg short GetLeft();
    afx_msg void SetLeft(short nNewValue);
    afx_msg short GetTop();
    afx_msg void SetTop(short nNewValue);
    afx_msg short GetinitSelect();
    afx_msg void SetinitSelect(short nNewValue);
    afx_msg short InitaccCombo(LPCTSTR strInitValue);
    afx_msg void EditFullCaption(LPCTSTR strCaption);
    afx_msg void ResetContent();
    afx_msg short AddRow(LPCTSTR strAccount);
    afx_msg short InsertRow(LPCTSTR strAccount,short iIndex);
    afx_msg void DeleteRow(short iIndex);
    afx_msg short GetCurSel();
    afx_msg void SetCurSel(short iIndex);
    afx_msg BSTR GetFirstCode();
    afx_msg BSTR GetMidCode();
    afx_msg short GetTotalRow();
    afx_msg void Sort(short bSortFlag);
    afx_msg void SetFocus();
    afx_msg BOOL UpdateFromMemory(const VARIANT FAR& DataArray);
    afx_msg BSTR GetAccountByIndex( short iIndex );
    afx_msg BOOL IsSupportedAgreementAccount(LPCTSTR    lpszAccount,long nAgreement);
    afx_msg void SetTotalTradeAccountdisplayFlag(BOOL bIsdisplay);
    afx_msg void IsLoadAllAccounts(BOOL bIsLoadAllAccounts);
    afx_msg long GetAccountCtrlType(void);
    afx_msg void SetAccountCtrlType(long lCtrlType);
    afx_msg BOOL GetReadOnly();
    afx_msg void SetReadOnly(BOOL bReadOnly);
    
    afx_msg BSTR GetProductCode();
    afx_msg BSTR GetBranchCode();
    afx_msg BOOL SetMSRHeaderClear();
    afx_msg short GetAccIsCmsn(LPCTSTR strAccount);

    //}}AFX_disPATCH
    DECLARE_disPATCH_MAP()
    DECLARE_INTERFACE_MAP()

public:
    enum
    {
    //{{AFX_disP_ID(CdispatchAccount)
    dispidBranchCodeHide = 1L,dispidBorder = 2L,dispidBranchCodeAuto = 3L,dispidItemCodeDefault = 4L,dispidInputDevice = 5L,dispidItemCodeType = 6L,dispidAccNameCtl = 7L,dispidAccPwdCtl = 8L,dispidAddTrustAccount = 9L,dispidAutoNextFocus = 10L,dispidUseHistory = 11L,dispidRequireInput = 12L,dispidLeft = 13L,dispidTop = 14L,dispidHeight = 15L,dispidWidth = 16L,dispidEnabled = 17L,dispidVisible = 18L,dispidCaption = 19L,dispidBackColor = 20L,dispidForeColor = 21L,dispidLinkinformation = 22L,dispidHelpMessage = 23L,dispidInitSelect = 24L,dispidReadOnly = 50L,dispidInitaccCombo = 25L,dispidEditFullCaption = 26L,dispidResetContent = 27L,dispidAddRow = 28L,dispidInsertRow = 29L,dispidDeleteRow = 30L,dispidGetCurSel = 31L,dispidSetCurSel = 32L,dispidGetFirstCode = 33L,dispidGetMidCode = 34L,dispidGetTotalRow = 35L,dispidSort = 36L,dispidSetFocus = 37L,dispidUpdateFromMemory = 38L,dispidGetAccountByIndex = 39L,dispidisSupportedAgreementAccount = 40L,dispidSetTotalTradeAccountdisplayFlag = 41L,dispidisLoadAllAccounts = 42L,dispidGetAccountCtrlType = 43L,dispidSetAccountCtrlType = 44L,dispidGetProductCode = 45L,dispidGetBranchCode = 46L,dispidSetMSRHeaderClear = 47L,dispidGetAccIsCmsn = 48L,eventidSetFocus = 1L,eventidKillFocus = 2L,eventidTab = 3L,eventidEditFull = 4L,eventidEditEnter = 5L,eventidListSelChanged = 6L,eventidChangeAccount = 7L,eventidDropDown = 8L,eventidMSRReceived = 9L,eventidEmplEditFull = 10L,//}}AFX_disP_ID
    };

    // Event maps
    //{{AFX_EVENT(CdispatchAccount)
    void FireSetFocus()
        {FireEvent(eventidSetFocus,EVENT_ParaM(VTS_NONE));}
    void FireKillFocus()
        {FireEvent(eventidKillFocus,EVENT_ParaM(VTS_NONE));}
    void FireTab()
        {FireEvent(eventidTab,EVENT_ParaM(VTS_NONE));}
    void FireEditFull()
        {FireEvent(eventidEditFull,EVENT_ParaM(VTS_NONE));}
    void FireEditEnter()
        {FireEvent(eventidEditEnter,EVENT_ParaM(VTS_NONE));}
    void FireListSelChanged(short iIndex)
        {FireEvent(eventidListSelChanged,EVENT_ParaM(VTS_I2),iIndex);}
    void FireChangeAccount()
        {FireEvent(eventidChangeAccount,EVENT_ParaM(VTS_NONE));}
    void FireDropDown(short bListShow)
        {FireEvent(eventidDropDown,bListShow);}
    void FireMSRReceived(LPCTSTR    lpszAccount,BOOL bIsOldWooriCard,VARIANT FAR* pvarCancelFlag)
        {FireEvent(eventidMSRReceived,EVENT_ParaM(VTS_BSTR VTS_BOOL VTS_PVARIANT),lpszAccount,bIsOldWooriCard,pvarCancelFlag);}
    void FireEmplEditFull()
        {FireEvent(eventidEmplEditFull,EVENT_ParaM(VTS_NONE));}
    //}}AFX_EVENT

    DECLARE_EVENT_MAP()

};

我尝试更改为静态void,但仍然收到此错误

我不知道是什么原因导致此错误,导致在VC ++ 6.0中成功编译而没有错误 错误显示在BEGIN_EVENT_MAP行上。

我已经搜索了一下,无法解决。有人做过这种事吗?还是我的代码有错

谢谢

PS:对不起,我的英语

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。