コード例 #1
0
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);
}
コード例 #2
0
ファイル: MainFrm.cpp プロジェクト: victimofleisure/WaveShop
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);
}
コード例 #3
0
ファイル: doccore.cpp プロジェクト: pixelspark/corespark
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;
	}
コード例 #4
0
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 ();
	}
}
コード例 #5
0
ファイル: SaveOptionPage.cpp プロジェクト: BennyThink/TimeM
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);
			}
		}
	}
}
コード例 #6
0
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() );
		}
	}
}
コード例 #7
0
ファイル: MainFrm.cpp プロジェクト: cdesjardins/DCom
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();
                    }
                }
            }
        }
    }
}
コード例 #8
0
ファイル: MainFrm.cpp プロジェクト: cdesjardins/DCom
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();
                }
            }
        }
    }
}
コード例 #9
0
ファイル: docmangr.cpp プロジェクト: ABratovic/open-watcom-v2
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 ) );
}
コード例 #10
0
ファイル: inputdoc.cpp プロジェクト: cdyangupenn/CarlaLegacy
// 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;
}
コード例 #11
0
ファイル: inputdoc.cpp プロジェクト: cdyangupenn/CarlaLegacy
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());
	}
}
コード例 #12
0
ファイル: MainFrm.cpp プロジェクト: tchv71/StartPP
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);
		}
	}
}
コード例 #13
0
ファイル: wordpad.cpp プロジェクト: jetlive/skiaming
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);
}
コード例 #14
0
void 
CMainFrame::OnWindowNew3d() 
{
   CMDIChildWnd*  pActiveChild = MDIGetActive();
   CDocument* pDocument;
   
   if ( pActiveChild == NULL ||
      ( pDocument = pActiveChild->GetActiveDocument() ) == NULL ) 
   {
      TRACE("Warning:  No active document for WindowNew command\n");
      AfxMessageBox(AFX_IDP_COMMAND_FAILURE);
      return; // Command failed
   }
   
   // Otherwise, we have a new frame!
   CDocTemplate* pTemplate = ((CDemoApp*)AfxGetApp())->m_pTemplate3dView;
   ASSERT_VALID( pTemplate );
   
   CFrameWnd* pFrame =
      pTemplate->CreateNewFrame( pDocument, pActiveChild );
   
   if (pFrame == NULL) 
   {
      TRACE( "Warning:  failed to create new frame\n" );
      AfxMessageBox( AFX_IDP_COMMAND_FAILURE );
      return; // Command failed
   }
   
   pTemplate->InitialUpdateFrame( pFrame, pDocument );

   ((CDemoDoc*)pDocument)->turnOnComputePoints();
}
コード例 #15
0
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;
}
コード例 #16
0
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());
                }
            }
        }
    }
}
コード例 #17
0
ファイル: MainFrm.cpp プロジェクト: zxlooong/bcgexp
void CMainFrame::OnWorkOffline()
{
    CBCGPIE7DemoView::m_bWorkOffline = !CBCGPIE7DemoView::m_bWorkOffline;

    POSITION posTemplate = theApp.m_pDocManager->GetFirstDocTemplatePosition ();
    while (posTemplate != NULL)
    {
        CDocTemplate* pTemplate = theApp.m_pDocManager->GetNextDocTemplate (posTemplate);
        if (pTemplate != NULL)
        {
            POSITION posDocument = pTemplate->GetFirstDocPosition ();
            while (posDocument != NULL)
            {
                CDocument* pDocument = 	pTemplate->GetNextDoc (posDocument);
                if (pDocument != NULL)
                {
                    POSITION posView = pDocument->GetFirstViewPosition ();
                    while (posView != NULL)
                    {
                        CHtmlView* pView = DYNAMIC_DOWNCAST(CHtmlView, pDocument->GetNextView (posView));
                        if (pView != NULL)
                        {
                            pView->SetOffline (CBCGPIE7DemoView::m_bWorkOffline);
                        }
                    }
                }
            }
        }
    }
}
コード例 #18
0
ファイル: PlayerFrame.cpp プロジェクト: joshlong/libcd
BOOL CPlayerFrame::OnCopyData(CWnd* pWnd, COPYDATASTRUCT* pCopyDataStruct) 
{
    CDocTemplate*	pTemplate = NULL;
    POSITION		pos;
    CDocument*		pDocument = NULL;

	pos = AfxGetApp()->GetFirstDocTemplatePosition();

	pTemplate = AfxGetApp()->GetNextDocTemplate( pos );

	if ( pCopyDataStruct->dwData == 0 && pCopyDataStruct->lpData )
	{
		if ( pTemplate )
		{

			POSITION docpos = pTemplate->GetFirstDocPosition( );

			// Loop through documents in this template
			while ( docpos )
			{
				VERIFY( pDocument = pTemplate->GetNextDoc(docpos) );

				// update all view attached to this document
				pDocument->UpdateAllViews( NULL, WM_PLAYER_ADD_FILE, (CObject*)pCopyDataStruct->lpData );
			}
		}
	}
	
	return CMainFrame::OnCopyData(pWnd, pCopyDataStruct);
}
コード例 #19
0
ファイル: dxtex.cpp プロジェクト: Axitonium/SourceEngine2007
HRESULT CDxtexApp::RestoreDeviceObjects(VOID)
{
    // Tell each view of each doc to restore
    POSITION pos = GetFirstDocTemplatePosition();
    CDocTemplate* pDocTemplate = GetNextDocTemplate( pos );

    pos = pDocTemplate->GetFirstDocPosition();
    for( ; ; )
    {
        CDocument* pDoc = NULL;
        if( pos == NULL )
            break;
        pDoc = pDocTemplate->GetNextDoc( pos );
        if( pDoc == NULL )
            break;
        POSITION posView;
        CDxtexView* pView = NULL;
        posView = pDoc->GetFirstViewPosition();
        for( ; ; )
        {
            if( posView == NULL )
                break;
            pView = (CDxtexView*)pDoc->GetNextView( posView );
            if( pView == NULL )
                break;
            pView->RestoreDeviceObjects();
        }
    }
    return S_OK;
}
コード例 #20
0
ファイル: MainFrm.cpp プロジェクト: cdesjardins/DCom
void CMainFrame::SetConfig(SDComCfg *sDComCfg)
{
    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->SetConfig(sDComCfg);
                }
            }
        }
    }
}
コード例 #21
0
BOOL CKSFileDialog::DoSave(LPCTSTR lpszPathName, BOOL bReplace)
{
	if (m_pDoc==NULL){ASSERT (FALSE);return FALSE;}
	CString newName = lpszPathName;
	if (newName.IsEmpty())
	{
		CDocTemplate* pTemplate = m_pDoc->GetDocTemplate();
		ASSERT(pTemplate != NULL);

		newName = m_pDoc->GetPathName();
		if (bReplace && newName.IsEmpty())
		{
			newName = m_pDoc->GetTitle();
			// 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] == '.');
				newName += strExt;
			}
		}

		if (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 (!m_pDoc->OnSaveDocument(newName))
	{
		if (lpszPathName == NULL)
		{
			// be sure to delete the file
			try
			{
				CFile::Remove(newName);
			}
			catch( CException * e)
			{
				TRACE0("Warning: failed to delete file after failed SaveAs.\n");
				do { e->Delete(); } while (0);
			}
		}
		return FALSE;
	}

	// reset the title and change the document name
	if (bReplace)
		m_pDoc->SetPathName(newName);

	return TRUE;        // success
}
コード例 #22
0
ファイル: BonfireDoc.cpp プロジェクト: Qeeet/nz-software
// modified from doccore.cpp
BOOL CBonfireDoc::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] == '.');
				newName += strExt;
			}
		}

		if (SaveFileDialog(AfxGetMainWnd(),newName,newName,NULL,
			GetFileFilter(FILTER_FILES),6,GetDefExt(FILTER_FILES)) <= 0)
			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)
			{
				TRACE0("Warning: failed to delete file after failed SaveAs.\n");
				do { e->Delete(); } while (0); //DELETE_EXCEPTION(e);
			}
			END_CATCH_ALL
		}
		return FALSE;
	}
