试图解决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 (将#修改为@)

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...