您的位置:首页 > 其它

MFC单文档应用程序默认打开一个文件

2010-12-07 23:00 645 查看
1.默认打开上一次打开的文档:

在CxxApp::InitInstance中m_pMainWnd->ShowWindow(SW_SHOW)之前,加入如下代码:

 

 CRecentFileList *pRFileList;
 pRFileList = m_pRecentFileList;

 if(cmdInfo.m_strFileName.IsEmpty())
 {
  int Max=pRFileList->GetSize();
  if(Max>0)
  {
   CString strFileName;
   strFileName=pRFileList->m_arrNames[0];   // choose the 1st
   if(strFileName.IsEmpty()) return TRUE;
   OpenDocumentFile(strFileName);
  }
 }

 

2.默认打开指定的文档:

在CxxApp::InitInstance中m_pMainWnd->ShowWindow(SW_SHOW)之前,加入如下代码:

 

 CString strDefaultFile = _T("c://Default.conf");
 if (PathFileExists(strDefaultFile))
 {
   OpenDocumentFile(strDefaultFile);
 }
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  文档 mfc c
相关文章推荐