October 21st, 2024

Why does adding WS_MINIMIZE­BOX change how my window behaves when the user presses Win+D?

A customer noticed that if they add the WS_MINIMIZE­BOX style to their window, then the IsIconic function returns a nonzero value after the user presses Win+D. But if they remove the WS_MINIMIZE­BOX style, then then the IsIconic function always returns FALSE. What’s going on?

We learned some time ago that the Show Desktop command Win+D first minimizes all windows that can be minimized, and then moves the desktop window to the top of the z-order.

Therefore, the described behavior is expected: If the window has the WS_MINIMIZE­BOX style, then it can be minimized, so the Show Desktop command minimizes it, and the IsIconic function reports that the window is indeed minimized. On the other hand, if the the style is missing, then the window cannot be minimized, so the IsIconic function reports that the window is not minimized.

Bonus chatter: But why is the function called IsIconic when it really reports on whether the window is minimized? Shouldn’t it be called IsMinimized? What is an “iconic” window anyway? Is it a window that is widely recognized as representative for its era?

No. The reason is simple: Before the taskbar was invented, minimized windows were represented by an icon. So the name “is iconic” was correct at the time.

Topics
Code

Author

Raymond has been involved in the evolution of Windows for more than 30 years. In 2003, he began a Web site known as The Old New Thing which has grown in popularity far beyond his wildest imagination, a development which still gives him the heebie-jeebies. The Web site spawned a book, coincidentally also titled The Old New Thing (Addison Wesley 2007). He occasionally appears on the Windows Dev Docs Twitter account to tell stories which convey no useful information.

10 comments

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

  • Jeff Stoner

    windowsx.h to the rescue. It defines IsMinimized for IsIconic (and IsMaximized for IsZoomed).

  • alan robinson

    I will grudgingly admit that not every win32 developer lived thru the 3.1 era, but surely they are aware of it, at least?

    I always thought the “iconic” representation in w95+ versions looks really weird. I suppose the expectation is that nobody would ever see it, but in truth explorer.exe does crash now and then (mostly then, not so much now).

    • DCH3416

      They're also visible when child windows are minimized. As you can see in program manager as well. https://github.com/bhuebschen/Program-Manager

      It's basically the default way the window manager in windows handles iconification. Except explorer intercepts that request, shoves them off screen and hides them.

      Personally, I prefer the Win3.x method because I can see exactly what's running on screen. But there's challenges to running windows without explorer, namely shell integration. Metro programs depend on explorer for whatever reason....

      Read more
    • Boris Zakharin

      And don’t forget that Program Manager was still available in Windows 95 as an alternative to Explorer. Those icons looked very weird indeed.

  • DCH3416

    Kill explorer.exe for the legacy iconic minimize to the bottom left corner. You can even double click on the program icon to restore.

    • 許恩嘉

      I discovered that setting the WS_EX_NOACTIVATE extended window style via SetWindowLongPtr can achieve a similar effect.
      When WS_EX_NOACTIVATE is set, the window cannot be activated by clicking with the mouse, and the window won’t show up in Alt+Tab or the taskbar by default, but it can still receive mouse messages.
      If you click the minimize button, the window will minimize to an icon in the lower-left corner, and you can activate the window from the...

      Read more
    • Boris Zakharin

      You get something similar to the old behavior, but they minimize to a bar with an icon and restore, maximize, and close buttons. That’s how it’s been since Windows 95. The pre-Windows 95 behavior had just icons on the desktop when minimized.

      • DCH3416 · Edited

        Yeah. If you iterate through the chicago builds you can see how that evolved. They took the original full size icons, added a window frame around it, and shifted the text to the right. Then eventually scaling the icon down, adding the caption buttons, and making it match the look of the regular windows. The original functionality is still there, even with the extra stuff that was added over time.

  • Boris Zakharin

    Way to make me feel old for actually remembering what the desktop was like before the taskbar. However, I don’t remember minimized windows being called “iconic”, so IsMinimized seems to be a better name for it than IsIconic even at the time.