本文整理汇总了C++中CDocument::RemoveView方法的典型用法代码示例。如果您正苦于以下问题:C++ CDocument::RemoveView方法的具体用法?C++ CDocument::RemoveView怎么用?C++ CDocument::RemoveView使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CDocument
的用法示例。
在下文中一共展示了CDocument::RemoveView方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: MakeWave
bool CMainFrame::MakeWave(const WAVEGEN_PARMS& Parms)
{
POSITION pos = theApp.GetFirstDocTemplatePosition();
CDocTemplate *pTpl = theApp.GetNextDocTemplate(pos);
CWaveShopDoc *pDoc = DYNAMIC_DOWNCAST(CWaveShopDoc, pTpl->CreateNewDocument());
if (pDoc == NULL)
return(FALSE);
bool retc, canceled;
{
CProgressDlg ProgDlg;
if (!ProgDlg.Create()) // create progress dialog
AfxThrowResourceException();
ProgDlg.SetWindowText(LDS(IDS_MAIN_GENERATING_AUDIO));
retc = CWaveGenDlg::MakeWave(Parms, pDoc->m_Wave, &ProgDlg);
canceled = ProgDlg.Canceled();
} // destroy progress dialog
if (!retc) { // if generation failed
if (!canceled) // if user canceled
AfxMessageBox(IDS_MAIN_CANT_MAKE_WAVE);
return(FALSE);
}
CDocument *pEmptyDoc = pTpl->OpenDocumentFile(NULL); // create new view
if (pEmptyDoc == NULL || m_View == NULL)
return(FALSE);
CString title = pEmptyDoc->GetTitle();
pEmptyDoc->RemoveView(m_View); // remove empty document from view
pDoc->SetTitle(title); // copy empty document's title to generated document
pDoc->AddView(m_View); // add generated document to view
m_View->OnInitialUpdate();
OnActivateView(m_View);
// view is still linked to empty document's undo manager; must relink
m_View->SetUndoManager(&pDoc->m_UndoMgr); // link view to undo manager
pDoc->m_UndoMgr.SetRoot(m_View); // link undo manager to view
return(TRUE);
}
示例2: OnViewChange
void CMainFrame::OnViewChange(UINT nCmdID)
// There is an ON_COMMAND_RANGE message map entry associated with
// OnViewChange:
// ON_COMMAND_RANGE(ID_VIEW_CHANGE1, ID_VIEW_CHANGE2, &OnViewChange)
{
CView* pViewAdd;
CView* pViewRemove;
CDocument* pDoc = GetActiveDocument();
// cvView1 and cvView2 are enum members defined in my CMainFrame class
if((nCmdID == ID_VIEW_CHANGE1) && (m_currentView == cvView1))
return;
if((nCmdID == ID_VIEW_CHANGE2) && (m_currentView == cvView2))
return;
if (nCmdID == ID_VIEW_CHANGE2)
{
if (m_pView2 == NULL)
{
m_pView1 = GetActiveView();
m_pView2 = new CMyView2;
//Note that if OnSize has been overridden in CMyView2
//and GetDocument() is used in this override it can
//cause assertions and, if the assertions are ignored,
//cause access violation.
m_pView2->Create(NULL, NULL, AFX_WS_DEFAULT_VIEW, rectDefault, this,
AFX_IDW_PANE_FIRST + 1, NULL);
}
pViewAdd = m_pView2;
pViewRemove = m_pView1;
m_currentView = cvView2;
}
else
{
pViewAdd = m_pView1;
pViewRemove = m_pView2;
m_currentView = cvView1;
}
// Set the child i.d. of the active view to AFX_IDW_PANE_FIRST,
// so that CFrameWnd::RecalcLayout will allocate to this
// "first pane" that portion of the frame window's client area
// not allocated to control bars. Set the child i.d. of the
// other view to anything other than AFX_IDW_PANE_FIRST; this
// examples switches the child id's of the two views.
int nSwitchChildID = pViewAdd->GetDlgCtrlID();
pViewAdd->SetDlgCtrlID(AFX_IDW_PANE_FIRST);
pViewRemove->SetDlgCtrlID(nSwitchChildID);
// Show the newly active view and hide the inactive view.
pViewAdd->ShowWindow(SW_SHOW);
pViewRemove->ShowWindow(SW_HIDE);
// Connect the newly active view to the document, and
// disconnect the inactive view.
pDoc->AddView(pViewAdd);
pDoc->RemoveView(pViewRemove);
SetActiveView(pViewAdd);
RecalcLayout();
}