100分急求解决方案!

solarhe 2005-03-26 10:07:58
我创建了一个多文档的程序.想把其中一个文档框架切分成两上,一下的三个视图窗口!每个窗口都可以跟着文档框架的大小来变化大小,可以单独的视图的大小却不能改变!下面是文档框架的cpp文件,请大家帮忙!
// ChildFrm.cpp : implementation of the CChildFrame class
//

#include "stdafx.h"
#include "pp.h"

#include "ChildFrm.h"
#include "MyTreeView.h"
#include "MyListView.h"

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CChildFrame

IMPLEMENT_DYNCREATE(CChildFrame, CMDIChildWnd)

BEGIN_MESSAGE_MAP(CChildFrame, CMDIChildWnd)
//{{AFX_MSG_MAP(CChildFrame)
ON_WM_SIZE()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()

/////////////////////////////////////////////////////////////////////////////
// CChildFrame construction/destruction

CChildFrame::CChildFrame()
{
// TODO: add member initialization code here

}

CChildFrame::~CChildFrame()
{
}

BOOL CChildFrame::PreCreateWindow(CREATESTRUCT& cs)
{
// TODO: Modify the Window class or styles here by modifying
// the CREATESTRUCT cs

if( !CMDIChildWnd::PreCreateWindow(cs) )
return FALSE;

return TRUE;
}



/////////////////////////////////////////////////////////////////////////////
// CChildFrame diagnostics

#ifdef _DEBUG
void CChildFrame::AssertValid() const
{
CMDIChildWnd::AssertValid();
}

void CChildFrame::Dump(CDumpContext& dc) const
{
CMDIChildWnd::Dump(dc);
}

#endif //_DEBUG

/////////////////////////////////////////////////////////////////////////////
// CChildFrame message handlers
//添加三个视图的成员函数
CView* CChildFrame::AddView(CCreateContext* pContext,UINT nIndex,LPCTSTR lpSZWindowName)
{
CWnd* pView=(CWnd*)pContext->m_pNewViewClass->CreateObject();
if(pView==NULL)
{
return NULL;
}
ASSERT_KINDOF(CWnd,pView);
//是不是这里的窗口风格有问题?
if(!pView->Create(NULL,lpSZWindowName,WS_CHILD|WS_VISIBLE|WS_CAPTION,
CRect(0,0,0,0),this,nIndex,pContext))
{
return NULL;
}
return (CView*)pView;
}
//重载OnCreateClient
BOOL CChildFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext)
{
// TODO: Add your specialized code here and/or call the base class
if((m_pView1=AddView(pContext,1,_T("123")))==NULL)
{
return false;
}
pContext->m_pNewViewClass=RUNTIME_CLASS(CMyListView);
if((m_pView2=AddView(pContext,2,_T("123")))==NULL)
{
return false;
}
pContext->m_pNewViewClass=RUNTIME_CLASS(CMyTreeView);
if((m_pView3=AddView(pContext,2,_T("123")))==NULL)
{
return false;
}
return true;
//return CMDIChildWnd::OnCreateClient(lpcs, pContext);
}
//调整文档框架中三个视图的大小
void CChildFrame::OnSize(UINT nType, int cx, int cy)
{
CMDIChildWnd::OnSize(nType, cx, cy);

// TODO: Add your message handler code here
m_pView1->MoveWindow(0,0,cx/2,cy/2);
m_pView2->MoveWindow(cx/2,0,cx/2,cy/2);
m_pView3->MoveWindow(0,cy/2,cx,cy/2);

}
...全文
92 10 打赏 收藏 转发到动态 举报
写回复
用AI写文章
10 条回复
切换为时间正序
请发表友善的回复…
发表回复
solarhe 2005-03-27
  • 打赏
  • 举报
回复
楼上怎么把广告贴这里来了?
solarhe 2005-03-26
  • 打赏
  • 举报
回复
怎么没人回贴呀!
solarhe 2005-03-26
  • 打赏
  • 举报
回复
关键是我用CSplitterWnd分不出两上,一下的视图!我只能分成两上,两下的样子
xuzheng318 2005-03-26
  • 打赏
  • 举报
回复
This constructor creates an instance of a splitter window and attaches it to the CSplitterWnd object.

To construct a CSplitterWnd object, call the constructor, which creates the CSplitterWnd object, then call the Create method
菜牛 2005-03-26
  • 打赏
  • 举报
回复
为什么不用CSplitterWnd?
solarhe 2005-03-26
  • 打赏
  • 举报
回复
在线等呀!
solarhe 2005-03-26
  • 打赏
  • 举报
回复
在线等呀!
solarhe 2005-03-26
  • 打赏
  • 举报
回复
在线等呀!

15,980

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 界面
社区管理员
  • 界面
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

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