Solved

Most recently used file lists

Posted on 1998-05-31
6
213 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
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
WinWaitActive parameters 12 31
dog bark java program 15 87
move a line in eclipse 3 81
isEverywhere  challenge 19 72
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…
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.
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.
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

911 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

16 Experts available now in Live!

Get 1:1 Help Now