What does it mean when a display change is temporary?

When you call the ChangeDisplaySettings function, you can pass the CDS_FULLSCREEN flag to indicate that the change is temporary. But if you don't also save the changes in the registry, how can they be permanent? What does temporary mean?

A temporary display change is one that your program has entered because it has gone into a fullscreen mode, a change which it will undo when it releases control of the screen to another program. For example, a fullscreen video may use a temporary display change to display a 320 × 200 video. The change isn't permanent, since the video player will certainly return the video resolution to its previous setting when the video ends or when the user switches to another program.

The window manager and Explorer behave differently in response to temporary as opposed to permanent display changes. If a display change is permanent, the window manager will reposition windows and Explorer will reposition desktop icons so that they all fit on the (new) screen. If they didn't do this, then windows and icons near the right edge or bottom edge would become inaccessible. Conversely, if you say that the change is temporary, then the window manager and Explorer won't reposition anything because you said that you'll set things back when you're done.

If you set the CDS_FULLSCREEN flag incorrectly, you typically see one of two results.

If you set the temporary flag when you shouldn't, then you'll find that icons have disappeared off-screen and have become inaccessible. That's because you said, "Oh, don't worry about this screen resolution change. I'll set it back before you even realize it."

If you fail to set the temporary flag when you should have, then you'll find that all your open windows and your desktop icons have been squished into the corner of the screen. And that's because you said, "The user is going to be working in screen resolution to 320 × 200, so you'd better make sure everything is ready for it!"

Moral of the story: If you're going to change the display settings, make sure you correctly indicate whether you're doing this temporarily or permanently. The name for the flag CDS_FULLSCREEN acts as a strong hint for telling you when you need to pass it.

Pre-emptive snarky comment: "This blog entry is proof that Microsoft documentation sucks. If the documentation were any good, this article would not have been necessary." Well, I'm sorry for trying to help. If you prefer, I'll only write about things that are already well-documented.

