BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext) 
{
// TODO: Add your specialized code here and/or call the base class
//创建一个静态分栏窗口,分为一行二列 
    if(m_wndSpliiter1.CreateStatic(this,1,2)==NULL) 
        return FALSE;     //将CCSplitterWndView连接到0行0列窗格上
    m_wndSpliiter1.CreateView(0,0,RUNTIME_CLASS(CSplitterView),CSize(600,600), pContext);     if(m_wndSpliiter1.CreateStatic(&m_wndSpliiter1,2,1,WS_CHILD|WS_VISIBLE, 
        m_wndSpliiter1.IdFromRowCol(0, 1))==NULL) 
        return FALSE; //将第0行1列再分开2行1列 
    //将FormView1类连接到第二个分栏对象的0行0列
    m_wndSplitter2.CreateView(0,0,RUNTIME_CLASS(CFormView1),CSize(200,400),pContext); 
    //将FormView2类连接到第二个分栏对象的1行0列
    m_wndSplitter2.CreateView(1,0,RUNTIME_CLASS(CFormView2),CSize(200,200),pContext); 
    return TRUE;
}
这是原码,CFormView1和FormView2是分别对应于两个不同的DIALOG的类,编译的时候显示ainFrm.obj : error LNK2001: unresolved external symbol "public: static struct CRuntimeClass const CFormView2::classCFormView2" (?classCFormView2@CFormView2@@2UCRuntimeClass@@B)
MainFrm.obj : error LNK2001: unresolved external symbol "public: static struct CRuntimeClass const CFormView1::classCFormView1" (?classCFormView1@CFormView1@@2UCRuntimeClass@@B)
Debug/splitter.exe : fatal error LNK1120: 2 unresolved externals
Error executing link.exe.
求大侠赐教,为什么错了,错在什么地方,应该如何更改?多谢!!!!!

解决方案 »

  1.   

    使用下面代码创建窗口的,CFormView1,CFormView2必须支持动态创建。你新建一个带分裂窗口的工程,看看人家的view里对DECLARE_DYNCREAT和IMPLEMENT_DYNCREAT宏的使用,你的form view里也必须有这个
    m_wndSplitter2.CreateView(0,0,RUNTIME_CLASS(CFormView1),CSize(200,400),pContext);  
      

  2.   

    你的CFormView1和CFormView2支持动态创建吗?DECLARE_DYNCREATE/IMPLEMENT_DYNCREATE
      

  3.   

    看看你的程序里有没有CSplitterView这个类,我也遇到过类似的问题,就是我的程序里没有该类,我改为程序里已用的类就好了,当然还要把头文件包含了》
      

  4.   

    在你的formview 中有没有这个 DECLARE_DYNCREATE(CFormView2)