コード例 #23
0
ファイル: docmangr.cpp プロジェクト: ABratovic/open-watcom-v2
void CDocManager::CloseAllDocuments( BOOL bEndSession )
/*****************************************************/
{
    POSITION position = m_templateList.GetHeadPosition();
    while( position != NULL ) {
        CDocTemplate *pTemplate = (CDocTemplate *)m_templateList.GetNext( position );
        ASSERT( pTemplate != NULL );
        pTemplate->CloseAllDocuments( bEndSession );
    }
}
コード例 #24
0
ファイル: FindByStrDlg.cpp プロジェクト: tvi123/rep123
void CFindByStrDlg::OnOK()
{
    // TODO: Add extra validation here
    try {
        UpdateData(TRUE);
        vector<CRossDoc*> RossDocs;

        if(GetCheckedRadioButton(IDC_FIND_IN_ALL_DICTS,IDC_FIND_IN_ACTIVE_DICT)==IDC_FIND_IN_ALL_DICTS)
        {
            CDocTemplate* pRossDocTemplate = GetRossDocTemplate();
            POSITION pos = pRossDocTemplate->GetFirstDocPosition();
            while( pos )
                RossDocs.push_back ((CRossDoc*)pRossDocTemplate->GetNextDoc(pos));
        }
        else
        {
            RossDocs.push_back(m_pActiveRossDoc);
        };

        CWaitCursor C;
        vector<CRossPocketItem> PocketItems;
        for (int RossDocNo=0; RossDocNo<RossDocs.size();  RossDocNo++)
        {
            CRossDoc* pRossDoc = RossDocs[RossDocNo];
            CTempArticle A;
            A.m_pRoss  = pRossDoc->GetRoss();
            size_t UnitNo;

            try {
                for (UnitNo = 0;  UnitNo < pRossDoc->GetRoss()->GetUnitsSize(); UnitNo++)
                {
                    if (pRossDoc->GetRoss()->IsEmptyArticle(UnitNo)) continue;
                    A.ReadFromDictionary(UnitNo, false, true);
                    if (A.GetArticleStr().find(m_FindString) != -1)
                        PocketItems.push_back(CRossPocketItem(UnitNo, pRossDoc));
                };
            }
            catch (...)
            {
                string Mess = string ("Errors in article ") + pRossDoc->GetRoss()->GetEntryStr(UnitNo) ;
                AfxMessageBox (Mess.c_str());
            };

        };
        C.Restore();

        OpenPocket(PocketItems, CString("Search Results for ") + m_FindString);
    }
    catch (...)
    {
        AfxMessageBox ("Something is wrong");
    };

    CDialog::OnOK();
}
コード例 #25
0
bool CLeftPanelDlgBar::IsLastDocValid()
{
	// look whether the last doc is still valid
	POSITION pos = AfxGetApp ()->GetFirstDocTemplatePosition ();
	CDocTemplate* pDocTmpl = AfxGetApp ()->GetNextDocTemplate (pos);
	for (pos = pDocTmpl->GetFirstDocPosition (); pos; )
		if (pDocTmpl->GetNextDoc (pos) == m_pLastDoc)
			return true;

	return false;
}
コード例 #26
0
ファイル: ippsDemo.cpp プロジェクト: vinnie38170/klImageCore
//----------------------------------------------------------------------------
// OpenNewDoc opens new user customized document.
// If newView == VIEW_DEMO then document will be created with signal default
// parameters and will be shown in graphic view;
// if newView == NEW_TEXT then document will be created with digital default
// parameters and will be shown in digital view
// if newView == VIEW_CHAR then document will be created with character default
// parameters and will be shown in character view
//----------------------------------------------------------------------------
void CippsDemoApp::OpenNewDoc(int newView)
{
   POSITION tPos = GetFirstDocTemplatePosition( );
   CDocTemplate* pTpl;
   for (int i=0; i<=newView; i++)
      pTpl = GetNextDocTemplate(tPos);
   ASSERT(pTpl);
   CippsDemoDoc* pDoc = (CippsDemoDoc*)pTpl->OpenDocumentFile(NULL);
   if (pDoc)
      pDoc->InitHisto();
}
コード例 #27
0
ファイル: SnoopyPro.cpp プロジェクト: cyphunk/sectk
CUSBLogDoc *CSnoopyProApp::CreateNewDocument(void)
{
    ASSERT(NULL != m_pDocManager);
    POSITION pos = 	m_pDocManager->GetFirstDocTemplatePosition();
    CDocTemplate* pTemplate = (CDocTemplate*)m_pDocManager->GetNextDocTemplate(pos);
    ASSERT(pTemplate != NULL);
    ASSERT_KINDOF(CDocTemplate, pTemplate);
    CUSBLogDoc *pDocument = (CUSBLogDoc *) pTemplate->OpenDocumentFile(NULL);
    ASSERT(NULL != pDocument);
    ASSERT_KINDOF(CUSBLogDoc, pDocument);
    return pDocument;
}
コード例 #28
0
ファイル: PocketForm.cpp プロジェクト: deNULL/seman
int OpenPocket(   const vector<CRossPocketItem>& UnitNos,
			  CString    Title) 
{

	CDocTemplate* tmpl = GetRossPocketTemplate();;

	CDocument* pDocument = tmpl->CreateNewDocument();

	if (pDocument == NULL)
	{
		TRACE0("CDocTemplate::CreateNewDocument returned NULL.\n");
		AfxMessageBox(AFX_IDP_FAILED_TO_CREATE_DOC);
		return false;
	}

    ASSERT_VALID(pDocument);

	pDocument->m_bAutoDelete = FALSE;   // don't destroy if something goes wrong
	CFrameWnd* pFrame = tmpl->CreateNewFrame(pDocument, NULL);
	pDocument->m_bAutoDelete = TRUE;
	if (pFrame == NULL)
	{
		AfxMessageBox(AFX_IDP_FAILED_TO_CREATE_DOC);
		delete pDocument;       // explicit delete on error
		return FALSE;
	};

	ASSERT_VALID(pFrame);

	pDocument->SetPathName(CString("An entry subset by  ")+Title);
	

	// open an existing document
	tmpl->InitialUpdateFrame(pFrame, pDocument, TRUE);

	POSITION pos =  pDocument->GetFirstViewPosition();
	CPocketForm* V = (CPocketForm*)(pDocument->GetNextView(pos));
	V->m_PocketItems = UnitNos;
    V->m_WordList.InsertColumn(1,"Словарный вход", LVCFMT_LEFT, 200);
	V->m_WordList.InsertColumn(2,"Номер значения", LVCFMT_LEFT, 60);
	V->m_WordList.InsertColumn(2,"Название словаря", LVCFMT_LEFT, 60);
	V->m_WordList.SetItemCountEx(UnitNos.size());
	V->m_UnitsSize.Format ("Число словарных входов : %i",    V->m_WordList.GetItemCount());
    V->UpdateData(FALSE);
    V->m_WordList.UpdateData(FALSE);
    V->m_WordList.Invalidate();	
	V->m_Title = Title;

	// установка размеров
	V->GetParent()->SetWindowPos(NULL, 0,0, 535 , 500, SWP_SHOWWINDOW|SWP_NOZORDER|SWP_NOMOVE);
	return true;
};
コード例 #29
0
ファイル: Docroot.cpp プロジェクト: ChrisMoreton/Test3
void OleDocRoot::SetTitle(LPCTSTR lpszTitle)
  {
  CString s(lpszTitle);
  CDocTemplate* pTempl = GetDocTemplate();
  if (pTempl)
    {
    flag Found = True;
    while (Found)
      {
      Found = False;
      POSITION Pos = pTempl->GetFirstDocPosition();
      while (Pos && !Found)
        {
        CDocument * pDoc = pTempl->GetNextDoc(Pos);
        if (pDoc!=this)
          {
          CString Title = pDoc->GetTitle();
          if (Title.GetLength()==s.GetLength() && _stricmp((const char*)s, (const char*)Title)==0)
            Found = True;
          }
        }
      if (Found)
        {
        CString Ext = "";
        int DotPos = s.ReverseFind('.');
        if (DotPos>=0)
          {
          Ext = s.Mid(DotPos, 256);
          s = s.Left(DotPos);
          }
        int _Pos = s.ReverseFind('_');
        if (_Pos>=0)
          {
          CString ss = s.Mid(_Pos+1, 256);
          s = s.Left(_Pos+1);
          if (ss.GetLength()>0)
            {
            char Buff[32];
            sprintf(Buff, "%d", atoi((const char*)ss) + 1);
            s += Buff;
            }
          else
            s += "1";
          }
        else
          s += "_1";
        s += Ext;
        }
      }
    }
  COleLinkingDoc::SetTitle((const char*)s);
  }
コード例 #30
0
ファイル: docmangr.cpp プロジェクト: ABratovic/open-watcom-v2
BOOL CDocManager::SaveAllModified()
/*********************************/
{
    POSITION position = m_templateList.GetHeadPosition();
    while( position != NULL ) {
        CDocTemplate *pTemplate = (CDocTemplate *)m_templateList.GetNext( position );
        ASSERT( pTemplate != NULL );
        if( !pTemplate->SaveAllModified() ) {
            return( FALSE );
        }
    }
    return( TRUE );
}