What defines an old-style common dialog?

Raymond Chen

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:

Open
File name: Folders:

OK
 
Cancel
 
 
file.txt
  C:\WINDOWS  
 
CONFIG.TXT
DISPLAY.TXT
EXCHANGE.TXT
EXTRA.TXT
FAQ.TXT
GENERAL.TXT
 
 
 
📁 C:\
 📁 WINDOWS
  📁COMMAND
  📁CONFIG
  📁CURSORS
  📁Desktop
 
 
 
  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.”

0 comments

Discussion is closed.

Feedback usabilla icon