急!急!急!如何创建单文档多视图

cx0998 2002-05-10 08:25:37
我创建的新视必须基于CFormView类,但我却不知如何做。如果是基于CEditView类是很容易的,但用同样的方法却不能实现基于CFormView类或是CRecordView类,请各位VC高手不吝赐教,谢谢!·
...全文
78 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
xlt777 2002-05-11
  • 打赏
  • 举报
回复
将你的要求具体再提具体些,我可能有办法解决的。
wolfliu 2002-05-11
  • 打赏
  • 举报
回复
刚才忘了,MDI 程序建立多视图是很容易的,各个视图
也容易排列,SDI 就很难了
wolfliu 2002-05-11
  • 打赏
  • 举报
回复
我认为 实现方式是建立 MDI 程序
当打开或建立一个文档后,程序就控制再打开或者建立新的问档时,
关闭原来的文档。
关闭一个文档时要么打开,要么建立一个新文档要么打开一个文档
expert_zh 2002-05-11
  • 打赏
  • 举报
回复
This article was contributed by Chris Kirby.
I think there is a new/simpler way to create new views attached to an existing document using VC++ 5.0. I think it is a cleaner implementation since it uses new hooks that MFC provides rather than having to work with the CCreateContext's.

Assuming the following are already declared in the app:


CMultiDocTemplate * m_pTemplate;
CWhateverDocument * m_pDocument;

The app would only need to have the following to create a new view attached to the document:


void CWhateverApp::OnCreateView()
{
// creates the frame and associated view, attaches to document
CFrameWnd * pFrameWnd = m_pTemplate->CreateNewFrame( m_pDocument, NULL );

// error checking in case creation of frame or view fails
RETURN_ON_NULL( pFrameWnd );

// let the frame do any initialization the framework needs,
// call the view's OnInitialUpdate()
m_pTemplate->InitialUpdateFrame( pFrameWnd, m_pDocument );
}


expert_zh 2002-05-11
  • 打赏
  • 举报
回复
This article was contributed by Adrian Roman.
I add here the code that could be used to add multiple views to a document, in a MDI application. I usually make database applications, and I don't want that the document to be created/destroyed by the framework, so I create the document myself (and of course I destroy it J ), and in document's constructor I set the m_bAutoDelete flag to FALSE.

The CMyApp class contains as public member a pointer to my document. I also make document templates for all views, and I keep the pointers in CMyApp. You should have something like this in InitInstance():


m_pView1Templ=new CMultiDocTemplate( IDR_VIEW1TYPE,
RUNTIME_CLASS( CMyDoc ),
RUNTIME_CLASS( CChildFrame ),
RUNTIME_CLASS( CView1 ) );
AddDocTemplate(m_pView1Templ);
// m_pView1Templ is member of CMyApp

After you created all necessary document templates, add the following code:


// create main MDI Frame window
CMainFrame* pMainFrame = new CMainFrame;
mp_doc=new CTimeClkDoc;
mp_doc->SetTitle("Just a demo");
CCreateContext context;
context.m_pCurrentDoc=mp_doc;
context.m_pNewViewClass=NULL;
context.m_pNewDocTemplate=NULL;
context.m_pLastView=NULL;
context.m_pCurrentFrame=NULL;
if (!pMainFrame->LoadFrame(IDR_MAINFRAME,WS_OVERLAPPEDWINDOW | FWS_ADDTOTITLE,NULL, &context ))
return FALSE;
m_pMainWnd = pMainFrame;

This code will allow opening the application without any open view and also avoids the dialog box that asks to choose a document template. Add for each view command handlers similar with this one:


void CMyApp::OnView1()
{
// TODO: Add your command handler code here
CChildFrame* pFrame = new CChildFrame();
CCreateContext context;
context.m_pCurrentDoc=mp_doc; //that's the way I avoid to create new document every time I open a new view
context.m_pNewViewClass=RUNTIME_CLASS(CView1);
context.m_pNewDocTemplate=m_pView1Templ;
context.m_pLastView=(((CMainFrame *)m_pMainWnd)->GetActiveFrame() ? ((CMainFrame *)m_pMainWnd)->GetActiveFrame()->GetActiveView() : NULL);
context.m_pCurrentFrame=((CMainFrame *)m_pMainWnd)->GetActiveFrame();
if (!pFrame->LoadFrame(IDR_VIEW1TYPE,WS_OVERLAPPEDWINDOW | FWS_PREFIXTITLE ,m_pMainWnd, &context ))return;
pFrame->InitialUpdateFrame(mp_doc,TRUE);
}


