--------------------Configuration: gps - Win32 Debug--------------------
Compiling...
gpsView.cpp
C:\Documents and Settings\Fantasy\My Documents\作业\comm\gps\gpsView.cpp(23) : error C2440: 'type cast' : cannot convert from 'void (__thiscall CGpsView::*)(unsigned int,class CPoint)' to 'void (__thiscall CCmdTarget::*)(struct tagNMHDR *,long *)'
        Pointers to members have different representations; cannot cast between them
Error executing cl.exe.
Creating browse info file...gps.exe - 1 error(s), 0 warning(s)错误指向的代码是ON_NOTIFY(NM_RCLICK, IDC_LIST_GPS, OnRclickListGps)
这是我右键单击一formview中listctrl控件的事件.
我是按正确步骤加如消息的,为什么会出现这种错误?不懂,望大家指点!!1谢谢!~!!

解决方案 »

  1.   

    无法从“type1”转换为“type2”
    由于不兼容的调用约定而产生的 C2440
      

  2.   

    protected:
    //{{AFX_MSG(CGpsView)
    afx_msg void OnRclickListGps(UINT nFlags, CPoint point);
    //}}AFX_MSG
    DECLARE_MESSAGE_MAP()
    DECLARE_DYNAMIC_MAP()
    IMPLEMENT_DYNCREATE(CGpsView, cdxCDynamicFormView)BEGIN_MESSAGE_MAP(CGpsView, cdxCDynamicFormView)
    //{{AFX_MSG_MAP(CGpsView)
    // ON_NOTIFY(NM_RCLICK, IDC_LIST_GPS, OnRclickListGps)
    //}}AFX_MSG_MAP
    END_MESSAGE_MAP()BEGIN_DYNAMIC_MAP(CGpsView, cdxCDynamicFormView)
    DYNAMIC_MAP_ENTRY(IDC_LIST_GPS,mdResize,mdResize)
    // DYNAMIC_MAP_ENTRY(IDC_TREE_COMBO,mdResize,mdNone)
    END_DYNAMIC_MAP()void CGpsView::OnRclickListGps(UINT nFlags, CPoint point) 
    {
    GetCursorPos(&point);
    CMenu*pPopMenu=new CMenu;
    pPopMenu->LoadMenu(IDR_RIGHTBUTTON_MENU);
    CMenu*pFileMenu=pPopMenu->GetSubMenu(0); CGpsDoc *pDoc=GetDocument();
        if( pDoc->m_bAuoMenuEnable)
        {
    pFileMenu->EnableMenuItem(ID_FILE_DOWNLOAD, MF_GRAYED);
    pFileMenu->EnableMenuItem(ID_FLASH_DELETE, MF_GRAYED);
    pFileMenu->EnableMenuItem(ID_FILE_DOWNLOAD_ZHD, MF_GRAYED);
    pFileMenu->EnableMenuItem(ID_FLASH_ERASE, MF_GRAYED);
    pFileMenu->EnableMenuItem(ID_FLASH_RECOVER, MF_GRAYED);
    pFileMenu->EnableMenuItem(ID_FLASH_REFRESH, MF_GRAYED);
        }
        pFileMenu->TrackPopupMenu(TPM_LEFTALIGN|TPM_RIGHTBUTTON,point.x,point.y,this);
    delete pPopMenu;}
      

  3.   

    From MSDN:ON_NOTIFY( wNotifyCode, id, memberFxn )where the italicized parameters are replaced with:wNotifyCodeThe code for the notification message to be handled, such as LVN_KEYDOWN.idThe child identifier of the control for which the notification is sent.memberFxnThe member function to be called when this notification is sent.Your member function must be declared with the following prototype:afx_msg void memberFxn( NMHDR * pNotifyStruct, LRESULT * result );where the italicized parameters are:就是说你的消息函数的声明格式不对。你应该声明称MSDN里的形式,然后由pNotifyStruct得到鼠标的位置。