Why are dialog boxes initially created hidden?

You may not have noticed it until you looked closely, but dialog boxes are actually created hidden initially, even if you specify WS_VISIBLE in the template. The reason for this is historical.

Rewind back to the old days (we're talking Windows 1.0), graphics cards are slow and CPUs are slow and memory is slow. You can pick a menu option that displays a dialog and wait a second or two for the dialog to get loaded off the floppy disk. (Hard drives are for the rich kids.) And then you have to wait for the dialog box to paint.

To save valuable seconds, dialog boxes are created initially hidden and all typeahead is processed while the dialog stays hidden. Only after the typeahead is finished is the dialog box finally shown. And if you typed far ahead enough and hit Enter, you might even have been able to finish the entire dialog box without it ever being shown! Now that's efficiency.

Of course, nowadays, programs are stored on hard drives and you can't (normally) out-type a hard drive, so this optimization is largely wasted, but the behavior remains for compatibility reasons.

Actually this behavior still serves a useful purpose: If the dialog were initially created visible, then the user would be able to see all the controls being created into it, and watch as WM_INITDIALOG ran (changing default values, hiding and showing controls, moving controls around...) This is both ugly and distracting. ("How come the box comes up checked, then suddenly unchecks itself before I can click on it?")

Comments (17)
  1. Moi says:

    I must confess I had always thought the reason in the last paragraph was behind it all. History’s fascinating.

  2. Marty Fried says:

    Interesting, but the part about hard disks can’t be true. I don’t think anybody ran Windows from floppy disk; installed from floppy, yes, but run? I don’t think so. I know I had a hard disk then, and I wasn’t rich. I had a whopping 30 meg at that time.

  3. Jordan Russell says:

    "To save valuable seconds, dialog boxes are created initially hidden and all typeahead is processed while the dialog stays hidden."

    What happens if a second, nested dialog box is displayed as a result of a certain typed-ahead key? Does the first dialog box stay hidden while the second dialog box is displayed?

  4. Jordan Russell says:

    Answer to my own question: The first dialog stays hidden. Eek!

  5. Catatonic says:

    This article (http://www.joelonsoftware.com/printerFriendly/articles/Platforms.html) says that Windows used to have a runtime you could bundle with your app, so the user did not need to have Windows installed. I could easily see someone in 1986 running an app like that directly from a floppy.

  6. asdf says:

    What I want to know is how did dialog boxes work in a window manager that didn’t allow overlapping windows?

  7. Raymond Chen says:

    Windows 1.0 did support overlapping windows, as long as they were dialog boxes. You couldn’t overlap your frame window. (Not for any technical reason; was just the way they wanted to "look".)


  8. Matthew Lock says:

    Can anyone remember any applications that were created for Windows 1.0?

  9. Norman Diamond says:

    and you can’t (normally) out-type a hard

    > drive

    But you can frequently out-type the combination of a hard drive, Windows XP SP1, and Outlook Express SP1. Ctrl-Shift-E, type the name of the new subfolder, Enter, Ctrl-Shift-V, Enter, wait for the current message to disappear from the current folder, and you might never see the two dialog boxes.

    Crusoe 600 MHz with 304 MB of RAM (really 320 but the Crusoe grabs 16 for code morphing), and msimn.exe occupies around 90% of the CPU during this time.

    Meanwhile, ordinarily:

    > Actually this behavior still serves a useful

    > purpose

    I agree with you and moi.

  10. Raymond Chen says:

    The "killer app" for Windows 1.0 was Adobe PageMaker. Excel came shortly thereafter.

  11. Larry Osterman says:

    Actually Pagemaker and Excel were the killer app for the MacIntosh. They were later ported to Windows.

    IIRC, there really was no "killer app" for Windows. Windows 1.0 and 1.1 sold a modest couple of thousand units a month. Windows 386 (Windows 2.0) helped sales because they added the ability to run multiple DOS applications simultaneously (the functionality to run multiple old applications was there but it only worked well enough to run multiple GWBasic applications simultaneously), but it wasn’t enough to make a dent.

    But the world changed when Windows 3.0 shipped.

    Windows 3.0 added two major features:

    1) Support for 286 protected mode. This meant that applications suddenly were able to take advantage of more than 640K of memory (ok, with LIM Expanded memory they could limp using more but protected mode busted things wide open).

    2) Support for more than 16 color displays.

    I remember wandering over to ask Aaron Reynolds some questions about Windows 2.0 for some Lan Manager 2.0 stuff I was working on and he, David Weise and Ralph Lipe gave me a quick demo of the stuff they were working on for Windows 3.0. My only comment to them after seeing this was "Steve’s going to kill you guys, you know that, right?".

    Remember, at the time Microsoft and IBM were focused like laser’s on OS/2. ALL of our operating systems efforts were going into OS/2 (there was another side project called NT OS/2 in the works but it wasn’t significant at the time). Windows (and DOS) were complete and total afterthoughts.

    And here were these guys working on a version of Windows that was going to totally blow everyone away. Steve was going to have a total cow when he heard that they had an OS/2 killer in the works. And pretty much, that’s exactly what happened once they shipped (I don’t know about the Steve having a cow, but I do know about the OS/2 killer).

    All of a sudden, Windows stopped being a toy and became an honest-to-goodness viable system. Without any new applications for it, sales suddenly spiked into the millions of units per month (for some reason the number ten million units a month sticks in my mind).

    "And the rest was history"….

  12. J. Edward Sanchez says:

    PageMaker was actually called Aldus PageMaker in those days, because it was developed by a company named Aldus.

    When Adobe acquired Aldus in 1994 (near the end of the Windows 3.x era), they rebranded the current version (5.0) as Adobe PageMaker. The first version of PageMaker released exclusively under the Adobe name was 6.0.

  13. Peter Torr says:

    I used to run Word 1.x which came bundled with a runtime version of Windows. Windows 3.1 rocked because it had TrueType support and you could run DOS boxes in a window!

  14. Will says:

    Yeah, I can remember Pagemaker seemingly including a runtime of Windows/286. IIRC it took up 1-2 floppy disks, and was required for Pagemaker to run.

  15. Walk the template items and do what they say.

  16. Posting a message isn’t good enough.

Comments are closed.