项目名称是TEST,想将窗口分割成两个,左边是树状目录CTreeView类,右边用来画图,是一般的view类
在OnCreateClient函数中加上:
BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT lpcs,CCreateContext* pContext)
{
splitter.CreateStatic(this,1,);
splitter.CreateView(0,0,RUNTIME_CLASS(CTreeView),CSize(2000,100),pContext);
splitter.CreateView(0,1,RUNTIME_CLASS(CEMCView),CSize(0,100),pContext);
return true;
}
这样运行时有问题中断:
EMC.exe 中的 0x725c3a66 处未处理的异常: 0xC0000005: 读取位置 0x725c3a66 时发生访问冲突如果把中间两行改为:
splitter.CreateView(0,0,RUNTIME_CLASS(CEMCView),CSize(2000,100),pContext);
splitter.CreateView(0,1,RUNTIME_CLASS(CTreeView),CSize(0,100),pContext);这样就没有问题。
请问为什么呢?
这样树状目录就只能在屏幕的右边了,可是我需要把树状目录放在屏幕左边,这样该怎么实现呢?

解决方案 »

  1.   

    修改BOOL CTESTApp::InitInstance()

    pDocTemplate = new CSingleDocTemplate(
    IDR_MAINFRAME,
    RUNTIME_CLASS(CTESTDoc),
    RUNTIME_CLASS(CMainFrame),       // 主 SDI 框架窗口
    RUNTIME_CLASS(CTESTView)
    );
    改为
    pDocTemplate = new CSingleDocTemplate(
    IDR_MAINFRAME,
    RUNTIME_CLASS(CTESTDoc),
    RUNTIME_CLASS(CMainFrame),       // 主 SDI 框架窗口
    NULL);
      

  2.   

    splitter.CreateStatic(this,1,);
    这个能编译通过吗
      

  3.   

    哦,贴错了,呵呵
    splitter.CreateStatic(this,1,2);
    但是错误不是这个问题。
      

  4.   


    BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext) 
    {
    // TODO: Add your specialized code here and/or call the base class
    splitter.CreateStatic(this,1, 2);
    // CNewTreeView派生自CTreeView类
    // CEMCView派生自CView类
    splitter.CreateView(0,0,RUNTIME_CLASS(CNewTreeView),CSize(200,100),pContext);
    splitter.CreateView(0,1,RUNTIME_CLASS(CEMCView),CSize(0,100),pContext); return TRUE;
     
    // return CFrameWnd::OnCreateClient(lpcs, pContext);
    }
      

  5.   

    to VisualEleven 感觉这个跟我的没什么区别呀
      

  6.   

    你看看InitInstance()
    建议还是调试一下!
      

  7.   

    splitter.CreateView(0,0,RUNTIME_CLASS(CEMCView),CSize(2000,100),pContext);应该是
    splitter.CreateView(0,0,RUNTIME_CLASS(CEMCView),CSize(100,2000),pContext);