头文件代码:
class CDiskView : public CView
{
DECLARE_DYNCREATE(CDiskView)
private:
static COLORREF rgbColor[2];
static CString strType[];
void GetLabel(CString * str,double e,PCSTR strTail);
protected:
afx_msg void OnMemoryUpdate(CCmdUI *pCmdUI);
afx_msg void OnDiskUpdate(CCmdUI *pCmdUI);
virtual void OnDraw(CDC * pDC);  
DECLARE_MAESSAGE_MAP();
};.cpp部分代码:
COLORREF CDiskView::rgbColor[2]={Mem_Color,Disk_Color};
CString CDiskView::strType[] = {"Memory","Fixed Disk","Remote Disk","RAM Disk"}; IMPLEMENT_DYNCREATE(CDiskView,CView)BEGIN_MESSAGE_MAP(CDiskView,CView)
    ON_UPDATE_COMMAND_UI(ID_Memory,OnMemoryUpdate)
ON_UPDATE_COMMAND_UI_RANGE(IDM_Disk_C,IDM_Disk_E,OnDiskUpdate)
END_MESSAGE_MAP()
错误信息:
1.error C2509: '_GetBaseMessageMap' : member function not declared in 'CDiskView'
        d:\测试各类用法程序\vc\diskpie\diskview.h(3) : see declaration of 'CDiskView'
2.error C2509: 'GetMessageMap' : member function not declared in 'CDiskView'
        d:\测试各类用法程序\vc\diskpie\diskview.h(3) : see declaration of 'CDiskView'
3.warning C4273: 'protected: static struct AFX_MSGMAP const CView::messageMap' : inconsistent dll linkage.  dllexport assumed.
4.error C2491: 'CDiskView::CView::messageMap' : definition of dllimport static data member not allowed
5.error C2248: 'OnMemoryUpdate' : cannot access protected member declared in class 'CDiskView'
6.error C2248: 'OnDiskUpdate' : cannot access protected member declared in class 'CDiskView'

解决方案 »

  1.   

    说你这两个函数GetBaseMessageMap,GetMessageMap没定义,你在哪用的这两个函数啊?
      

  2.   

    把afx_msg void OnMemoryUpdate(CCmdUI *pCmdUI);
     和afx_msg void OnDiskUpdate(CCmdUI *pCmdUI);
    拷贝到public下试试看
      

  3.   

    to 风小云 : 拷贝到public下也不行.
    代码不是用向导生成的.
    我也没用 GetBaseMessageMap,GetMessageMap 函数.
      

  4.   

    1、双击错误信息,看看跳到哪里了?(这时会自动跳到使用GetBaseMessageMap或GetMessageMap 函数函数的地方);
    2、把你的“protected:”去掉吧
      

  5.   

    to 改头换面:
      1.双击会跳到 BEGIN_MESSAGE_MAP() 行.
      2.去掉"protected:",错误依旧.
     他的定义与别的头文件中的定义没什么区别,别处没错,为什么这个文件就编译不过去呢?
      

  6.   

    把这些东西尽可能放前放。IMPLEMENT_DYNCREATE(CDiskView,CView)BEGIN_MESSAGE_MAP(CDiskView,CView)
        ON_UPDATE_COMMAND_UI(ID_Memory,OnMemoryUpdate)
    ON_UPDATE_COMMAND_UI_RANGE(IDM_Disk_C,IDM_Disk_E,OnDiskUpdate)
    END_MESSAGE_MAP()把这些定义都放在 END_MESSAGE_MAP() 后面COLORREF CDiskView::rgbColor[2]={Mem_Color,Disk_Color};
    CString CDiskView::strType[] = {"Memory","Fixed Disk","Remote Disk","RAM Disk"};
      

  7.   

    头文件里这句写错了,哈哈
    DECLARE_MESSAGE_MAP()