What defines an old-style common dialog?

In the documentation for the OPEN­FILE­NAME structure, there are many references to "old-style" dialogs. What is an old-style dialog, how do you get one, and how is it different from a new-style dialog?

So-called "old-style" dialogs are the File Open and File Save dialogs from Windows 3.1. Here's roughly what they looked like:

File name: Folders:
📁 C:\
List files of type: Drives:
Text files (*.txt)
🖴 C:

These are not the "new" style dialogs that resemble an Explorer window. They are the old-fashioned dialogs that scream "I was written in the early 1990s!"

When you use an old-style dialog, Windows basically uses the code that was originally written for Windows 3.1, because programs from that era don't support fancy things like long file names, and when they try to customize the dialog, they are expecting to customize a Windows 3.1-style dialog, so that's what we give them.

Here are the main differences between the old style and new style dialogs:

Feature Old-style New-style
Long file names No Yes
Resizability Not resizable Resizable
Multiselect Space-separated file names Null-separated file names
Template Replaces entire dialog Embedded into existing dialog
Default extension Maximum 3 characters Can exceed 3 characters
Hooks Windows 3.1-style Windows 95-style

The system decides whether you get an old-style or new-style dialog based on the following rules:

  • If you say OFN_EXPLORER, then you get a new-style dialog.
  • If you don't say OFN_EXPLORER, and you do say OFN_ENABLE­TEMPLATE, OFN_ENABLE­TEMPLATE­HANDLE, OFN_ENABLE­HOOK, or OFN_ALLOW­MULTI­SELECT, then you get an old-style dialog.
  • If you don't say anything on the above list, then you get a new-style dialog.

In words: You get an old-style dialog if you ask for any of OFN_ENABLE­TEMPLATE, OFN_ENABLE­TEMPLATE­HANDLE, OFN_ENABLE­HOOK, or OFN_ALLOW­MULTI­SELECT, since those are the things that affect the programmatic behavior of the dialog. However, you can override this by saying OFN_EXPLORER to say, "No really, I'm okay with the new hotness."

Comments (26)
  1. SimonRev says:

    I remember many years ago (early 2000’s) writing a program which allowed the users to select .ttf files. I discovered that when the user selected a .ttf file in the explorer style dialog, instead of selecting the file, it would always open the font preview window instead. (applied to either double clicking the file, or selecting and pressing [Open]).

    I ultimately worked around the problem by using the windows 3.1 style dialogs, which would properly return the name of the selected file(s). I hated doing that. I wonder if there was a better way.

  2. laonianren says:

    Something (WordPress?) has mangled your dialog by converting newlines into <p></p>.

    1. WordPress likes to mangle anything vaguely unusual. They even consider SVG and data URIs to be unusual. It’s a constant struggle.

      1. Linda Kaioh says:

        HTML graphics is good but actual screenshots are better ^^

  3. skSdnW says:

    And the Vista style dialog is the new-new-style which can be customized when you use the IFileSaveDialog interfaces instead.

    The old style only knows about DOS style file-systems of course.
    New-style knows about the shell namespace (can navigate it) but will return the result as a path.
    New-new-style knows about the shell namespace and can return shell items.

  4. Long file names, no?

    Well, then, please take a look at this:


    It is supposedly a screenshot of Windows Server 2008 in Server Core mode. It is featuring both Unicode support and long file names.

    1. Joshua says:

      It is. The old style knows about long file names now.

      I put the code in to switch to old style open dialog boxes on Windows Server Core after discovering that explorer style dialog boxes were bugged. I’ve had reports that this isn’t always the case anymore, but I left the code in because I have to deal with old Server Core versions.

      1. Yuhong Bao says:

        AFAIK the old-style dialogs supported LFNs from NT 3.1, since they were the only type available at the time. What would be interesting would be Win9x.

        1. Linda Kaioh says:

          Win9x support LFN in old style dialogs too.

          1. RP says:

            I don’t get it – if Win9x and NT 3.1 both supported LFNs, why did Joshua need to add them? Was the functionality dropped in later versions of NT?

      2. Antonio Rodríguez says:

        The old-style file dialogs did support LFN in Windows 3.11, even if it wasn’t oficially supported. 3.11 included a backport of Chicago’s VxD implementation of VFAT, and would show long filenames of files saved by other versions of Windows. You could even save over an existing file with a long filename, but IIRC you couldn’t create a new file with any other than an 8.3 filename (it couldn’t because it allways returned short filenames).

  5. Oh, great! This blog is once again rendering my whole comment without its paragraph marks; but, only as long as I am logged in. You guys are probably seeing my comment as I intended you to.

    1. Alex Cohn says:

      Yes, indeed.

      That’s sophisticated Web programming

      1. Alex Cohn says:

        What you see is not what they get.

        1. LOL. Indeed.

          Still, I’m kinda curious as to what causes it. I believe it is the script that adds the “Delete” widget.

  6. Wyatt says:

    Note, the dialog shown doesn’t really render correctly in IE 11. The scrollbars and drop down arrows render on the next line instead of the right side of the psuedo control like they should.

    1. Yeah, sorry. IE doesn’t support flex or grid layouts.

      1. SomeGuyOnTheInternet says:

        It doesn’t render correctly in Edge either. What browser is Raymond using? Hmm…

        1. Looks okay in Microsoft Edge 42.17134.1.0.

  7. AsmGuru62 says:

    New dialogs need CoInitialize/CoUninitialize to avoid exceptions on some systems.
    Other than that, a very cool dialog.

    1. Joshua says:

      Have fun if your thread is MultiThreadApartment.

  8. BZ says:

    I seem to recall after upgrading to Windows 95 that 16-bit programs would display LFNs, but would convert them to short filenames before passing them back to the program. In particular Visual Basic 3 definitely did this.

  9. Linda Kaioh says:

    Actually old style dialog do support long file names. Just tested it on my own app on Windows XP.

    1. skSdnW says:

      Several places in the base DLLs they check if the app is >= 4.0 (Some PE field, linker maybe), if not, it gets 3.x behavior.

  10. John Elliott says:

    IIRC, the old-style dialogs also support ‘/’ as a path separator (when the user keys a path), but the Win95-style ones don’t.

  11. Nico says:

    I wonder if Raymond has written a program yet to convert a DIALOG resource into HTML and CSS? :)

Comments are closed.

Skip to main content