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);
}