?
Solved

Most recently used file lists

Posted on 1998-05-31
6
Medium Priority
?
223 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 150 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
Percona Live Europe 2017 | Sep 25 - 27, 2017

The Percona Live Open Source Database Conference Europe 2017 is the premier event for the diverse and active European open source database community, as well as businesses that develop and use open source database software.

 

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

Get MySQL database support online, now!

At Percona’s web store you can order your MySQL database support needs in minutes. No hassles, no fuss, just pick and click. Pay online with a credit card.

Question has a verified solution.

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

Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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.
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …
Suggested Courses

764 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