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


C++ CDocTemplate::GetDocString方法代码示例

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


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

示例1: UpdateRegistry

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

示例2: OnFileOpen

void CImportExportApp::OnFileOpen() 
{
  CFileDialog dlg(TRUE,
				  NULL,
				  NULL,
				  OFN_HIDEREADONLY | OFN_FILEMUSTEXIST,
				  NULL, 
				  NULL );
  

	CString initdir(((OCC_BaseApp*) AfxGetApp())->GetInitDataDir());
	initdir += "\\Data";

	dlg.m_ofn.lpstrInitialDir = initdir;

	CString strFilter;
	CString strDefault;

	POSITION pos = GetFirstDocTemplatePosition();

	CDocTemplate* pTemplate = GetNextDocTemplate(pos);
	CString strFilterExt, strFilterName;
	if (pTemplate->GetDocString(strFilterExt, CDocTemplate::filterExt) &&
		!strFilterExt.IsEmpty() &&
		pTemplate->GetDocString(strFilterName, CDocTemplate::filterName) &&
		!strFilterName.IsEmpty()) {
		// add to filter
		strFilter += strFilterName;
		ASSERT(!strFilter.IsEmpty());  // must have a file type name
		strFilter += (TCHAR)'\0';  // next string please
		strFilter += (TCHAR)'*';
		strFilter += strFilterExt;
		strFilter += (TCHAR)'\0';  // next string please
		dlg.m_ofn.nMaxCustFilter++;		
	}
	// append the "*.*" all files filter
	CString allFilter;
	VERIFY(allFilter.LoadString(AFX_IDS_ALLFILTER));
	strFilter += allFilter;
	strFilter += (TCHAR)'\0';   // next string please
	strFilter += _T("*.*");
	strFilter += (TCHAR)'\0';   // last string
	dlg.m_ofn.nMaxCustFilter++;
	dlg.m_ofn.lpstrFilter = strFilter;

  if (dlg.DoModal() == IDOK) 
  {
	AfxGetApp()->OpenDocumentFile(dlg.GetPathName());
  }	
}
开发者ID:AsherBond,项目名称:MondocosmOS,代码行数:50,代码来源:ImportExportApp.cpp

示例3: RegFileType

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

示例4: OnFileSaveAs

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

示例5: DoSave

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

示例6: DoSave

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
}
开发者ID:amikey,项目名称:tradingstrategyking,代码行数:59,代码来源:XFDialog.cpp

示例7: DoSave

// 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;
	}
开发者ID:Qeeet,项目名称:nz-software,代码行数:59,代码来源:BonfireDoc.cpp

示例8: GetTemplate

//----------------------------------------------------------------------------
CDocTemplate* GetTemplate( CString Name )
{
	// получение template документа статьи
	POSITION pos = AfxGetApp()->GetFirstDocTemplatePosition();
	CDocTemplate* tmpl;
	CString S;
	do {
		tmpl = AfxGetApp()->GetNextDocTemplate (pos);
		tmpl->GetDocString (S, CDocTemplate::regFileTypeId);
	}
	while ((tmpl != 0) &&  (S != Name));

	ASSERT (tmpl);

	return tmpl;
}
开发者ID:tvi123,项目名称:rep456,代码行数:17,代码来源:MorphwizardView.cpp

示例9: HasRegistered

BOOL CSaveOptionPage::HasRegistered(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();
			return (strTemp.Compare(strFileTypeId) == 0);
		}
	}
	return FALSE;
}
开发者ID:BennyThink,项目名称:TimeM,代码行数:19,代码来源:SaveOptionPage.cpp

示例10: UnRegFileType

void CSaveOptionPage::UnRegFileType(LPCTSTR pszType)
{
	POSITION posTmpl = AfxGetApp()->GetFirstDocTemplatePosition();
	if(posTmpl != NULL)
	{
		CDocTemplate* pTemplate = AfxGetApp()->GetNextDocTemplate(posTmpl);
		CString strFileTypeId;
		if (pTemplate->GetDocString(strFileTypeId, CDocTemplate::regFileTypeId))
		{
			CString strTemp = AfxGetApp()->GetProfileString(_T("Settings"), pszType);
			if(strTemp.Compare(strFileTypeId) != 0)
			{
				AfxRegSetValue(
					HKEY_CLASSES_ROOT, pszType, REG_SZ,
					strTemp, lstrlen(strTemp) * sizeof(TCHAR));
			}
		}
	}
}
开发者ID:BennyThink,项目名称:TimeM,代码行数:19,代码来源:SaveOptionPage.cpp

示例11: DoSaveAs

