Solved

Most recently used file lists

Posted on 1998-05-31
6
210 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
  • 3
  • 2
6 Comments
 

Accepted Solution

by:
TXTX earned 50 total points
Comment Utility
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
Comment Utility
Recet should be Recent!
0
 
LVL 10

Expert Comment

by:RONSLOW
Comment Utility
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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

Author Comment

by:jhanson040697
Comment Utility
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
Comment Utility
ROFL!
0
 
LVL 10

Expert Comment

by:RONSLOW
Comment Utility
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

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

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 …
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.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

771 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now