// if you want to open a recent file on start up. #if 0 if(cmdInfo.m_strFileName.IsEmpty()) { int Max=RFileList->GetSize(); if(Max>0) { CString strFileName; strFileName=RFileList->m_arrNames[0];// choose the 1st if(strFileName.IsEmpty()) return TRUE; OpenDocumentFile(strFileName); } } #endif
这个找本权威一点的MFC都有吧。
#if 0
if(cmdInfo.m_strFileName.IsEmpty())
{
int Max=RFileList->GetSize();
if(Max>0)
{
CString strFileName;
strFileName=RFileList->m_arrNames[0];// choose the 1st
if(strFileName.IsEmpty()) return TRUE;
OpenDocumentFile(strFileName);
}
}
#endif
CRecentFileList *RFileList;
BOOL CxxxxApp::InitInstance()
{
LoadStdProfileSettings(); // Load standard INI file options (including MRU)
//
RFileList=m_pRecentFileList;
}
2、我要调用视图类的一个函数打开最近列表里的文件pview->LoadFile(strFileName),那要怎么实现?
BOOL CxxxxxDoc::OnOpenDocument(LPCTSTR lpszPathName)
{
if (!CDocument::OnOpenDocument(lpszPathName))// file not exist !
return FALSE;
}
2>.
void CMainFrame::OnFileMruFile1()
{
// TODO: Add your command handler code here
FileName=RFileList->m_arrNames[0];
}