// MutiViewFrame.cpp : 实现文件
//
#include "stdafx.h"
#include "MutiViewFrame.h"
// CMutiViewFrame
IMPLEMENT_DYNCREATE(CMutiViewFrame, CFrameWnd)
CMutiViewFrame::CMutiViewFrame()
: m_nIDW_PANE_ViewID( AFX_IDW_PANE_FIRST )
{
}
CMutiViewFrame::~CMutiViewFrame()
{
}
BEGIN_MESSAGE_MAP(CMutiViewFrame, CFrameWnd)
END_MESSAGE_MAP()
// CMutiViewFrame 消息处理程序
void CMutiViewFrame::RecalcLayout(BOOL bNotify)
{
// TODO: 在此添加专用代码和/或调用基类
CView *pView = this->GetActiveView();
if( NULL == pView )
return;
RecalcLayoutByView( pView->GetDlgCtrlID(), bNotify );
}
// 按特定View计算大小
void CMutiViewFrame::RecalcLayoutByView( UINT nIDView, BOOL bNotify )
{
if (m_bInRecalcLayout)
return;
m_bInRecalcLayout = TRUE;
// clear idle flags for recalc layout if called elsewhere
if ( m_nIdleFlags & idleNotify )
bNotify = TRUE;
m_nIdleFlags &= ~(idleLayout|idleNotify);
//#ifndef _AFX_NO_OLE_SUPPORT
// // call the layout hook -- OLE support uses this hook
// if (bNotify && m_pNotifyHook != NULL)
// m_pNotifyHook->OnRecalcLayout();
//#endif
// reposition all the child windows (regardless of ID)
if (GetStyle() & FWS_SNAPTOBARS)
{
CRect rect(0, 0, 32767, 32767);
RepositionBars(0, 0xffff, nIDView, reposQuery,&rect, &rect, FALSE);
RepositionBars(0, 0xffff, nIDView, reposExtra,
&m_rectBorder, &rect, TRUE);
CalcWindowRect(&rect);
SetWindowPos(NULL, 0, 0, rect.Width(), rect.Height(),
SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOZORDER);
}
else
RepositionBars(0, 0xffff, nIDView, reposExtra, &m_rectBorder);
m_bInRecalcLayout = FALSE;
}
// 设置当前View
CView *CMutiViewFrame::SetCurrentView( CView *pView )
{
CView *pOldView = GetActiveView();
/*SetActiveView( pView );
SetActiveView( pView );
pView->OnInitialUpdate();*/
SetActiveView( pView );
RecalcLayout();
pOldView->ShowWindow( SW_HIDE );
pView->ShowWindow( SW_SHOW );
return pOldView;
}
// 创建默认客户区
BOOL CMutiViewFrame::OnCreateClient(LPCREATESTRUCT, CCreateContext* pContext)
{
CView *pView = NULL;
// default create client will create a view if asked for it
if (pContext != NULL && pContext->m_pNewViewClass != NULL)
{
pView = reinterpret_cast<CView*>( CreateView(pContext, AFX_IDW_PANE_FIRST) );
if ( pView == NULL)
return FALSE;
}
m_nIDW_PANE_ViewID = AFX_IDW_PANE_FIRST + 1;
m_vecView.push_back( pView );
return TRUE;
}
// 添加视图
int CMutiViewFrame::AddView( CRuntimeClass *pViewCreater, CCreateContext* pContext )
{
CView *pView = NULL;
// 创建附加View
/*m_pFriendView = reinterpret_cast<CFormFriendLink*>(RUNTIME_CLASS(CFormFriendLink)->CreateObject());
ASSERT(m_pFriendView != NULL );*/
// Initialize a CCreateContext to point to the active document.
// With this context, the new view is added to the document
// when the view is created in CView::OnCreate().
CCreateContext newContext( *pContext );
newContext.m_pNewViewClass = pViewCreater;
newContext.m_pLastView = NULL;
newContext.m_pCurrentFrame = this;
CRect rect(0, 0, 0, 0); // Gets resized later
pView = reinterpret_cast<CView*>( CreateView( &newContext, m_nIDW_PANE_ViewID ) ); //
if( NULL == pView )
return -1;
m_nIDW_PANE_ViewID = AFX_IDW_PANE_FIRST + 1;
int nID = m_vecView.size();
m_vecView.push_back( pView );
return nID;
}
// 按ID设置当前View
CView *CMutiViewFrame::SetCurrentView( int nID )
{
if( nID<0 || nID>m_vecView.size() )
return NULL;
CView *pView = m_vecView[ nID ];
SetCurrentView( pView );
return pView;
}
MFC的SDI程序多视图支持
4星 · 超过85%的资源 需积分: 11 10 浏览量
2009-07-03
16:18:40
上传
评论 5
收藏 2KB RAR 举报
b2b160
- 粉丝: 2353
- 资源: 29
最新资源
- 2SJ343-VB一款P-Channel沟道SOT23的MOSFET晶体管参数介绍与应用说明
- 一款基于Matlab的像素级图像标记工具,支持FITS、JPG、PNG、TIF等图像格式,可导出所有标记点坐标+源代码+文档说明
- 基于javaweb的在线答题平台.zip
- 三菱PLC例程源码丹佛斯变频器与FX通讯实例(适用于所有丹佛斯变频器)
- 微信每日早安问候(用微信传递爱情).zip
- 基于matlab-模板匹配-角度修正的铭牌识别+源代码+文档说明
- 三菱PLC例程源码丹佛斯VT2800与FX2N用RS485通讯示例
- 微信 macOS 客户端增强 Tweak 动态库.zip
- UAM概念飞机 UAM概念飞机
- 一个使用 Java 开发的、类似 WordPress 的产品,支持多站点、多语种自动切换等.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
- 1
- 2
- 3
- 4
- 5
前往页