Comments (24)
  1. Thom says:

    It’s easy enough to find the flag in the documentation for ChangeDisplaySettings and, though it’s lacking in details, I think it wouldn’t take much testing to figure out what it meant.  

    I am curious how this flag got its name though.  I get the impression that it started out for something else and that something was pared down until all that remained was this behavior – else a wise developer would have named it CDS_TEMPORARY_CHANGE (or some such).

    [As I suggested in the article itself, I suspect it was somebody’s attempt at making a self-documenting flag, giving the flag a name that describes how it should be used instead of describing what it does. The sort of thing some people claim they want more of. -Raymond]
  2. Tim Smith says:

    Being in the game industry, I knew exactly what the flag did just from the name.  "Hey, I need to go into full screen mode so don’t goof up the user’s desktop layout when the desktop gets resized."

  3. Niels says:

    And I have seen way too many games failing at this, meaning I get a broken desktop and window layout after running them… :(

    At least now I know what they’re doing wrong.

  4. Andrew Cook says:

    The Application Compatibility Toolkit shim for this is ForceTemporaryModeChange, right?

  5. Kip says:

    I remember in Windows 95 days this would happen with nearly every game I played.  Nowadays game developers seem to have figured this out though.

  6. Sven Groot says:

    Kip, more likely game developers nowadays don’t use this API to go fullscreen anymore. The more common way for games to do this is to use Direct3D (or previously, DirectDraw) exclusive mode, which will switch modes for you, and it will always behave correctly as it has no "permament" mode.

  7. Chris says:

    Yes, but DirectX exclusive mode only works in the single-monitor case. If you actually need to reset two or more video modes simultaneously, like our applications do, CDS_FULLSCREEN is the only reliable way to go.

  8. Sven Groot says:

    Chris, I wasn’t suggesting that CDS_FULLSCREEN is obsolete, I was simply replying to Kip’s observation that most games get it right today; I believe most of them get it right because they use DirectX not because they correctly use CDS_FULLSCREEN. That’s not to say there aren’t any applications that correctly use CDS_FULLSCREEN.

    Sorry for the confusion.

  9. Marc K says:

    CDS_FULLSCREEN was really only intended for full-screen apps.  I’ve seen on older versions of Windows where the task bar is not repositioned when CDS_FULLSCREEN is used.

  10. Marc K says:

    Is the “hint” that indicates the display change is only temporary available to other programs?

    AFAIK, the main notice of a display change is WM_DISPLAYCHANGE and that message doesn’t contain any information about the permanence of the change.

    [I went back and did the research and I was wrong. Explorer doesn’t use this flag to decide whether to reposition icons – for the reason you give. -Raymond]
  11. Hugo says:

    "Yes, but DirectX exclusive mode only works in the single-monitor case. If you actually need to reset two or more video modes simultaneously, like our applications do, CDS_FULLSCREEN is the only reliable way to go."

    Ever since I startet using a second monitor I had problems with windows rearanging themselves, switching screens, or going  entirely offscreen after using fullscreen apps. Is that the reason?

  12. Chris says:

    Nah, it’s probably because Windows doesn’t really handle a sparse virtual desktop. If your second monitor is to the "right" of the primary, then it suddenly starts displaying windows starting at (800,0) rather than (1280,0) rather than have a no-man’s land. Screen coordinates subject to change, obviously.

    The only practical remedy at the moment is to put your secondary (non-gaming) monitor into "negative space" (e.g., (-1280,0) origin). That hides most of the problems, but some apps don’t handle negative coordinates well.

  13. Gabe says:

    I’m surprised nobody complained about icons rearranging themselves yet. The problem being that when the desktop shrinks the icons are relocated, but when the desktop goes back to its original size the icons don’t move back to their original positions.

    I think this is particularly common now that people use remote desktop, connect to projectors, and such.

    Does anybody know why Explorer doesn’t remember the last position the user set the icon to, and then just always try that position first when drawing an icon? It seems like remembering the last size and position a user set a window to even if it was last maximized.

  14. Leo Davidson says:

    Presumably CDS_FULLSCREEN is more about undoing the change when the program exits (or loses focus or, most importantly, crashes) rather than making the change have no effect on other apps while the program has focus.

    What Hugo and Chris mention, with full-screen games (not running at the desktop resolution) causing windows on secondary monitors with positive coordinates to shift around is annoying. Very few games use more than one monitor so it’s nice to be able to keep an eye on IRC and other things (including CPU/memory monitors) while playing games, but having everything move around and sometimes go offscreen completely isn’t ideal.

    Rather than a sparse virtual desktop, I wonder if the problem could be solved by pretending that the usual desktop resolution was still in use, but giving the full-screen app (the game) a "virtual screen", which is effectively just its window sent to the primary monitor. The app just has to render to its window as if it were running in a windowed mode, no program has to know anything strange is going on and it’s just a trick of the video hardware/drivers that you see that one window as if it was full-screen. Perhaps there are performance issues with that, like the framebuffer may have to have lots of dead space between each scan line or something.

    Amiga OS didn’t have multi-monitor support (at least back when I used it) but it always had the ability to have different "screens" with independent resolutions and bit-depths which you could flick between (and even display at once stacked down the screen, due to the way the Amiga’s hardware worked). It’s a shame Windows has never had anything similar, but perhaps adding it now would be too difficult.

    On the plus side, graphics cards are so powerful these days that only the very cutting edge games require you to switch to a lower resolution than your desktop (at least on my 1920×1200 monitor; perhaps people with higher res 30" monitors feel differently).

  15. Worf says:

    Ah… now it makes sense.

    I am always annoyed at programs that do fullscreen because there was a random chance that they would screw up the window size and positioning, as well as reposition all the icons on the screen. I did notice that if an app did it, it did so consistently, but determining if an app would do it wasn’t possible (other than trying).

    Especially if the default for said app was "full screen low res". Ugh, what a nice first impression to make – having all your windows suddenly resized and all the icon positioning lost.

    Too bad there isn’t a way to force this flag on anything other than the Display Control Panel and certain user-selectable apps. Not a security issue, but more of an annoyance to keep having to redo the icon positions and resize the numerous windows one has open.

    Of course, QA never notices because a clean machine only has a few icons by default, and rarely are useful windows kept open (browser, help), or if they are, they’re nominally maximized.

    *Sigh*. Raymond, it looks like you’ll probably end up coding around this by having to store and restore the window positions and icon positions should an app misbehave. Even worse when they crash and they leave your desktop at 640×480, which one promptly resets back to the old settings.  Probably end up with a nice dialog asking "Why is my desktop strange" (and the option "restore desktop" back the way it was), and get blamed for adding this feature in.

    It’s usually games (that don’t use DirectX), media players, or other multimedia thing that does this…

    Won’t blame Microsoft for this one – the API is necessary (Though, I suppose someone could put in the SDK CDS_TEMPORARY equal to CDS_FULLSCREEN), but the developers, since obviously many now get it right!

  16. Neil says:

    Leo, are you describing a feature similar to the virtual desktop available with some video card Windows 95 drivers, whereby your workspace area can be larger than the monitor and the driver will automatically pan to follow the mouse?

    (I tried the Windows 98 drivers in an attempt to resolve an unrelated problem and noticed that they no longer supported panning, possibly because of the multiple desktop architecture. I actually switched back but for other reasons.)

  17. stosb says:

    The squish effect is kinda funny if the taskbar is set to auto hide… You can see it move up and down thinking it’s hiding for you :)

  18. Igor Levicki says:

    It would be nice if change to VGA mode (ie the one when you uninstall the old drivers in preparation for installing the updated ones) was also “temporary” so that you don’t have to rearrange icons afterwards.

    {Imagine what the world would be like if that were true. -Raymond]

    Speaking of this, I do not understand why users have to manually restore all display settings, why there is no export/import functionality for display drivers?

  19. Drak says:

    Well Igor, I guess that’s because the video driver programmers would have to make that, because Windows probably doesn’t have any idea what export/import.

  20. Igor Levicki says:

    >Well Igor, I guess that’s because the video driver programmers would have to make that, because Windows probably doesn’t have any idea what export/import.<<

    Sooo… Windows doesn’t know about resolution, bit-depth and refresh rate? That’s a new one for me.

    Actually Windows could offer the export/import functionality without even knowing what the drivers are exporting/importing.

    Don’t tell me that the Microsoft couldn’t have made it mandatory for drivers to support save/restore settings IOCTL?

    That goes for any device which needs reconfiguring from scratch (video card, sound card, printer) once you update the drivers for it.

    It is as if they want users to suffer by having to perform boring repetitive tasks instead of letting computer handle them, which by the way was the sole reason computers were invented in the first place if I remember correctly.

  21. Dean Harding says:

    "Windows doesn’t know about resolution, bit-depth and refresh rate?"

    Of course it does, but what about all the other settings that are driver-specific. Most newish drivers allow you to specify colour spaces and anti-aliasing levels and so on. So either Windows exports only a subset of the settings (which is pretty useless) or the driver has to support all (in which case, it’s pointless for Windows to do anything).

    "Don’t tell me that the Microsoft couldn’t have made it mandatory for drivers to support save/restore settings IOCTL?"

    How can they possibly making it mandatory in retrospect? Either it is mandatory, or it’s optional. If it’s going to be mandatory, then it has to be mandatory for all time.

  22. Marc K says:

    "I’m surprised nobody complained about icons rearranging themselves yet."

    I’ve been using a program called UIFriend that makes backups of the icon layout.  It handles when programs change the display settings, but if it misses something, the worst case scenario is having to go into the menu to manually restore things.

  23. Igor Levicki says:

    >Of course it does, but what about all the other settings that are driver-specific.<<

    As I said that could have been handled in two ways.

    1. Let each driver implement their own save/restore settings — kX drivers for Creative sound cards offer that. In my opinion that is suboptimal as it still requires significant interaction from the user.
    2. Let Windows issue Save/Restore settings IOCTL to the driver. On save driver would send data and Windows would dump it into a file associated with current date, device and vendor ID. On driver reinstall, Windows would ask the user if he wants to restore previous settings and if user says "yes" it would attempt to send the file contents to the driver. Driver could do version checking and accept all the settings it knows about. In case that driver writers have added new settings, driver could return special error code upon which Windows would suggest user to manually check settings because new settings are available.

    >How can they possibly making it mandatory in retrospect?<<

    Who said in retrospect?!?

    There have been two changes in driver model so far. First missed oportunity for what I am suggesting was change to WDM. Second was Vista driver model. How much more we will have to wait?

  24. Igor Levicki says:

    Oh yes, and after having File Manager in Windows 3.x, Explorer in Windows 95, Windows 95 OSR2, Windows 98 Gold, Windows 98 SE, Windows ME, and Windows NT 3.x-6.0 one would think that so far shell team would implement such a simple option as "Save Icon Positions" and "Restore Icon Positions".

Comments are closed.

Skip to main content