File Dialogs in MFC 9.0

Windows Vista redesigned the way the file dialogs look. MFC 9.0 (that will ship with Visual Studio 2008) was updated to support the new look and feel. If you compile your MFC application with VS 2008 you get the new file dialogs with no additional change. On the other hand if you run the application under Win XP the old file dialogs are shown. This is possible because of an additional parameter to the constructor of CFileDialog. The old constructor signature was:

The new constructor in MFC 9.0 has an additional parameter, a BOOL flag indicating whether the Vista dialogs should be displayed of not.

To display the Vista file dialogs, all you have to do is instantiate a CFileDialog object and create the dialog itself:

Vista look and feel file dialog

You can still use the old file dialog look and feel if you set the last parameter to FALSE:

Win XP look and feel file dialog

This old dialog is what you automatically get when running on a previous operating system.

2 Replies to “File Dialogs in MFC 9.0”

  1. I’ve to make sure the last parameter is FALSE in VS2008, since the program in XP sometimes have trouble bring up vista style dialog (hangs) if I don’t do it.

  2. When set to TRUE for Vista style file open dialog, the dialog will crash in a very bad way when the SetWindowText() is called.

    Just a heads up.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.