int CTestFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
{
if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
return -1; CCreateContext context;
context.m_pNewViewClass = RUNTIME_CLASS(CEditClient);
context.m_pCurrentFrame = this;
context.m_pCurrentDoc = NULL;
context.m_pLastView = NULL; m_pView = STATIC_DOWNCAST(CEditClient, CreateView(&context)); //CreateView(&context);
if(m_pView != NULL)
{
m_pView->ShowWindow(SW_SHOW);
SetActiveView(m_pView);
} //ShowWindow(SW_MAXIMIZE); */ return 0;
}
不管我是在Dialog中动态创建一个View还是显示一个Frame/view,程序都会报错,在Dialog中动态创建一个View的时候是有鼠标Click时出错,创建Frame/view时是显示时出错.不知道是什么原因?

解决方案 »

  1.   

    http://www.codeguru.com/Cpp/W-D/dislog/article.php/c5007/
    http://www.codeguru.com/Cpp/W-D/dislog/article.php/c5009/
      

  2.   

    http://www.codeproject.com/dialog/A_Doc_View_Dialog_support.asp
      

  3.   

    to lixiaosan(小三) 
    thanks,调试通过的话马上给分
      

  4.   

    http://codeguru.earthweb.com/dialog/ViewOnDlg.html
    Creating a View on a Dialog - Naama Goraly (2001/08/09)
    Creating a view on a child frame is a basic action when programming in MFC, but what happens when you want your view to be attached to a popup dialog? This article shows a simple way to make this possible.
    http://codeguru.earthweb.com/dialog/vwindlg.html
    Creating a View in Dialog (An easy way). - Z Mohamed Mustafa (2002/02/19)
    Adding a view to a dialog.
      

  5.   

    参考一下下面的
    http://www.vccode.com/file_show.php?id=782
      

  6.   

    to lixiaosan(小三) ( ) ,laiyiling(最熟悉的陌生人) ( )  successq(江川) ( ) 多谢3位,按你们提供的例子,创建普通的CView没有问题,但是如果是CScrollView就会出错,不知道是什么原因?