Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>I recently did that using MFC, so since you seems to be using MFC as well maybe it will help:</p> <p>in:</p> <pre><code>BOOL MyApp::InitInstance() { // Call this member function from within the InitInstance member function to // enable and load the list of most recently used (MRU) files and last preview // state. SetRegistryKey("MyApp"); //I think this caused problem with Vista and up if it wasn't there //, not really sure now since I didn't wrote a comment at the time LoadStdProfileSettings(); } </code></pre> <p>//..</p> <pre><code>//function called when you save or load a file void MyApp::addToRecentFileList(boost::filesystem::path const&amp; path) { //use file_string to have your path in windows native format (\ instead of /) //or it won't work in the MFC version in vs2010 (error in CRecentFileList::Add at //hr = afxGlobalData.ShellCreateItemFromParsingName) AddToRecentFileList(path.file_string().c_str()); } //function called when the user click on a recent file in the menu boost::filesystem::path MyApp::getRecentFile(int index) const { return std::string((*m_pRecentFileList)[index]); } </code></pre> <p>//...</p> <pre><code>//handler for the menu BOOL MyFrame::OnCommand(WPARAM wParam, LPARAM lParam) { BOOL answ = TRUE; if(wParam &gt;= ID_FILE_MRU_FILE1 &amp;&amp; wParam &lt;= ID_FILE_MRU_FILE16) { int nIndex = wParam - ID_FILE_MRU_FILE1; boost::filesystem::path path = getApp()-&gt;getRecentFile(nIndex); //do something with the recent file, probably load it return answ; } } </code></pre> <p>You only need that your application is derived from CWinApp (and I use a class derived from CFrmWnd to handle the menu, maybe you do the same?).</p> <p>Tell me if that works for you. Not sure if I have everything.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload