Solved

Most recently used file lists

Posted on 1998-05-31
6
216 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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 

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

ScreenConnect 6.0 Free Trial

At ScreenConnect, partner feedback doesn't fall on deaf ears. We collected partner suggestions off of their virtual wish list and transformed them into one game-changing release: ScreenConnect 6.0. Explore all of the extras and enhancements for yourself!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
ADO Memory leak with DELPHI 2007 37 181
Folder Comparison 12 54
How to know only "File created" with EventLog 3 34
notReplace  challenge 53 131
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: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
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.
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…

810 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