当前位置: 首页>>代码示例>>C++>>正文


C++ CChildFrame::SetActiveView方法代码示例

本文整理汇总了C++中CChildFrame::SetActiveView方法的典型用法代码示例。如果您正苦于以下问题:C++ CChildFrame::SetActiveView方法的具体用法?C++ CChildFrame::SetActiveView怎么用?C++ CChildFrame::SetActiveView使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CChildFrame的用法示例。


在下文中一共展示了CChildFrame::SetActiveView方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: ShowStaticView

BOOL CStaticDoc::ShowStaticView( CRuntimeClass * pViewClass, BOOL bMaximized )
{
	if( NULL == pViewClass )
		return FALSE;

	CChildFrame * pChildFrame = NULL;

	POSITION pos = GetFirstViewPosition( );
	CView * pView = NULL;
	while( pView = GetNextView(pos) )
	{
		if( pView->IsKindOf( pViewClass ) )
		{
			pChildFrame = DYNAMIC_DOWNCAST( CChildFrame, pView->GetParentFrame() );
			ASSERT( pChildFrame );
			if( pChildFrame )
				break;
		}
	}

	if( NULL == pChildFrame )
	{
		// create frame
		pChildFrame = CChildFrame::CreateNewFrame( this );
		ASSERT( pChildFrame );

		if( pChildFrame )
		{
			// create view
			CCreateContext context;
			context.m_pCurrentDoc = this;
			context.m_pCurrentFrame = pChildFrame;
			context.m_pLastView = NULL;
			context.m_pNewDocTemplate = NULL;
			context.m_pNewViewClass = pViewClass;

			CView * pNewView = DYNAMIC_DOWNCAST(CView,pChildFrame->CreateView( &context, AFX_IDW_PANE_FIRST));
			if( pNewView )
			{
				pChildFrame->SetActiveView( pNewView );
				pNewView->OnInitialUpdate( );
			}

			// if no active child frame, maximize this frame
			CMainFrame * pMainFrame = AfxGetMainFrame();
			if( pMainFrame )
			{
				CFrameWnd * pActiveFrame = AfxGetMainFrame()->GetActiveFrame();
				if( !pActiveFrame || !pActiveFrame->IsKindOf(RUNTIME_CLASS(CChildFrame)) )
					pChildFrame->MDIMaximize();
			}
		}
	}
	
	if( pChildFrame )
	{
		// activate it
		pChildFrame->MDIActivate();
		if( bMaximized )
			pChildFrame->MDIMaximize();
		else
			pChildFrame->ShowWindow( SW_SHOW );
	}

	return TRUE;
}
开发者ID:ZhaoboMeng,项目名称:k-line-print,代码行数:66,代码来源:StaticDoc.cpp

示例2: SwitchToView


//.........这里部分代码省略.........

		// connect the view to the document
		AddView(pViewAdd);
	}
	else
	{
		pViewAdd = pBNewView->m_pView;
	}

	// save file on switching views
	if (theApp.m_opOptions.general.dwSaveOnSwitch && !m_xTextBuffer.GetReadOnly() && pViewDel)
		DoFileSave();
	
	CSplitterWnd*	pSplitter	= NULL;
	POSITION pos				= GetFirstViewPosition();
	BOOL firstOne				= true;
	while (pos)
	{
		CView* pv	= GetNextView(pos);
		if (pv == pViewAdd)	
		{
			pv->SetDlgCtrlID(AFX_IDW_PANE_FIRST);

			// show the view
			if (pBNewView->m_bAllowsSplitter)
			{
				pSplitter	= (CSplitterWnd*)pViewAdd->GetParent();
				
				// show the splitter (show the children view(s) as well)
				pSplitter->ShowWindow(SW_SHOW);
			}
			else
				// show the view
				pViewAdd->ShowWindow(SW_SHOW);
		}
		else 
		{
			// check if the view is inside a splitter
			if (pv->GetParent()->GetRuntimeClass() == (CRuntimeClass*)RUNTIME_CLASS(CSplitterWnd))
			{
				pSplitter	= (CSplitterWnd*)pv->GetParent();
				
				// hide the splitter (hide all views with the splitter)
				pSplitter->ShowWindow(SW_HIDE);
			}
			else
			{
				// hide the view
				pv->ShowWindow(SW_HIDE);
				pv->SetDlgCtrlID(AFX_IDW_PANE_FIRST + 255);
			}
		}

		TRACE("%s (%d) ", pv->GetRuntimeClass()->m_lpszClassName, (unsigned)(pv->GetDlgCtrlID() - AFX_IDW_PANE_FIRST));
		if (pv == pViewDel)		TRACE("= D ");
		if (pv == pViewAdd)		TRACE("= A ");
		if (pv->GetRuntimeClass() == pGlobalView->m_pClass)
		{
			if (firstOne)
				firstOne = false;
			else
				TRACE("removing ");
		}
	}
	TRACE("\n");

	// get rid of extra views created by the splitter
	if (pSplitter)
	{
		for (int cols = 1; cols < pSplitter->GetColumnCount(); cols++)
			pSplitter->DeleteColumn(cols);
		for (int rows = 1; rows < pSplitter->GetRowCount(); rows++)
			pSplitter->DeleteRow(rows);

		pSplitter->RecalcLayout();
	}

	pViewAdd->UpdateWindow();
	pChild->SetActiveView(pViewAdd);
	pChild->RecalcLayout();

	if (pBNewView->m_bModifiedSinceRefresh)
	{
		pBNewView->m_bModifiedSinceRefresh = FALSE;
		if (pGlobalView->m_pClass == RUNTIME_CLASS(CXMLTreeView))
		{
			((CXMLTreeView*)pViewAdd)->RefreshView();
		}
		else if (pGlobalView->m_pClass == RUNTIME_CLASS(CBrowserView))
		{
			((CBrowserView*)pViewAdd)->RefreshView();
		}
		else
		{
			pBNewView->m_bModifiedSinceRefresh = TRUE;
		}
	}

	return TRUE;
}
开发者ID:Qeeet,项目名称:nz-software,代码行数:101,代码来源:BonfireDoc.cpp


注:本文中的CChildFrame::SetActiveView方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。