BOOL CEtsEodManagerDoc::DoSaveAs()
{
	CDocTemplate* pTemplate = GetDocTemplate();
	ASSERT(pTemplate != NULL);

	CString strNewName;
	if(m_bIsCurrent)
	{
		strNewName = CModuleVersionEx::GetFilePath(m_strPathName);
		COleDateTime dtToday(COleDateTime::GetCurrentTime());

		strNewName += _T("EodReport_");
		strNewName += dtToday.Format(_T("%Y%m%d"));
		CString strExt;
		pTemplate->GetDocString(strExt, CDocTemplate::filterExt);
		strNewName += strExt;
	}
	else
		strNewName = m_strPathName;

	if(!AfxGetApp()->DoPromptFileName(strNewName,
		AFX_IDS_SAVEFILECOPY, OFN_HIDEREADONLY | OFN_PATHMUSTEXIST, FALSE, pTemplate))
		return FALSE;       // don't even attempt to save

	strNewName.Trim();

	if(_IsCurrent(strNewName))
	{
		AfxGetMainWnd()->MessageBox(_T("Can't save opened report to current report file."), NULL, MB_ICONSTOP);
		return FALSE;
	}

	CWaitCursor wait;
	if(!OnSaveDocument(strNewName))
		return FALSE;

	return TRUE;        // success
}
开发者ID:AlexS2172,项目名称:IVRMstandard,代码行数:38,代码来源:EtsEodManagerDoc.cpp

示例12: OnNewDocument

BOOL DocRoot::OnNewDocument()
  {
  if (!CDocument::OnNewDocument())
    return False;
  
  if (gs_Exec.Busy())
    {
    LogError("SysCAD", 0, "Must not be running");
    return False;
    }

  if (gs_pPrj->pPrjDoc==NULL && !gs_pPrj->bDoingLoad)//sPrjFile.Length() > 0)
    {
    LogError("SysCAD", 0, "A project must be opened or a new project created.");
    return False;
    }

  /*CString s = GetTitle();
  Strng T = PrjFiles();
  T += (const char*)s;
  GetDocTemplate()->GetDocString(s, CDocTemplate::filterExt);
  T += (const char*)s;
  SetPathName(T());
  Strng T1,T2;
  T1.FnName(T());
  T2.FnExt(T());
  T = T1;
  T += T2;
  SetTitle(T());*/

  gs_pCmd->ProcessAStr("\x1b"); //Ensure there are no half complete commands
  gs_pCmd->ProcessAStr("\x1b"); //Ensure there are no half complete commands, call more than once!

  CDocTemplate* pTemplate = GetDocTemplate();
  CString s;
  bool GrfChangeName = false;
  if (1)
    {
    pTemplate->GetDocString(s, CDocTemplate::filterExt);
    if (s==".scg")
      {
      s = "05_Flowsheet.scg";
      SetTitle(s); //this may alter title;
      GrfChangeName = true;
      //ChooseTitle(this, s);
      //SetTitle(s);
      }

    }
  if (!GrfChangeName)
    {
    s = GetTitle();
    Strng T = (const char*)s;
    pTemplate->GetDocString(s, CDocTemplate::filterExt);
    T += (const char*)s;
    SetTitle(T()); //this may alter title;
    }
  Strng PathN = PrjFiles();
  s = GetTitle();
  PathN += (const char*)s;
  SetPathName(PathN()); //do this AFTER SetTitle

  OnAttachDoc();
  OnActivate(True);

  //gs_pCmd->SetDocForCmds(this);
  //gs_pCmd->ProcessAStr("CLEAR DOCUMENT \r");
  //gs_pCmd->SetDocForCmds(NULL);
  bIsOpen = True;
  return True;
  }
开发者ID:ChrisMoreton,项目名称:Test3,代码行数:71,代码来源:Docroot.cpp

示例13: DoSave

//NBNB: KGA: I am overiding this undocumented function; 
//      3 May 1996 from doccore.cpp; check with future versions of MFC
//      Last checked Feb 1997 with MSVC++/MFC version 4.2
BOOL DocRoot::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;
#ifndef _MAC
			// check for dubious filename
			int iBad = newName.FindOneOf(_T(" #%;/\\"));
#else
			int iBad = newName.FindOneOf(_T(":"));
#endif
			if (iBad != -1)
				newName.ReleaseBuffer(iBad);

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

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

	CWaitCursor wait;

	if (!OnSaveDocument(newName))
	{
    /* KGA, DO NOT DELETE !!!
		if (0 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");
				DELETE_EXCEPTION(e);
			}
			END_CATCH_ALL
		}*/
		return FALSE;
	}

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

	return TRUE;        // success
}
开发者ID:ChrisMoreton,项目名称:Test3,代码行数:76,代码来源:Docroot.cpp

示例14: SetTitle

void DocRoot::SetTitle(LPCTSTR lpszTitle)
  {
  CString s(lpszTitle);
  CDocTemplate* pTempl = GetDocTemplate();
  if (pTempl)
    {
    CString se;
    pTempl->GetDocString(se, CDocTemplate::filterExt);
    bool Grf = (se==".scg");
    int No = 5;
    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);
          }
        if (Grf)
          {
          s.Format("%02d%s", No, "_Flowsheet");
          No += 5;
          }
        else
          {
          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;
        }
      }
    }
  CDocument::SetTitle((const char*)s);
  }
