MRU in a dialog box app
-
How can I add files to MRU in a dialog box app? I tried to override OnOpenRecentFile and OnUpdateRecentFile which i have found in appui.cpp but nothing happens.
Have you tried CRecentFileList class? (see MSDN for details) Robert-Antonio "CRAY is the only computer, which runs an endless loop in just 4 hours"
-
Have you tried CRecentFileList class? (see MSDN for details) Robert-Antonio "CRAY is the only computer, which runs an endless loop in just 4 hours"
-
Yes.I have done a key in Registry and another key called Recent File List and there are all my 5 MRU, but i want to put them in a menu to appear also there .I have put ID_FILE_MRU_FILE1 but MRU don't appear.This is my problem. Thanks.
Handle an
UPDATE_COMMAND_UI
message for theID_FILE_MRU_FILE1
menu item:void CMainFrame::OnUpdateFileMruFile1(CCmdUI* pCmdUI)
{
m_MRU.UpdateMenu(pCmdUI);
}where
m_MRU
is yourCRecentFileList
object. Robert-Antonio "Friends come and leave, but teddybears stay in forever." -
Handle an
UPDATE_COMMAND_UI
message for theID_FILE_MRU_FILE1
menu item:void CMainFrame::OnUpdateFileMruFile1(CCmdUI* pCmdUI)
{
m_MRU.UpdateMenu(pCmdUI);
}where
m_MRU
is yourCRecentFileList
object. Robert-Antonio "Friends come and leave, but teddybears stay in forever." -
This solution isn't dependent on doc/view. If you want to add MRU to dialog box, use simply
CYourDialog
instead ofCMainFrame
Robert-Antonio "Love without sex is like a fish without antlers" -
Handle an
UPDATE_COMMAND_UI
message for theID_FILE_MRU_FILE1
menu item:void CMainFrame::OnUpdateFileMruFile1(CCmdUI* pCmdUI)
{
m_MRU.UpdateMenu(pCmdUI);
}where
m_MRU
is yourCRecentFileList
object. Robert-Antonio "Friends come and leave, but teddybears stay in forever."Thanks a lot.It works.But I have another problem. When I open the first file from MRU menu it works,but if i want to open the rest of 4 files I get an assert:appui.cpp line 130,ASSERT(m_pRecentFileList != NULL); But I don't have anything with BOOL CWinApp::OnOpenRecentFile(UINT nID). I did my own function. void CMyRtfDlg::OnFileMruFile1() { OnOpenRecentFile(ID_FILE_MRU_FILE1); } // added on 22 Apr 2004 void CMyRtfDlg::OnUpdateFileMruFile1(CCmdUI* pCmdUI) { m_pMRU->UpdateMenu(pCmdUI); } // @added on 22 Apr 2004 from appui.cpp // @for MRU BOOL CMyRtfDlg::OnOpenRecentFile(UINT nID) { ASSERT(m_pMRU!= NULL); ASSERT(nID >= ID_FILE_MRU_FILE1); ASSERT(nID < ID_FILE_MRU_FILE1 + (UINT)m_pMRU->GetSize()); int nIndex = nID - ID_FILE_MRU_FILE1; ASSERT((*m_pMRU)[nIndex].GetLength() != 0); TRACE2("MRU: open file (%d) '%s'.\n", (nIndex) + 1, (LPCTSTR)(*m_pMRU)[nIndex]); OnFileOpen((*m_pMRU)[nIndex]); return TRUE; }