MRU LISTS

A Most Recently Used list (MRU list) is a series of menu items (usually at the bottom of an application’s File menu) that displays the files most recently accessed by the user. If the user clicks one of these menu items, the program reopens the corresponding file.

By convention, these menu items begin with the accelerator characters 1, 2, 3, and so forth. If you opened the File menu and pressed 2, for example, the program would reopen the second file in the MRU list.

When the user opens a new file or saves a file with a new name, that file is placed at the top of the list. Most applications display up to four items in the MRU list and, if the list ever contains more items, the oldest are removed.

Most applications remove a file from the MRU list if the application tries to open it and fails. For example, if the user selects an MRU menu item but the corresponding file has been removed from the system, the program removes the file’s menu item.

Building an MRU list isn’t too difficult in Visual Basic. The MruList example program, which is available for download on the book’s website, uses the MruList class to manage its MRU list. This class manages a menu that you want to use as an MRU list and updates the menu as the user opens and closes files. For example, if you configure the class to allow four MRU list entries and the user opens a fifth file, the class removes the oldest entry and adds the new one.

The class saves and restores the MRU list in the system’s Registry. ...

Get Visual Basic 2012 Programmer's Reference now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.