本人是初学者,在网上找了一个比较详细的窗体分割实例,可是按他那些编写后运行在编译时没有问题,但运行却会报错
请高人帮我看看 谢谢了~!一下是那个实例的具体过程及代码:
首先建立MFC AppWizard(exe),取名字为SplitterWnd,下一步,选择单文档“Single document”,其他默认,点击“完成”。 点击ResourceView,在Dialog下插入两个个Dialog窗口用于稍后的分割后的窗口,ID号分别改为“IDD_FORMVIEW1”和“IDD_FORMVIEW2”。记得及时保存。 单击ClassView标签,添加2个类,当然也可以从ClassWizard中添加,名字叫FormView1,类选择CFormView,Dialog ID选择IDD_FORMVIEW1,另一个类叫FormView2,ID选择IDD_FORMVIEW2。 在CMainFrame中添加两个成员变量,类型都为CSplitterWnd,变量名分别为m_splitter和m_splitter1,然后添加一个虚函数OnCreateClient,点击编辑代码,将如下代码更改  BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext) 
{
    // TODO: Add your specialized code here and/or call the base class
    return CFrameWnd::OnCreateClient(lpcs, pContext);
}改为 BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext) 
{    //创建一个静态分栏窗口,分为一行二列 
    if(m_splitter.CreateStatic(this,1,2)==NULL) 
        return FALSE;     //将CCSplitterWndView连接到0行0列窗格上
    m_splitter.CreateView(0,0,RUNTIME_CLASS(CSplitterWndView),CSize(600,600), pContext);     if(m_splitter1.CreateStatic(&m_splitter,2,1,WS_CHILD|WS_VISIBLE, 
        m_splitter.IdFromRowCol(0, 1))==NULL) 
        return FALSE; //将第0行1列再分开2行1列 
    //将FormView1类连接到第二个分栏对象的0行0列
    m_splitter1.CreateView(0,0,RUNTIME_CLASS(FormView1),CSize(200,400),pContext); 
    //将FormView2类连接到第二个分栏对象的1行0列
    m_splitter1.CreateView(1,0,RUNTIME_CLASS(FormView2),CSize(200,200),pContext); 
    return TRUE; }添加头文件:#include "SplitterWndDoc.h"
#include "SplitterWndView.h"
#include "FormView1.h"
#include "FormView2.h"好了,现在编译运行,可以得到分栏的结果了。

解决方案 »

  1.   


    Debug Assertion Failed!
    program:...
    file:viewform.cpp
    line:69for information on how your program can cause an assertion failure,see the visual C++ documentation on asserts.多次忽略以后0x5f4604fd指令引用的0x00000020内存。该内存不能为read.谁能帮帮我啊,看了很久也没弄明白
      

  2.   

    那两个Dialog的属性你是怎么设置的?它们的属性中的“样式(S)”要设置为"下层"
      

  3.   

    if(m_splitter.CreateStatic(this,1,2)==NULL) 
    这一句说明什么?再看看m_splitter1.CreateView(1,0,RUNTIME_CLASS(FormView2),CSize(200,200),pContext),是不是可以看出什么来?把
    m_splitter1.CreateView(1,0,RUNTIME_CLASS(FormView2),CSize(200,200),pContext);
    改成
    m_splitter1.CreateView(0,1,RUNTIME_CLASS(FormView2),CSize(200,200),pContext);
      

  4.   

    另外,我看着RUNTIME_CLASS(FormView1)感觉巨不爽,FormView1是你自己定义的类名吗?还是在按一般人写的那样在前面加一个大写的C吧。
      

  5.   


    太谢谢你了~!!!!
    我把两个Dialog属性  STYLE:改为 CHILD; BORDER:改为NONE。在编译运行就好了~!
    太感谢你了 哈哈
      

  6.   

    你好我想请问一下,我刚才按你说的操作了一遍,编译时报错
    d:\工作\程序\splitterwnd\formview1.h(26) : error C2065: 'IDD_FORMVIEW1' : undeclared identifier
    工作\程序\splitterwnd\formview1.h(26) : error C2057: expected constant expression
    d:\工作\程序\splitterwnd\formview2.h(26) : error C2065: 'IDD_FORMVIEW2' : undeclared identifier
    d:\工作\程序\splitterwnd\formview2.h(26) : error C2057: expected constant expression
    请问一下,这是怎么回事?
      

  7.   

    #include "SplitterWndDoc.h" 
    #include "SplitterWndView.h" 这头文件 哪有啊!!!~~~有知道告诉我一下非常感谢
      

  8.   

    Blacking你有SplitterWndDoc.h和SplitterWndView.h这两个文件了吗?