MFCマルチドキュメントアプローチを再開けないでください

    template<typename T>
    inline CView* GetView(CDocument* pDoc)
    {
	    CView* pView;
    	POSITION pos = pDoc->GetFirstViewPosition();
	    CRuntimeClass* pClass = RUNTIME_CLASS(T);

    	while (pos != NULL) {
	    	pView = pDoc->GetNextView(pos);
		    if (!pView->IsKindOf(pClass))
			    break;
    	}

	    if (!pView->IsKindOf(pClass)) {
		    return NULL;
    	}

	    return pView;
    }


     CView* pView = nullptr;
	 POSITION pos = theApp.GetMeterReportT()->GetFirstDocPosition();
	 while (pos)
	 {
		 CDocument* pDoc = theApp.GetMeterReportT()->GetNextDoc(pos);
		 if (pDoc->IsKindOf(RUNTIME_CLASS(CNaturalMeterDoc)))
		 {
			 pView = GetView<CMeterReportView>(pDoc);
			 if (pView)
			 {
				 pView->GetParentFrame()->ActivateFrame();
				 break;
			 }
		 }

	 }

	 if (nullptr == pView)
	 {
		 theApp.GetMeterReportT()->OpenDocumentFile(nullptr);
	 }

CMultiDocTemplate * CxxxxxApp :: GetMeterReportT()constは // フロー計算書のテンプレート 
{
    m_pMeterReportTを返します;
}

より便利なこの代替方法、このレコードを見て

公開された14元の記事 ウォンの賞賛0 ビュー9847

おすすめ

転載: blog.csdn.net/u011512808/article/details/104720207