Fixing up MFC Office 2007 Ribbon Applications, Part 2

Posted by Matt | Filed under , , , ,

In my continuing series, I am providing some workarounds/solutions to some issues in the Visual Studio 2008 SP1 projects created that use the new “MFC Feature Pack”.

Today’s issue is the recent file list.

If you create a new project using the MFC Application Wizard, and you specify an Office 2007 Ribbon user interface, then your application will be created with the ability to have a recent file list.  This list is located in the File or “Application” menu (the “Pearl” in the top-left corner of the application).  The space is there, but if you run your application, you’ll notice that the recent file list is never populated with files you open or save.

The reason for this is because the project was created using a maximum of 0 files for the recent file list.  Take a look in your application’s main .cpp file in InitInstance() of your class.  You’ll notice a call to LoadStdProfileSettings().  It is passing as a parameter ‘0’.  This means to make the recent file list 0 elements long, or empty. 

To fix this issue, set the parameter to LoadStdProfileSettings() to something realistic, or remove the parameter completely since it has a default value of 4.

In summary: you need to change this:

LoadStdProfileSettings(0);  // Load standard INI file options

to:

LoadStdProfileSettings();  // Load standard INI file options

I have submitted the issue to Microsoft.  You can view the issue report here.

Comments are closed