How do I add custom controls to the common file open or file save dialogs?

Raymond Chen

In the beginning, every program had to create its own File Open and File Save dialogs. The system tried to help a little bit, with list boxes having a LB_DIR message to populate the list box from a directory.

Windows 3.1 introduced the common file dialogs, known today as “old-style dialogs“, though they were brand new back then. Now developers could use these prewritten dialogs instead of having to write their own. And users got some consistency. Win-win.

The Windows 3.1 common file dialogs could be customized by providing a replacement dialog template. The standard template is provided in the SDK under the name FileOpen.Dlg, and you could modify the template, typically by adding new check boxes or other controls, and add the modified template to your component as a custom dialog. Just keep the IDs the same for the pre-existing controls, and don’t give your new controls conflicting IDs.

Windows 95 introduced a new style of common dialog. This one uses an Explorer-style interface to select the files. Customization of this type of dialog is done by providing a dialog template not of the entire common file dialog but of just the extra controls you want to add. This style of customization was continued through Windows XP.

Windows Vista redesigned the common file dialogs again, which means another round of “Allow customization of the new thing, but keep doing the old thing when given old customizations.” But this time, they were ready. Instead of creating another extension pattern that is tied to the design of the dialog box, the extension pattern is now declarative: You use the IFile¬≠Dialog¬≠Customize interface to add controls to the common file dialogs. The interface also lets you query the state of those controls later. The precise layout of those controls, and the form which they take, is left to the operating system. This makes things (hopefully) more future-proof. Even if the design of the common file dialogs changes again in the future, existing apps which use the declarative customization can still be accommodated.

An example of customizing the file open and save dialogs is provided on MSDN, and there’s also a sample on GitHub.


Discussion is closed. Login to edit/delete existing comments.

  • c h 0

    I left a Feedback Hub problem/comment titled

    “IFileDialogCustomize in dark mode does not color correctly in Windows 10 and Windows 11”

    I don’t see any sort of ID given to that report, so a search on the title is the only way I know to find it.

    Is this not a problem but a “The precise layout of those controls, and the form which they take, is left to the operating system” thing?

    For those that cannot see the screenshot at the F-Hub (maybe the screenshot is considered private), the AddText() customizations don’t get colored as one would expect when in the dark mode theme.

  • Michael Dietrich 0

    Those customizations are often used to show previews for the selected file. E.g. Photoshop uses this to show a preview for a variety of image types. But looking at the documentation for IFileDialogCustomize seem not to provide a suitable control for such a customization:

    These controls include PushButton, ComboBox, EditBox, CheckButton, RadioButton lists, Groups, Separators, and Static Text controls.

    So this is not possible or how can this be achieved?

    • Seri Ously 0

      If I understood the results of my quick search for “IFileDialogCustomize Preview” correct, it can be achieved by implementing a preview handler to be used by the preview pane, which is already part of the standard file dialog.
      See Preview Handler Documentation for more information.

      So all you should need to do is open an IFileDialog with FOS_FORCEPREVIEWPANEON and have an preview handler for your file type available. When the user selects a file, the preview should be shown in the preview pane.

Feedback usabilla icon