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


C++ CDocTemplate类代码示例

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


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

示例1: TRACE0

void CMainFrame::MakeNewView( CRuntimeClass* pViewRuntimeClass)
{
	CDocument* pDocument;
	CChildFrame *pActiveChild;

	pActiveChild =(CChildFrame *)this->MDIGetActive();

	pDocument = this->GetCurrentDoc ();
/*
	if (pActiveChild == NULL ||
	  (pDocument = pActiveChild->GetActiveDocument()) == NULL)
	{
		TRACE0("Warning: No active document for WindowNew command.\n");
		AfxMessageBox(AFX_IDP_COMMAND_FAILURE);
		return;     // command failed
	}
*/
	// otherwise we have a new frame !
	CDocTemplate* pTemplate = pDocument->GetDocTemplate();
	ASSERT_VALID(pTemplate);
	CFrameWnd* pFrame = CreateNewGameViewFrame(pViewRuntimeClass, pTemplate, pDocument, pActiveChild);
	if (pFrame == NULL)
	{
		TRACE0("Warning: failed to create new frame.\n");
		return;     // command failed
	}

	pTemplate->InitialUpdateFrame(pFrame, pDocument);
}
开发者ID:RealityFactory,项目名称:Genesis3D-Tools,代码行数:29,代码来源:MainFrm.cpp

示例2: 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);
}
开发者ID:victimofleisure,项目名称:WaveShop,代码行数:35,代码来源:MainFrm.cpp

示例3: GetDocTemplate

