Solved

Most recently used file lists

Posted on 1998-05-31
6
219 Views
Last Modified: 2013-11-19
How do you read the filenames from the standard CWinApp MRU list? Is there a member variable or function which allows this list to be read. I know CWinApp has a function to add to the list but I could find no way to read it. I need a filename because I want the application to automaticaly load the most recently used file upon startup. I could save this information myself but it seems like a waste since it is already stored in the MRU list. I just don't know how to access it.
0
Comment
Question by:jhanson040697
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
6 Comments
 

Accepted Solution

by:
TXTX earned 50 total points
ID: 1315788
Call the CWinApp function (call from InitInstance):

CString s = GetProfileString("Recet File List", "File1", "*");
if (s != "*")
{
  OpenDocumentFile(s);
}
else
{
  // No MRU yet.
}
0
 

Expert Comment

by:TXTX
ID: 1315789
Recet should be Recent!
0
 
LVL 10

Expert Comment

by:RONSLOW
ID: 1315790
Here is how I do it...

CString CMyWinApp::MostRecentFile() {
  if (m_pRecentFileList->GetSize() < 1) {
    return "";
  } else {
    return (*m_pRecentFileList)[0];
  }
}

The registry method may only give you the most recently used last time the app was run .. not the curernt MRU list.  m_pRecentFileList is what to use.

NOTE: If you find this more helpful and wish to grade me, don't forget to reject the currently proposed answer so I can post mine .. or apply to EE customer service to split points.

0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:jhanson040697
ID: 1315791
In this case I only needed the file used the last time the application was run so TXTX's answer worked well for me. I am curious about m_pRecentFileList though. Is this an undocumented class member? I couldn't find any references to it in the documentation.
0
 

Expert Comment

by:TXTX
ID: 1315792
ROFL!
0
 
LVL 10

Expert Comment

by:RONSLOW
ID: 1315793
TXTX  ... I can imagine you grin :-)

CRecentFileList is, however, a well documented class for maintaining the recent file list.  But you are right in that m_pRectFileList is not a documented pointer.  It's use should be OK for now, but may change in the future.  Any use of it should be well commented as being implementation defined.  However, there is no great dependency on the internals of MFC etc to use it.

Of course, it is no more or less documented than how the most recently used file list is stored in the registry.  And my suggest method is certainly no less risky.

0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
function returning CString in a regular win32 DLL 8 215
Doc'in system (example?) BA 7 125
matchUp  challenge 6 82
Detect file exist or not 3 215
In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

738 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question