开发者ID:ChrisMoreton,项目名称:Test3,代码行数:64,代码来源:Docroot.cpp

示例15: AfxGetApp

CBCGPFileDialog::CBCGPFileDialog (LPCTSTR lpszCaption, BOOL bNewPage, LPCTSTR lpszDefExt, LPCTSTR lpszFileName,
		DWORD dwFlags, LPCTSTR lpszFilter, CWnd* pParentWnd) :
		CFileDialog (TRUE /*bOpenFileDialog*/, lpszDefExt, lpszFileName, dwFlags, lpszFilter, pParentWnd
#if _MSC_VER >= 1500
			,0 , FALSE		// Not Vista-style dialog
#endif
			),
		m_pImagesNew (NULL),
		m_bNewPage (bNewPage),
		m_strCaption (lpszCaption),
		m_hIconBig (NULL),
		m_hIconSmall (NULL),
		m_iLogoAreaHeight (0),
        m_iExtraWidth (0),
        m_iExtraHeight (0)
{
	m_iNewItemIndex = -1;
	m_pBmpLogo = NULL;

	CDocManager* pDocManager = AfxGetApp ()->m_pDocManager;
	if (pDocManager != NULL && lpszFilter == NULL)
	{
		CString strDefault;
		BOOL bFirst = TRUE;
		m_strFilter.Empty();
		for (POSITION pos = pDocManager->GetFirstDocTemplatePosition (); pos != NULL;)
		{
			CDocTemplate* pTemplate = pDocManager->GetNextDocTemplate (pos);
			ASSERT_VALID (pTemplate);
			
			CString strFilterExt, strFilterName;
			
			if (pTemplate->GetDocString (strFilterExt, CDocTemplate::filterExt) &&
				!strFilterExt.IsEmpty() &&
				pTemplate->GetDocString(strFilterName, CDocTemplate::filterName) &&
				!strFilterName.IsEmpty())
			{
#if _MSC_VER >= 1300
				int iStart = 0;
				m_strFilter += strFilterName;
				m_strFilter += (TCHAR)'\0';
				do
				{
					CString strExtension = strFilterExt.Tokenize( _T( ";" ), iStart );
					
					if (iStart != -1)
					{
						// a file based document template - add to filter list
						
						// If you hit the following ASSERT, your document template 
						// string is formatted incorrectly. The section of your 
						// document template string that specifies the allowable file
						// extensions should be formatted as follows:
						// .<ext1>;.<ext2>;.<ext3>
						// Extensions may contain wildcards (e.g. '?', '*'), but must
						// begin with a '.' and be separated from one another by a ';'.
						// Example:
						// .jpg;.jpeg
						ASSERT(strExtension[0] == '.');
						if ( strDefault.IsEmpty() )
						{
							// set the default extension
							strDefault = strExtension.Mid( 1 ); // skip the '.'
							m_ofn.lpstrDefExt = const_cast< LPTSTR >((LPCTSTR)strDefault);
							m_ofn.nFilterIndex = m_ofn.nMaxCustFilter + 1; // 1 based number
						}
						
						m_strFilter += (TCHAR)'*';
						m_strFilter += strExtension;
						m_strFilter += (TCHAR)';'; // Always append a ';'. The last ';' will get replaced with a '\0' later.
					}
				} while (iStart != -1);
				m_strFilter.SetAt( m_strFilter.GetLength()-1, '\0' );; // Replace the last ';' with a '\0'
				m_ofn.nMaxCustFilter++;
				
#else
				// a file based document template - add to filter list
				ASSERT(strFilterExt[0] == '.');
				if (bFirst)
				{
					strDefault = ((LPCTSTR)strFilterExt) + 1; // skip the '.'
					m_ofn.lpstrDefExt = strDefault;
					m_ofn.nFilterIndex = m_ofn.nMaxCustFilter + 1; // 1 based number
				}
				// add to filter
				m_strFilter += strFilterName;
				ASSERT(!m_strFilter.IsEmpty()); // must have a file type name
				m_strFilter += (TCHAR)'\0'; // next string please
				m_strFilter += (TCHAR)'*';
				m_strFilter += strFilterExt;
				m_strFilter += (TCHAR)'\0'; // next string please
				m_ofn.nMaxCustFilter++;
#endif
			}
			bFirst = FALSE;
		}
		
		CString allFilter;
		VERIFY(allFilter.LoadString(AFX_IDS_ALLFILTER));
		m_strFilter += allFilter;
//.........这里部分代码省略.........
开发者ID:iclosure,项目名称:jframework,代码行数:101,代码来源:BCGPFileDialog.cpp


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