onlynight 2002-05-11
  • 打赏
  • 举报
回复
可否说一下要实现些什么功能
CEditView也是人写出来的啊
ryan_chen 2002-05-11
  • 打赏
  • 举报
回复
可以。
需要自己建视,文档,菜单等等,用OpenDocumentFile来显示一个新的FormView.
具体就很长了。
不算太繁琐。
英文版:Expert Spring MVC and Web Flow 内容简介 《深入解析Spring MVCgn Web Flow》是Spring MVC 和Web Flow 两个框架的权威指南,书中包括的技巧和提示可以让你从这个灵活的框架中汲取尽可能多的信息。书中包含了一些开发良好设计和解耦的Web 应用程序的最佳实践,介绍了Spring 框架中的Spring MVC 和Spring Web Flow,以及着重介绍利用Spring 框架和Spring MVC 编写Web 应用程序的最佳方法。《深入解析Spring MVCgn Web Flow》还介绍了Spring 框架的设计模式,以及如何将同样的设计和技术应用到读者自己的代码中。 《深入解析Spring MVCgn Web Flow》适合各层次Spring Web 程序员阅读。 编辑推荐 《深入解析Spring MVCgn Web Flow》来自Spring开发团队的权威之作前所未有地深入剖析Spring MVC技术内幕大量专家经验和技巧,全面提升你的Web开发境界 Spring MVC和Spring Web Flow是Spring平台上两个极为灵活而且功能强大的Web框架。前者是构建在Spring框架上的Web应用程序框架,可以同许多其他视图技术无缝集成;后者是控制业务处理流程的有效解决方案,提供了一种编写有状态和基于会话的Web应用程序的简便手段。 《深入解析Spring MVCgn Web Flow》出自Spring核心开发者之手,不仅详细分析代码,全面剖析了两个框架的各种特性(包括一些不为人知的技术亮点)。告诉读者如何最大程度地发挥出它们的潜力。还解密了设计这两个框架时的许多决策内幕、所应用的设计模式和面向对象技术,使读者能够更深入地了解Spring。并在自己的项目中运用这些专家技术,全面提升自己的Web开发境界。 《深入解析Spring MVCgn Web Flow》由spring框架的开发和维护者SpringSource公司组织编写,作者均为资深Spring工程师或咨询师。 Seth Ladd是资深Spring培训师,曾为NEC公司等许多国际性机构构建Web系统。Darren Davison和StevenDevijver都曾是Spring核心开发人员,在Spring源代码和文档中可以很容易地找到他们的名字。而Colin Yates、Keith Donald和Rob Harrop均是SpringSource资深工程师,仍然是Spring新版本开发的核心骨干。Yalcs是.J2EE主架构师,Donald是SpringWeb Flow负责人,Hartop是Spring与Tomcat成产品负责人。“《深入解析Spring MVCgn Web Flow》为Spring社区弥补了一大空白。” ——Lasse Koskela.JavaRanch版主,Test Driven作者“《深入解析Spring MVCgn Web Flow》是非常缺的深入讲解Spring MVCf~~Spring Web Flow的图书堪与Pro Spring相媲美。” ——Steve Anglin,资深Java技术专家

16,550

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC相关问题讨论
社区管理员
  • 基础类社区
  • Creator Browser
  • encoderlee
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

        VC/MFC社区版块或许是CSDN最“古老”的版块了,记忆之中,与CSDN的年龄几乎差不多。随着时间的推移,MFC技术渐渐的偏离了开发主流,若干年之后的今天,当我们面对着微软的这个经典之笔,内心充满着敬意,那些曾经的记忆,可以说代表着二十年前曾经的辉煌……
        向经典致敬,或许是老一代程序员内心里面难以释怀的感受。互联网大行其道的今天,我们期待着MFC技术能够恢复其曾经的辉煌,或许这个期待会永远成为一种“梦想”,或许一切皆有可能……
        我们希望这个版块可以很好的适配Web时代,期待更好的互联网技术能够使得MFC技术框架得以重现活力,……

试试用AI创作助手写篇文章吧