BOOL CDocument::DoSave(LPCTSTR lpszPathName, BOOL bReplace)
	// Save the document data to a file
	// lpszPathName = path name where to save document file
	// if lpszPathName is NULL then the user will be prompted (SaveAs)
	// note: lpszPathName can be different than 'm_strPathName'
	// if 'bReplace' is TRUE will change file name if successful (SaveAs)
	// if 'bReplace' is FALSE will not change path name (SaveCopyAs)
{
	CString newName = lpszPathName;
	if (newName.IsEmpty())
	{
		CDocTemplate* pTemplate = GetDocTemplate();
		ASSERT(pTemplate != NULL);

		newName = m_strPathName;
		if (bReplace && newName.IsEmpty())
		{
			newName = m_strTitle;
			// check for dubious filename
			int iBad = newName.FindOneOf(_T(":/\\"));
			if (iBad != -1)
				newName.ReleaseBuffer(iBad);

			// append the default suffix if there is one
			CString strExt;
			if (pTemplate->GetDocString(strExt, CDocTemplate::filterExt) &&
			  !strExt.IsEmpty())
			{
				ASSERT(strExt[0] == '.');
				int iStart = 0;
				newName += strExt.Tokenize(_T(";"), iStart);
			}
		}

		if (!AfxGetApp()->DoPromptFileName(newName,
		  bReplace ? AFX_IDS_SAVEFILE : AFX_IDS_SAVEFILECOPY,
		  OFN_HIDEREADONLY | OFN_PATHMUSTEXIST, FALSE, pTemplate))
			return FALSE;       // don't even attempt to save
	}

	CWaitCursor wait;

	if (!OnSaveDocument(newName))
	{
		if (lpszPathName == NULL)
		{
			// be sure to delete the file
			TRY
			{
				CFile::Remove(newName);
			}
			CATCH_ALL(e)
			{
				TRACE(traceAppMsg, 0, "Warning: failed to delete file after failed SaveAs.\n");
				DELETE_EXCEPTION(e);
			}
			END_CATCH_ALL
		}
		return FALSE;
	}
开发者ID:pixelspark,项目名称:corespark,代码行数:60,代码来源:doccore.cpp

示例4: AfxGetApp

void CCWArrangePage::OnMatchMerge () 
{
	CPickMergeDlg dlg;

	// add all open documents to the list
	POSITION pos = AfxGetApp ()->GetFirstDocTemplatePosition ();
	CDocTemplate* pDocTmpl = AfxGetApp ()->GetNextDocTemplate (pos);
	pos = pDocTmpl->GetFirstDocPosition ();
	while (pos)
		dlg.m_arrTrackInfo.Add (((CCdCoverCreator2Doc*) pDocTmpl->GetNextDoc (pos))->m_pTracks);

	if (dlg.DoModal () == IDOK)
	{
		// build merged trackinfo
		CTracksInfo ti, *pT;
		for (int i = 0; i < dlg.m_arrTrackInfo.GetSize (); i++)
		{
			pT = (CTracksInfo*) dlg.m_arrTrackInfo.GetAt (i);
			for (int j = 0; j  < pT->GetNumTracks (); j++)
				ti.Add (new CTrack (pT->GetTrack (j)));
		}

		// clear tracks
		if (!dlg.m_DontDeleteExisting)
			for (int i = 0; i < m_pTracks->GetNumTracks (); i++)
				m_pTracks->GetTrack (i).SetText ("", "");

		// match tracks
		GetTracksInfo ();
		m_pTracks->Match (&ti, dlg.m_DontDeleteExisting ? false : true);

		// display
		SetTracks ();
	}
}
开发者ID:matthias-christen,项目名称:CdCoverCreator,代码行数:35,代码来源:CreationWizardPages.cpp

示例5: AfxGetApp

void CSaveOptionPage::RegFileType(LPCTSTR pszType)
{
	POSITION posTmpl = AfxGetApp()->GetFirstDocTemplatePosition();
	if(posTmpl != NULL)
	{
		CDocTemplate* pTemplate = AfxGetApp()->GetNextDocTemplate(posTmpl);
		CString strFileTypeId;
		if (pTemplate->GetDocString(strFileTypeId, CDocTemplate::regFileTypeId))
		{
			CString strTemp;
			LONG lSize = _MAX_PATH * 2;
			LONG lResult = AfxRegQueryValue(HKEY_CLASSES_ROOT, pszType,
				strTemp.GetBuffer(lSize), &lSize);
			strTemp.ReleaseBuffer();

			if(strTemp.Compare(strFileTypeId) != 0)
			{
				AfxRegSetValue(
					HKEY_CLASSES_ROOT, pszType, REG_SZ,
					strFileTypeId, lstrlen(strFileTypeId) * sizeof(TCHAR));
				AfxGetApp()->WriteProfileString(_T("Settings"), pszType, strTemp);
			}
		}
	}
}
开发者ID:BennyThink,项目名称:TimeM,代码行数:25,代码来源:SaveOptionPage.cpp

示例6: UpdateView

void MLocatorView::UpdateView()
{
	POSITION p = theApp.GetFirstDocTemplatePosition(); 
	CDocTemplate* pTemplate = theApp.GetNextDocTemplate(p); 
	p = pTemplate->GetFirstDocPosition(); 
	CLocatorDoc* pDoc = (CLocatorDoc*)pTemplate->GetNextDoc(p); 
	if( 0 != pDoc )
	{
		const MServerStatusMgr* pServerStatusMgr = pDoc->GetLocator()->GetServerStatusMgr();
		if( (0 != pServerStatusMgr) && (0 < pServerStatusMgr->GetSize()) )
		{
			CListCtrl& lc = GetListCtrl();

			char szBuf[ 128 ];
			string strDeadServerIDList;
			const int nDeadServerCount = pServerStatusMgr->GetDeadServerCount();

			_snprintf( szBuf, 127, "%d", pServerStatusMgr->GetSize() );
			lc.InsertItem( 0, szBuf );

			_snprintf( szBuf, 127, "Run:%d, Dead:%d", pServerStatusMgr->GetLiveServerCount(), nDeadServerCount );
			lc.SetItemText( 0, 1, szBuf );
			
			for( int i = 0; i < nDeadServerCount; ++i )
			{
				_snprintf( szBuf, 127, "%d,  ", pServerStatusMgr->GetDeadServerIDList()[i] );
				strDeadServerIDList += szBuf;
			}
			strDeadServerIDList += "\0";

			lc.SetItemText( 0, 2, strDeadServerIDList.c_str() );
		}
	}
}
开发者ID:roseon,项目名称:life-marvelous,代码行数:34,代码来源:MLocatorView.cpp

示例7: InvalidateAll

void CMainFrame::InvalidateAll()
{
    POSITION appPos, templatePos;
    CDocTemplate *pTemplate;
    CDComDoc *pDoc;
    CDComView *pView;

    appPos = AfxGetApp()->GetFirstDocTemplatePosition();

    while (appPos)
    {
        pTemplate = AfxGetApp()->GetNextDocTemplate(appPos);
        if (pTemplate)
        {
            templatePos = pTemplate->GetFirstDocPosition();
            while (templatePos)
            {
                pDoc = (CDComDoc*)pTemplate->GetNextDoc(templatePos);
                if (pDoc)
                {
                    pView = pDoc->GetView();
                    if (pView)
                    {
                        pView->PostMessage(WM_DOC_UPDATE, 0);
                        pView->Invalidate();
                    }
                }
            }
        }
    }
}
开发者ID:cdesjardins,项目名称:DCom,代码行数:31,代码来源:MainFrm.cpp

示例8: FindTextResetAll

void CMainFrame::FindTextResetAll()
{
    POSITION appPos, templatePos;
    CDocTemplate *pTemplate;
    CDComDoc *pDoc;

    appPos = AfxGetApp()->GetFirstDocTemplatePosition();

    while (appPos)
    {
        pTemplate = AfxGetApp()->GetNextDocTemplate(appPos);
        if (pTemplate)
        {
            templatePos = pTemplate->GetFirstDocPosition();
            while (templatePos)
            {
                pDoc = (CDComDoc*)pTemplate->GetNextDoc(templatePos);
                if (pDoc)
                {
                    pDoc->FindTextReset();
                }
            }
        }
    }
}
开发者ID:cdesjardins,项目名称:DCom,代码行数:25,代码来源:MainFrm.cpp

示例9: while

CDocument *CDocManager::OpenDocumentFile( LPCTSTR lpszFileName )
/**************************************************************/
{
    POSITION                    position = m_templateList.GetHeadPosition();
    CDocTemplate                *pSelected = NULL;
    CDocTemplate::Confidence    nSelConfidence = CDocTemplate::noAttempt;
    while( position != NULL ) {
        CDocTemplate *pTemplate = (CDocTemplate *)m_templateList.GetNext( position );
        ASSERT( pTemplate != NULL );
        
        CDocument                   *pMatch = NULL;
        CDocTemplate::Confidence    nConfidence = pTemplate->MatchDocType( lpszFileName,
                                                                           pMatch );
        if( nConfidence > nSelConfidence ) {
            nSelConfidence = nConfidence;
            pSelected = pTemplate;
            if( nConfidence == CDocTemplate::yesAlreadyOpen ) {
                ASSERT( pMatch != NULL );
                POSITION viewPos = pMatch->GetFirstViewPosition();
                if( viewPos != NULL ) {
                    CView *pView = pMatch->GetNextView( viewPos );
                    CFrameWnd *pFrame = pView->GetParentFrame();
                    ASSERT( pFrame != NULL );
                    pFrame->ActivateFrame();
                }
                return( pMatch );
            }
        }
    }
    if( pSelected == NULL ) {
        return( NULL );
    }
    return( pSelected->OpenDocumentFile( lpszFileName ) );
}
开发者ID:ABratovic,项目名称:open-watcom-v2,代码行数:34,代码来源:docmangr.cpp

示例10: stream

// STATIC
// called by CProjectDoc when it is opening
// This reads parameters out of the project document.  These
// params give us the path of the base file (ana document)
// the size and placement of the window, the processing goal, etc.
CAnaInputDoc * CAnaInputDoc ::loadDocument( LPCTSTR lpszField, SFMFile & f)
{
	CDocTemplate* pT = theApp.getDocTemplate(getRegFileTypeID());
	ASSERTX(pT);
	CParseStream stream(lpszField);
	CString sPath;
	stream.getQuotedString(sPath);
	//if(!theApp.askUserToFindFileIfNotFound(sPath, getRegFileTypeID()))
	//	return NULL;

	CPathDescriptor path(sPath);
	if(!path.fileExists())	// don't bother the user (mar 99)
	{
		// need to skip the rest of the fields related to this document in the project file
		CString sMarker, sField;
		do
		{
			f.getField(sMarker, sField);
		} while (sMarker != END_MARKER());
		return NULL;
	}
	// jdh I'm not certain what this does, but it appears that it will just set
	// the member variable m_strPathName, so that whent the panels are displayed,
	// we then go and load up that file into the first panel.
	CAnaInputDoc * pDoc = (CAnaInputDoc *)pT->OpenDocumentFile(sPath);

	ASSERTX(pDoc->IsKindOf(RUNTIME_CLASS(CAnaInputDoc )));
	pDoc->readParams(f);
	pDoc->SetTitle(getFullFileName(pDoc->GetPathName()));
	return pDoc;
}
开发者ID:cdyangupenn,项目名称:CarlaLegacy,代码行数:36,代码来源:inputdoc.cpp

示例11: GetDocTemplate

void CInputDoc::OnFileSaveAs()
{
	CDocTemplate* pDT = GetDocTemplate();
	CString sFileTypeName;
	pDT->GetDocString(sFileTypeName, CDocTemplate::regFileTypeName);
	CString sFilter;
	pDT-> GetDocString(sFilter, CDocTemplate::filterName);
	CString sExt;//="txt";
	pDT-> GetDocString(sExt, CDocTemplate::filterExt);
	sFilter += "|*";
	sFilter += sExt;
	sFilter+= "||";
	CFileDialog dlg( FALSE,
		sExt,
		this->GetPathName(),
		OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,
		sFilter, NULL );
	//CString sPrompt("Save As");

	//char* lpszPrompt = new char[sPrompt.GetLength()+1];
	//strcpy(lpszPrompt, sPrompt);
	dlg.m_ofn.lpstrTitle  = "Save As";//lpszPrompt;

	if(IDOK == dlg.DoModal())
	{
		this->SetPathName(dlg.GetPathName());
		OnSaveDocument(dlg.GetPathName());
	}
}
开发者ID:cdyangupenn,项目名称:CarlaLegacy,代码行数:29,代码来源:inputdoc.cpp

示例12: AfxGetApp

void CMainFrame::OnViewDeletedrecords() 
{
	m_bShowDeletedRecords = !m_bShowDeletedRecords;
	
	CWinApp* pApp = AfxGetApp();
	ASSERT_VALID(pApp);

	// Iterate through the application's document templates list
	POSITION posTemplate = pApp->GetFirstDocTemplatePosition();
	while(posTemplate)
	{
		// For each document template object...
		CDocTemplate* pTemplate = pApp->GetNextDocTemplate(posTemplate);
		ASSERT_VALID(pTemplate);
		ASSERT_KINDOF(CDocTemplate, pTemplate);

		// Iterate through the template's document list
		POSITION posDocument = pTemplate->GetFirstDocPosition();
		while(posDocument)
		{
			// For each document object...
			CDocument* pDoc = pTemplate->GetNextDoc(posDocument);
			ASSERT_VALID(pDoc);
			ASSERT_KINDOF(CDocument, pDoc);

			// reload records
			POSITION pos = pDoc->GetFirstViewPosition();
			while (pos)
				((CDBFExplorerView *)pDoc->GetNextView(pos))->ShowRecords(m_bShowDeletedRecords);
		}
	}
}
开发者ID:tchv71,项目名称:StartPP,代码行数:32,代码来源:MainFrm.cpp

示例13: TRACE0

void CWordPadApp::UpdateRegistry()
{
	USES_CONVERSION;
	LPOLESTR lpszClassID = NULL;
	CDocTemplate* pDocTemplate = &DocTemplate;

	// get registration info from doc template string
	CString strServerName;
	CString strLocalServerName;
	CString strLocalShortName;

	if (!pDocTemplate->GetDocString(strServerName,
	   CDocTemplate::regFileTypeId) || strServerName.IsEmpty())
	{
		TRACE0("Error: not enough information in DocTemplate to register OLE server.\n");
		return;
	}
	if (!pDocTemplate->GetDocString(strLocalServerName,
	   CDocTemplate::regFileTypeName))
		strLocalServerName = strServerName;     // use non-localized name
	if (!pDocTemplate->GetDocString(strLocalShortName,
		CDocTemplate::fileNewName))
		strLocalShortName = strLocalServerName; // use long name

	ASSERT(strServerName.Find(' ') == -1);  // no spaces allowed

	::StringFromCLSID(clsid, &lpszClassID);
	ASSERT (lpszClassID != NULL);

	// get path name to server
	TCHAR szLongPathName[_MAX_PATH];
	TCHAR szShortPathName[_MAX_PATH];
	::GetModuleFileName(AfxGetInstanceHandle(), szLongPathName, _MAX_PATH);
	::GetShortPathName(szLongPathName, szShortPathName, _MAX_PATH);

	LPCTSTR rglpszSymbols[NUM_REG_ARGS];
	rglpszSymbols[0] = OLE2CT(lpszClassID);
	rglpszSymbols[1] = strServerName;
	rglpszSymbols[2] = szShortPathName;
	rglpszSymbols[3] = strLocalShortName;
	rglpszSymbols[4] = strLocalServerName;
	rglpszSymbols[5] = m_pszAppName;    // will usually be long, readable name
	rglpszSymbols[6] = NULL;

	if (RegisterHelper((LPCTSTR*)rglpszWordPadRegister, rglpszSymbols, FALSE))
		RegisterHelper((LPCTSTR*)rglpszWordPadOverwrite, rglpszSymbols, TRUE);

//  RegisterExt(_T(".txt"), _T("txtfile"), IDS_TEXT_DOC, rglpszSymbols,
//      (LPCTSTR*)rglpszTxtExtRegister, (LPCTSTR*)rglpszTxtRegister, 3);
	RegisterExt(_T(".rtf"), _T("rtffile"), IDS_RICHTEXT_DOC, rglpszSymbols,
		(LPCTSTR*)rglpszRtfExtRegister, (LPCTSTR*)rglpszRtfRegister, 1);
	RegisterExt(_T(".wri"), _T("wrifile"), IDS_WRITE_DOC, rglpszSymbols,
		(LPCTSTR*)rglpszWriExtRegister, (LPCTSTR*)rglpszWriRegister, 2);
	RegisterExt(_T(".doc"), _T("WordPad.Document.1"), IDS_WINWORD6_DOC, rglpszSymbols,
		(LPCTSTR*)rglpszDocExtRegister, (LPCTSTR*)rglpszDocRegister, 1);

	// free memory for class ID
	ASSERT(lpszClassID != NULL);
	CoTaskMemFree(lpszClassID);
}
开发者ID:jetlive,项目名称:skiaming,代码行数:60,代码来源:wordpad.cpp

示例14: __declspec

extern "C" __declspec(dllexport) bool GetWorkspaceName(LPTSTR buffer, int bufSize)
{
	if (!g_app)
		return false;

	POSITION pos = g_app->GetFirstDocTemplatePosition();
	while (pos)
	{
		CDocTemplate* dt = g_app->GetNextDocTemplate(pos);
		if (strcmp(dt->GetRuntimeClass()->m_lpszClassName, "CProjectWorkspaceDocTemplate") == 0)
		{
			POSITION docPos = dt->GetFirstDocPosition();
			if (!docPos)
				break;

			CDocument* doc = dt->GetNextDoc(docPos);
			if (!doc)
				break;

			strcpy(buffer, doc->GetPathName());

			return true;
		}
	}

	return false;
}
开发者ID:Luomu,项目名称:workspacewhiz,代码行数:27,代码来源:WWhizInterfaceHelper.cpp

示例15: g_OpenPic

void g_OpenPic(const ResourceBlob *pData)
{
    // Get the document template, so we can create a new CPicDoc.
    CDocTemplate *pDocTemplate = theApp.GetPicTemplate();
    if (pDocTemplate)
    {
        // and create the PicResource for it.
        CPicDoc *pDocument = (CPicDoc*)pDocTemplate->OpenDocumentFile(NULL, TRUE);
        if (pDocument)
        {
            PicResource *pepic = new PicResource();
            if (pepic)
            {
                HRESULT hr = pepic->InitFromResource(pData);
                if (FAILED(hr))
                {
                    delete pepic;
                }
                else
                {
                    pDocument->SetEditPic(pepic, pData->GetId());
                }
            }
        }
    }
}
开发者ID:OmerMor,项目名称:SciCompanion,代码行数:26,代码来源:ResourceManagerView.cpp


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