为何我无法在静态拆分窗口中加入CFormView派生的类?!
编译可以通过,但无法运行!
在CMainFrame::OnCreateClient中VERIFY(m_wndSplitter.CreateView(0,0,RUNTIME_CLASS(COptionView)CSize(100,100),pContext));S.P. COptionView是CFormView的派生类。谢谢:)

解决方案 »

  1.   

    以下是完整的OnCreateClient代码:BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext) 
    {
    // TODO: Add your specialized code here and/or call the base class
        VERIFY(m_wndSplitter.CreateStatic(this, 1, 2));
        VERIFY(m_wndSplitter.CreateView(0, 0, RUNTIME_CLASS(CConView),
                                        CSize(100, 100), pContext));
        VERIFY(m_wndSplitter.CreateView(0, 1, RUNTIME_CLASS(CVacanView),
                                        CSize(100, 100), pContext));
        return TRUE;

    //return CFrameWnd::OnCreateClient(lpcs, pContext);
    }S.P. CConView是CFormView的派生类。
    如果把CConView换成CVacanView就没问题。
      

  2.   

    BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext) 
    {
    // TODO: Add your specialized code here and/or call the base class
    if(!m_wndSplitter.CreateStatic(this,1,2))return FALSE;
    if(!m_wndSplitter.CreateView(0,0,RUNTIME_CLASS(CLeftView),CSize(200,0),pContext))return FALSE;
    if(!m_wndSplitter.CreateView(0,1,RUNTIME_CLASS(CMyForm),CSize(0,0),NULL))return FALSE;
    m_wndSplitter.RecalcLayout(); return TRUE;
    return CFrameWnd::OnCreateClient(lpcs, pContext);
    }
      

  3.   

    这是我的代码,完全没有问题,CMyForm派生自CFormView.
    你设断点跟踪你的这句看看为什么会出错,或者重新开一个工程试试。
    m_wndSplitter.CreateView(0, 0, RUNTIME_CLASS(CConView),
                                        CSize(100, 100), pContext));
      

  4.   

    谢谢恢复:)
    但问题依然存在,我进行了DEBUG,我想问题应该还是出在CFormView的派生类上。错误代码如下:
    ERROR: Dialog with IDD 0x0082 must have the child style.
    Loaded 'C:\Program Files\Logitech\MouseWare\system\LGMOUSHK.DLL', no matching symbolic information found.
    Detected memory leaks!
    Dumping objects ->
    C:\PROJECT\VC\OPENGL\Vacan\ConView.cpp(17) : {96} client block at 0x00302DA0, subtype 0, 128 bytes long.
    a CConView object at $00302DA0, 128 bytes long
    {95} normal block at 0x00302E50, 12 bytes long.
     Data: <            > 00 00 00 00 00 00 00 00 FF FF FF FF 
    {94} normal block at 0x00301030, 24 bytes long.
     Data: <                > 00 00 00 00 FA 00 00 00 FF FF FF FF 00 00 00 00 
    strcore.cpp(118) : {90} normal block at 0x00301080, 18 bytes long.
     Data: <            Vaca> 01 00 00 00 05 00 00 00 05 00 00 00 56 61 63 61 
    strcore.cpp(118) : {89} normal block at 0x003010C0, 80 bytes long.
     Data: <    C   C   Vaca> 01 00 00 00 43 00 00 00 43 00 00 00 56 61 63 61 
    C:\PROJECT\VC\OPENGL\Vacan\MainFrm.cpp(21) : {88} client block at 0x00301140, subtype 0, 680 bytes long.
    a CMainFrame object at $00301140, 680 bytes long
    C:\PROJECT\VC\OPENGL\Vacan\VacanDoc.cpp(18) : {87} client block at 0x00301420, subtype 0, 84 bytes long.
    a CVacanDoc object at $00301420, 84 bytes long
    plex.cpp(31) : {72} normal block at 0x003014A0, 124 bytes long.
     Data: <              0 > 00 00 00 00 00 00 00 00 00 00 00 00 20 16 30 00 
    {71} client block at 0x00301550, subtype 0, 32 bytes long.
    a CDocManager object at $00301550, 32 bytes long
    strcore.cpp(118) : {70} normal block at 0x003015A0, 80 bytes long.
     Data: <    C   C   Vaca> 01 00 00 00 43 00 00 00 43 00 00 00 56 61 63 61 
    C:\PROJECT\VC\OPENGL\Vacan\Vacan.cpp(76) : {69} client block at 0x00301620, subtype 0, 108 bytes long.
    a CSingleDocTemplate object at $00301620, 108 bytes long
    strcore.cpp(118) : {67} normal block at 0x003016C0, 19 bytes long.
     Data: <            File> 01 00 00 00 06 00 00 00 06 00 00 00 46 69 6C 65 
    strcore.cpp(118) : {66} normal block at 0x00301700, 29 bytes long.
     Data: <            Rece> 01 00 00 00 10 00 00 00 10 00 00 00 52 65 63 65 
    {65} normal block at 0x00301750, 20 bytes long.
     Data: <      L_  L_  L_> 04 00 00 00 14 CB 4C 5F 14 CB 4C 5F 14 CB 4C 5F 
    {64} normal block at 0x00301790, 32 bytes long.
     Data: << K_    T 0   0 > 3C 8D 4B 5F 04 00 00 00 54 17 30 00 0C 17 30 00 
    Object dump complete.
    The thread 0x13E8 has exited with code 3 (0x3).
    The program 'C:\PROJECT\VC\OPENGL\Vacan\Debug\Vacan.exe' has exited with code 3 (0x3).
      

  5.   

    你的派生类资源模板中,没有child风格。要设为child!!