大浪淘沙

大浪淘沙,吹尽狂沙始到金!

博客园 首页 新随笔 联系 订阅 管理

一、建立一个MDI的工程。
二、添加一个新的基于CFormView的类。 (new Form)
三、将app中的InitInstance()函数中的一下代码注释掉。

  CMultiDocTemplate* pNewDocTemplate = new CMultiDocTemplate(
   IDR_FORMEX_TMPL,
   RUNTIME_CLASS(CMDISplittWndDoc),  // document class
   RUNTIME_CLASS(CMDIChildWnd),  // frame class
   RUNTIME_CLASS(CFormEx));  // view class
  AddDocTemplate(pNewDocTemplate);
四、在CChildFrame类中重载虚函数OnCreateClient
添加一下代码

BOOL CChildFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext)
{
 // TODO: Add your specialized code here and/or call the base class

 CRect rect;
 GetClientRect(&rect);
 CSize size1, size2;

 size1 = rect.Size();
 size1.cx = size1.cx;
 size1.cy = size1.cy/2;
 size2.cx = size1.cx;
 size2.cy = size2.cy/2;


 BOOL bCreateSpltr = m_wndSplitter.CreateStatic( this, 2, 1);
 m_wndSplitter.CreateView(0, 0, RUNTIME_CLASS(CMDISplittWndView), size1,
  pContext);
 m_wndSplitter.CreateView(1, 0, RUNTIME_CLASS(CFormEx), size2,
  pContext);
 
 return TRUE;//必须更返回值为TRUE;
// return CMDIChildWnd::OnCreateClient(lpcs, pContext);
}
五、运行编译,即可。

posted on 2004-07-27 15:28  大浪淘沙  阅读(2250)  评论(0编辑  收藏  举报