How do I make a window remain visible even when the user selects Show Desktop?

A customer had this question:

I'd like to know how to get a window to remain visible, even when the user has selected Show Desktop. Right now, when the user picks Show Desktop, the desktop appears and covers my window.

Um, yeah, because that's the whole point of Show Desktop: To show the desktop and get rid of all those windows that are in the way. Windows like yours.

We're sorry that Windows was unprepared for a program as awesome as yours, because there's no way to mark your window as even if the user says to show the desktop instead of this window, override the user's command and show the window anyway. (They're probably angling for a nice bonus.)

As a consolation prize, you can create a desktop gadget. Desktop gadgets are part of the desktop and raise with it. It so happens that upon further discussion, the customer was trying to write a clock-type program—this is something very well-suited to gadgetification.

A different customer had a related question, but disguised it behind another question:

I noticed that desktop gadgets remain on the desktop even if the user clicks Show Desktop. How does that work? How do gadget stay in front of the desktop when it is shown? What is the trick?

This was a rather odd question to come through the customer channel. And it probably wasn't just idle curiosity. You don't burn a support request for idle curiosity.

(While it's probably true that you don't burn a support request just for idle curiosity, I've seen support requests turn into idle curiosity. Once the customers got the answer to their question, they realized that since they had already burned a support request, they may as well pile on with follow-up questions that are just idle curiosity. That was not the case here, because the customer led with the question.)

The "trick" is that gadgets and the desktop know about each other, so when the user clicks Show Desktop, the desktop covers up all the windows on the screen and then takes the gadgets and places them on the desktop.

The customer's question is rather odd, because they ask "The system works like X. Are there any tricks for X?" The answer is the rather tautological "The trick for how the system works like X is that the system was designed to do X."

I suspect that the customer has a secret agenda they are unwilling to share. My guess is that their secret agenda is that they want to write a program that is exempt from being covered by the desktop when the user clicks Show Desktop, and they think they can do it by emulating whatever it is that gadgets do.

The customer liaison confirmed that that's what the customer is actually trying to do, but that the customer was being coy with the liaison as well and did not explain what the problem scenario was that made them think that they needed a program that is exempt from being covered by the desktop when the user clicks Show Desktop. The customer liaison went back to the customer with the explanation that the way to get the special gadget behavior is to be a gadget, and if they want to pursue it, then writing a gadget is what they need to do.

Comments (32)
  1. Fidel says:

    So the trick is to look and act in all important respects like the sidebar application? (Warning: This trick might not survive the next service pack and/or release).

  2. Mike Caron says:

    Fidel, unless I'm mistaken, the trick is to /be/ the sidebar application.

  3. Fidel says:

    But the sidebar application is but a mere big blob of data. Unless its signature is checked, it should possible to create a program which successfully pretends to be the sidebar app while doing something else.

  4. Kemp says:

    Fidel: Yes, if you want to do bad things to the system then you can. Of course there's always going to be a way. The point here is that the customers didn't want to do bad things, they just didn't understand how to do the thing they wanted.

  5. Sunil Joshi says:


    You would need to overwrite sidebar.exe which is no doubt protected by windows file protection.

  6. Tom says:

    Now WHY oh WHY would they not want to just write a gadget?

    I'm sure it has nothing to do with being forced to write it in HTML and JavaScript…

    Oh wait!  …YEAH, I went there. :)

  7. Mordachai says:

    Wow.  Just… wow.  How can there be so many stupid software engineers out there?  Maybe not stupid, per se, but with zero respect for conventions of Windows, and more importantly, no respect for the end-user's ability to control his/her own PC?

    There ought to be a hall of shame for such individuals (and organizations).

  8. Kemp says:

    Steve Wolf: gives quite a few results, but I'm not sure how directed they are. Maybe there's enough to make us angry anyway ;-)

  9. Malapine says:

    Hire an attendant who knuckle-slaps the user with a ruler if they try to minimize the window.

    Thwack!! "No! Bad User! Put our window back up!"

  10. Well.. to be true.. says:

    Well, to be true the app writer could for example just be a writer of some other widget engine (like Konfabulator for example) which unfortunately has no way to emulate the sidebar behaviour. Or could be a developer for internal corporate software who just need that functionality – on some corporate PCs dedicated to some purposes, internal application are THAT awesome.

  11. Mordachai says:

    Why is the user pressing "show desktop" on a corporate PC dedicated to a single app?    How does that not fall under "training issue" rather than "rewrite Windows" issue?  Seems to me that many (all?) of these schemes that try to do back flips to circumvent the user from having control have at their heart the idea that the user cannot be trusted to do the right thing.  If you cannot trust your users, then why give them access?  Or why not train them so that you can trust them?  Seems like going around 3 sides of a block to navigate 1 (at the very least).

  12. Fidel says:

    Oh, there seems to be some confusion. By "sidebar application" I do not mean an application for the sidebar, but that one that hosts them (I think it was called sidebar.exe).

  13. Voo says:

    Maybe I'm missing something, but wouldn't setting HWND_TOPMOST be the solution if they really, really want their program to remain visible independent of circumstances?

    Just tried with a small app I've written for myself and it remains visible just fine when clicking Show Desktop as expected. Now if they didn't want their Window to stay visible at all times, then why would they even be worried about the show desktop command hiding it?

  14. Kemp says:

    Fidel: I got that, but nowhere did anyone mention replacing the existing sidebar. The customer wanted something that would always be visible on the desktop, and the solution was to write a gadget that integrates into the sidebar. Replacing the sidebar is rather a jump into the land of malware or system abuse – if you find yourself doing that, then you have the wrong solution or you don't correctly understand your problem.

  15. a random passerby says:

    @Zan Lynx: Great minds think alike.

  16. Joshua says:

    Well there's the way I did it as a prank years ago: The program set it's window TOPMOST and ran in a loop clearing TOPMOST on all other windows.

    And then there's the way I did as a prank decades ago: The program scribbled on the desktop window.

    Please note that neither solution is viable for production.

  17. Fidel says:

    @Zan Lynx: I must admit that your solution is much more awesomer than mine. But I still see room for improvement. Why not just replace lsmm.exe?

  18. Mordachai says:

    @Mason – that's a whole 'nuther can of worms.  I certainly agree that the DMCA is a whorish piece of legislation, and I'm no fan of DRM.  Even so, one can see the difference between having control over reproduction of software, and control over it's installations and usages as separate from a given piece of software being a good citizen of the Windows desktop.  I don't really think the one is connected to the other, excepting the general lack of respect for end-users that is shown / inherent to DMCA/DRM.

  19. ErikF says:

    @Mason: DRM is also one of those "do not touch" issues that often gets entire classes of topics scrubbed by our illustrious host!

    I can't think of many classes of applications that must not under any circumstances become hidden.  If you need to alert the user, that's the job of the notification area.  Statuses?  That's maybe a gadget.  Anything else?  It can probably wait, but you can FlashWindow() yourself to get noticed if necessary.

  20. Dileepa Prabhakar says:

    I am not sure, but I've seen Google Talk (the Windows version) stay on after Win+D.

  21. Rob says:

    @Fidel, "So the trick is to look and act in all important respects like the sidebar application?"

    No, the "trick", so much as there is one, is to *be* a sidebar/gadget application.

  22. Zan Lynx says:

    If their program is *that* awesome, they should just name it "explorer.exe" or otherwise make it the user's default shell. Then there is only one window. Theirs!

  23. I-hate-punctuation says:

    but that the customer was being coy with the liaison as well and did not explain what the problem scenario was that made them think that they needed a program that is exempt from being covered by the desktop when the user clicks Show Desktop.

    Wow, just wow.

  24. Mason Wheeler says:

    @Steve Wolf:

    >How can there be so many stupid software engineers out there?  Maybe not stupid, per se, but with zero respect for conventions of Windows, and more importantly, no respect for the end-user's ability to control his/her own PC?

    I thought not respecting the end-user's ability to control his/her own PC *is* the standard convention of Windows. Why else would Microsoft support the DMCA and the crimeware that it explicitly makes legal to use and illegal to circumvent, and participate in the Trusted Computing initiative?  The message is very clear: As long as DRM is not only not regarded as the act of hacking that it is, but actually *protected* by law, you do not have the legal right to control your own computer, and Microsoft feels no obligation to protect that right.

  25. InControl says:

    Why not override Ctrl+D with a global hotkey which hides all windows except your own?

  26. Sidebar says:

    Well, I can think of several situations where someone might want to keep the window visible. If you have a toolbar on the side (like the taskbar), there is nothing important to see on the desktop below it, so most people actually want that behaviour.

    I actually did write a gadget which creates a another window (in c) to simulate the vista-sidebar for win7 and many users complained that it gets hidden on Win+D. So I looked how sidebar.exe does it and copied the behaviour, and everyone was happy…

    PS: Please stop talking about DRM

  27. Joseph Koss says:


    The thing is that you *GET* to have that protected media path. Your argument pretends to be just about your machine but neglects the fact that its not your content and to enjoy that content you are subject to the terms defined by those selling that content. You don't have to buy that content, but if you do you have a machine with a commercial software stack that is capable of playing it precisely and only because it conforms. You *GET* to play it at full resolution, which is otherwise not something that you would get to do without breaking the contents license terms.

    If you dont like it, then dont buy the content. The protected media path doesnt make windows worse.. on the contrary it allows you to make the choice for yourself, which is better. Without the protected path, you would have no choice.

  28. Joshua says:

    @Joseph: The laws of physics are what they are. The protected media path doesn't work. TPM doesn't work either if enough money is behind bypassing it.

  29. Troll says:

    The gadget thingy is true only for Windows 7. Win+D/Show Desktop hides gadgets as well on Windows Vista.

  30. CJ says:

    @Tom: I bet it's not that. I think writing a gadget might require to think about UI design and stuff. and they newer do that!

    @Troll: Don't you remember vista road is a dead end?

  31. SimonRev says:

    @Sidebar:  Keep in mind that if you need an app bar, you can always write one.  ShowDesktop won't hide those, any more than it hides explorer's app bar.

  32. Sidebar says:


    Yes it hides app bars. Except the taskbar.

Comments are closed.

Skip to main content