What’s with those blank taskbar buttons that go away when I click on them?

Date:December 29, 2003 / year-entry #183
Tags:tipssupport
Orig Link:https://blogs.msdn.microsoft.com/oldnewthing/20031229-00/?p=41283
Comments:    41
Summary:Sometimes you'll find a blank taskbar button that goes away when you click on it. What's the deal with that? There are some basic rules on which windows go into the taskbar. In short: If the WS_EX_APPWINDOW extended style is set, then it will show (when visible). If the window is a top-level unowned window,...

Sometimes you'll find a blank taskbar button that goes away when you click on it. What's the deal with that?

There are some basic rules on which windows go into the taskbar. In short:

  • If the WS_EX_APPWINDOW extended style is set, then it will show (when visible).
  • If the window is a top-level unowned window, then it will show (when visible).
  • Otherwise it doesn't show.

(Though the ITaskbarList interface muddies this up a bit.)

When a taskbar-eligible window becomes visible, the taskbar creates a button for it. When a taskbar-eligible window becomes hidden, the taskbar removes the button.

The blank buttons appear when a window changes between taskbar-eligible and taskbar-ineligible while it is visible. Follow:

  • Window is taskbar-eligible.
  • Window becomes visible ? taskbar button created.
  • Window goes taskbar-ineligible.
  • Window becomes hidden ? since the window is not taskbar-eligible at this point, the taskbar ignores it.

Result: A taskbar button that hangs around with no window attached to it.

This is why the documentation also advises, "If you want to dynamically change a window's style to one that doesn't support visible taskbar buttons, you must hide the window first (by calling ShowWindow with SW_HIDE), change the window style, and then show the window."

Bonus question: Why doesn't the taskbar pay attention to all windows as they come and go?

Answer: Because that would be expensive. The filtering out of windows that aren't taskbar-eligible happens inside USER32 and it then notifies the taskbar (or anybody else who has installed a WH_SHELL hook) via one of the HSHELL_* notifications only if a taskbar-eligibie window has changed state. That way, the taskbar code doesn't get paged in when there's nothing for it to to.


Comments (41)
  1. Alex Feinman says:

    The link to WH_SHELL hook seems to be broken

  2. Kevin Dente says:

    Here’s a related question – why is it that there are sometimes (in fact, often) windows that show up in the taskbar but don’t show up in the ALT-TAB rotation? That one drives a heavy keyboarder like me nuts.

  3. Mark Hurd says:

    Kevin: Anyone can look up the documentation for the exact details, but simply the criteria is different.

    You can use Win-Tab to cycle through the TaskBar buttons in the same way.

    (Note also for keyboarders: Win-Tab (or otherwise give the TaskBar focus) followed by Tab (or Shift-Tab) will move the focus to toolbars and the notification area. Further Tabs and Ctrl-Tabs will move to docked toolbars and to the desktop.)

    Raymond: What’s the easiest way to give a minimized application the focus (and hence the priority boost) without restoring it? (In Win3.1 just clicking on the task icon would do it IIRC.) Alt-Esc gets it done, but is there a TaskBar way?

  4. Raymond Chen says:

    Alt+Esc is the way to do this. It turns out that very few people ever say, "Y’know, what I really want to do is switch to a minimized program without restoring it, so it can get its priority boost." The taskbar is all about switching to running windows so you can use them, not fiddling with priority boosts.

  5. Raymond, why WH_SHELL doesn’t send anything when console window become active? How to handle this situation?

  6. Raymond Chen says:

    It doesn’t? I didn’t know that. It should – you see the taskbar buttons pushing and unpushing when you move focus to/from a console window, after all.

  7. Heh. I thought so too, but it doesn’t — I made WH_SHELL hook several days ago. :-)

    I also searched google groups — people have met this problem too. :-(

  8. James Curran says:

    While we’re on taskbar quirks…. What’s up with this?

    I’ve noticed frequently, if you has several windows open, and click on a taskbar item to to bring that window to the top of the z-order, a complete different window will also rise. (I’ve noticed this the most when I’ve tried to do a drag’n’drop between two Explorer windows. I’d get the source window pointed to the right directory, click the taskbar icon for the destination window to bring it into view — and at the same time, an IE window (for example) will also come to the top, blocking the source Explorer window).

    Another time I see it a lot, is when a spammer pops-up an off-the-screen IE window. I’ll see an unidentified IE icon on the taskbar, and click on it to see what it is. While the popup restores out of view, a legitimate IE window also restores, looking as if it’s the one I clicked on.

  9. Raymond Chen says:

    I can’t explain the behavior you’re seeing.

  10. Scott says:

    How about this one: if a program in the "tray" crashes, the icon isn’t removed until you mouse over it. Did they fix that in XP?

  11. Tom says:

    I’ve never seen empty taskbar items in the new-style XP taskbar, has it changed or am I just lucky?

    Also, why was the decision that Control Panel dialogs should never have a taskbar button taken? *So* many times I’ve seen someone accidentally click away from one, and then go all through Start -> Settings, etc just to get it back!

  12. Raymond Chen says:

    The taskbar doesn’t continuously check if each program backing a notification icon is still alive. That would be very wasteful of memory and CPU (checking the window every few seconds to see if it is still responding). When you mouse over the icon, the taskbar finally has a reason to talk to the window backing the icon, and that’s when it notices that the window is no longer valid.

    As for why control panel programs do not show up in the taskbar: This was in my mind a controversial decision from the beginning. The theory was that they aren’t applications or documents; they’re properties (like file properties), and the taskbar is for showing tasks and documents.

    I think the original taskbar designers were trying to keep "clutter" out of the taskbar.

  13. Tom says:

    Hehe, so why in XP do connection properties dialogs get taskbar buttons? Slight lack of consistency methinks :)

  14. Raymond Chen says:

    Simple: The RAS team is not part of the shell team.

  15. Mark Hurd says:

    I’ve noticed File Properties *sometimes* get icons. I’m not sure when — perhaps when the Explorer window that initiated them has been closed.

    James: The other windows that come foreward can be windows of the same process. If you’ve got Explorer doing web browsing and Internet Explorer browsing disks, you can get some un expected window changes…

  16. Roy Osherove says:

    Here’s a good question:

    Why in the world when I copy large amounts of data between machines, does the copy dialog show the most inexact time, and sometimes even counts upwards?

  17. Raymond Chen says:

    Good question. I’ll answer it in a future blog entry.

  18. "If the window is a top-level unowned window, then it will show (when visible)."

    In XP the above is true about 97% of the time. There are only a few ways in which XP is more unreliable than 95, but this is one of them. After you minimize an application which doesn’t have a button showing in the taskbar, you have to open the task manager and do a "switch to" in order to get back to the application. And to decide to do that, you have to have the presence of mind to remember that you actually have that application running and only the Windows XP taskbar forgot about it.

  19. James Curran said:

    "Another time I see it a lot, is when a spammer pops-up an off-the-screen IE window."

    Actually IE can do that all by itself. This happens even when each IE window resulted from a separate invocation (separate push of the icon in the Quick Launch bar or Start menu or whatever, anyway not from popups and not from a right clicking a link and open in new window). For a few months last year I had to use Windows 98 and IE was doing that several times per day, suddenly deciding that each window had negative size and was located beyond the lower right corner of the display. In Windows XP it has only happened a few times, deciding that a single IE window had negative size and was located beyond the upper left corner of the display.

    Such a broken window can be brought back by a sequence of three steps. In the taskbar, do a right click on the button for the window, and select Move. Use an arrow key to move the window a bit, but it will actually move onto the visible screen, at an edge or corner of the screen, and you can use the mouse to move it further. It will hardly be visible because it has negative size and only a corrupted portion of its title is showing, but if you know what to look for you’ll find it. Second, click on an edge of the window and try to resize it. This effort will fail but the size will change from negative to zero and you’ll be able to read the first few characters in its title. Third, click on an edge of the window and try to resize it again. This will succeed.

    In this situation, Windows XP is more reliable than Windows 98, as it should be. But it’s just luck that the few times it happened to me, it didn’t coincide with Windows XP forgetting to display a button in the taskbar.

  20. Raymond Chen says:

    If you can repro this I’d like to debug it.

  21. Danit says:

    The area in my win-xp taskbar that shows the tasks disappeared and I can’t get it back.

    I guess there’s some registry key responsible for that, but I don’t know which.

    Can you help?

  22. I think Raymond Chen was replying to me:

    "If you can repro this I’d like to debug it."

    1. Taskbar not getting button for application.

    In my experience it happens about 3% of the time. The victim application can be anything. I can only guess what might or might not be a way to make it happen more than 3% of the time. Here is a first guess. Let’s try something that is slow to start up, and open a bunch of them, and let’s hope this will maximize the probability of Windows forgetting to put the victim’s button in the taskbar.

    Try something like my Crusoe at a slow 600MHz and measly 320MB of RAM. To simulate that, maybe try a Celeron 300MHz and measly 256MB of RAM.

    In Internet Explorer, uncheck the option to reuse existing IE windows when clicking on shortcuts. (By the way, another bug is that IE doesn’t entirely respect this option either. Sometimes it still reuse a window. Then the user has to scramble to find the window that had some other page that they wanted to keep open, do a "back" operation there, open a new IE application and copy the new desired shortcut into its address bar.)

    Anyway, in that environment, click about 20 times on the IE button in the Quick Launch bar. This might put about 19 IE buttons in the taskbar, if we’re lucky enough to get the problem reproduced this time. Minimize each IE window as it gets opened. When none of them are open on the desktop, go through each one in turn, click on the button in the taskbar to restore it, then click on the upper-right closer to close it. At the end of this there should be no IE buttons in the taskbar. Then open up the Task Manager to the Applications tab and see if it knows about a still-existing IE window. If it does, you can do a "switch to", the IE window will be restored, and Windows will belatedly enter a button into the taskbar.

    2. IE displaying itself with negative size, off screen.

    In Windows 98 it’s pretty easy. If I’m on a machine connected (indirectly) to the internet, I usually keep three IE windows open but minimized, displaying financial information, and glance at them occasionally. Two of them automatically get refreshed every few minutes. The three I do are:

    http://quote.yahoo.co.jp/

    http://www.cme.com/dta/del/globex.html

    (You want RTH if you do it during your hours)

    http://finance.yahoo.com/m2?u

    And I usually keep one OE window open, which automatically checks for new mail every some minutes.

    If I then do something silly like opening a few more IE windows and actively using them to search for useful information, and open the MSDN library in another window, and on rare occasions a non-MS app, then the confusion will start pretty quickly. I’ll try to minimize a window and it will refuse to minimize. I’ll try to click on icons in the task bar for windows that are already minimized but they refuse to open. If enough windows are still being displayed, then clicking on the upper right to close them will free enough of Windows Resources, so that some of the messed up victim applications can be reopened after a fashion. Clicking on a button in the task bar to restore the window appears to fail but in fact it succeeds, with IE or OE or MSDN library having negative size and off-screen. It can be brought back on-screen by playing games as described.

    In Windows XP, the exact same behavior only happened to me about twice so I can’t exactly say how to reproduce it.

    In Windows XP, different but not entirely different behavior had some windows that could not be brought back on-screen at all. This involved having IE open to a completely different web site from any of those involved in the past. For MSDN product keys I had to get a Microsoft Passport. After evading MSDN’s effort to create a personal passport associated with a Windows XP account existing on one of my employer’s computers, I followed instructions to go to the sign-on screen and get a new passport associated with my personal e-mail account. But before proceeding to get such a passport, I clicked on two of the "help" items to see what assertions there were about privacy and such matters. These opened up IE windows that did not display at all, but which had buttons in the taskbar. I reported this to Microsoft already. Microsoft said to delete cookies. I deleted all known cookies associated with Microsoft (microsoft.com, msj.co.jp, 207.46.something). It worked. I was surprised, but it worked. On retrying, I got Microsoft’s assertions about its Passport privacy policy.

  23. Raymond Chen says:

    I tried scenario 1 twice on my 128MB P3 (800MHz) with a fresh copy of Windows XP (SP2) and neither time were there any "lost windows". Sorry.

  24. I suppose it should be possible to send you a screen shot the next time it happens, but I guess it won’t be possible to give a recipe to reproduce it.

    By the way you don’t say how many IE windows you opened each time. Say my estimate of 3% failures is accurate, and say you opened 20 IE windows twice, for a total of 40. This would be enough to expect an average of 1.2 failures, but not an enormous certainty of getting 1.

  25. Brian says:

    Is there any way to move application buttons around on the taskbar? For Example, I always want Outlook as the far left side button. Short of logging off and always starting Outlook first, how is that accomplished?

  26. Raymond Chen says:

    There is no facility to change the positions of the buttons. Buttons from the same program are grouped together.

  27. Mr. Chen, though this won’t help much, here’s a repro of the taskbar losing its button for an executing IE window. One of my home computers did this last night.

    http://home.att.ne.jp/star/ndiamond/xp-taskbar-bug.jpg

    This occasion was even more odd, because I don’t recall opening any new windows (applications or processes) when the taskbar suddenly decided to forget this one.

    At first glance it might look like the number of buttons in the taskbar matches the number of applications listed in the Windows Task Manager, so you’ll have to remember that the Windows Task Manager does not list itself as an executing application. The lost taskbar button is for the IE window for eBay item 2221926370.

    After capturing the screen image, opening Paint to save the bitmap and then Microsoft Photo Editor to convert it to JPEG, (i.e. after several minutes) I went back to the Windows Task Manager, selected that IE task, and clicked on ???? (Switch To). The correct IE window appeared, and a few seconds later a correct new button appeared in the taskbar.

    By the way, although I installed a PowerToy two years ago to switch desktops, I’ve never used it except for testing it the day I installed it. I probably ought to delete that PowerToy. But I don’t think it’s responsible for lost taskbar buttons. The day I tested it, it switched desktops but the taskbar remained unchanged, displaying buttons for all applications regardless of desktops.

    Also by the way, though this looks like an IE bug, I think it might not be. A few past occurences involved applications which are not part of IE or Windows Explorer or Outlook Express.

    Though this won’t help track down where the bug is, I hope it will help assure you that the bug is active.

  28. Gwyn Fisher says:

    Somewhat related question: I’ve noticed that several applications (MMC being the example du jour) manage to have modeless top-level dialogs show up in the Alt+Tab set of tasks, but not in the taskbar.

    For purposes of consistency (I’m writing a snap-in) my customer would like to have the modeless top-level dialogs that I create also exhibit this same behavior, i.e. be available for keyboard navigation via the Alt+Tab list, but not "clutter up" their taskbar.

    So… I’m feeling incredibly thick at this point, but the approaches I’ve tried so far don’t seem to do what MMC does, or anything close.

    Spy++ reports that MMC is subclassing its property sheets, but… what are they overriding in this particular context (spy++ usefully reports that the dialog doesn’t actually respond to *any* messages)?

    I’ve tried using ITaskbarList::DeleteTab on various messages (WM_ACTIVATE, etc.), but that simply results in a nice now-its-here, now-it-gone sort of game.

    So… anybody got bright ideas of how to accomplish this?

  29. Raymond Chen says:

    I don’t doubt that the bug exists, but without a way of consistently reproducing it, it’svery hard to diagnose. Like an automobile mechanic – there’s only so much you can do without studying the car *while* it is making the strange noise.

    Gwyn: It’s nothing that complicated. I forget precisely, but it’s just a combination of having an owned window (therefore not taskbar ineligible) and some extended style (I forget precisely which). A little more Spy++ action on the *extended* styles of the window and its owner should reveal somethinguseful.

  30. Gwyn Fisher says:

    Thanks for the feedback. As you say, it’s nothing that complicated. Turns out that what I was missing was the fact that the MMC property sheet named a hidden window as its parent (got to love Spy++), and if you do this (and that hidden window has the desktop as its parent), then Windows does all the work for you. Automagically your icon shows up in the Alt+Tab list, but not on the taskbar.

    Thanks for shoving me in the right direction.

  31. 2/4/2004 6:58 PM Raymond Chen:

    > I don’t doubt that the bug exists,

    At least that’s a start, thank you. At least I didn’t have to pay Microsoft 4,200 yen to get this far. Thank you.

    (Speaking of reproducibility, Microsoft added two bugs to Solitaire in Windows XP that I never saw in previous versions of Windows, one of which is 100% reproducible. I haven’t posted screenshots because other bugs in Windows are vastly more important. But perhaps I should post them for laughs, that one of them is 100% reproducible and that Microsoft even found a way to add bugs to Solitaire. Windows Server 2003 didn’t copy Solitaire bugs from XP though :-)

  32. Mary Breden says:

    Danit wrote: "The area in my win-xp taskbar that shows the tasks disappeared and I can’t get it back."

    I have also had the exact same problem, which occurred after "playing" with Desktop Manager and Tweak UI power toys. No buttons for open windows, folders, or applications appear on the taskbar. When minimized they simply disappear (with the normal animation effect of going down to the taskbar), but no taskbar button appears. Double clicking on the desktop icon of the window which was minimized retrieves the window from the taskbar (with the same animation effect).

    One other symptom is in the appearance of the "dotted" divider lines which appear when the taskbar is unlocked. These seem to be associated with the various toolbars on the taskbar, and there was a "blank" area between other tool bars where the application buttons were displayed. This "blank space" seems to be missing.

    Note that it only has affected my user login, not my husband’s, so this seems to be something user-specific, not system-wide.

    Is there a registry entry to toggle or tweak to fix this?

  33. Mary Breden says:

    Forgot to post my email – sorry.

  34. Raymond Chen says:

    You say they disappear but later talk about double-clicking on the desktop icon for the window — so they didn’t really disappear. They turned into a desktop icon rather than going onto the taskbar.

    This means that the notification that tells the taskbar "Hey, I just minimized a window, please make a button for it" isn’t working. This can happen if another program installs a WH_SHELL hook and fails to forward the notifications onward. Did you install any new software?

  35. Mary Breden says:

    The desktop icon was there before I started the application – in fact, double-clicking on the desktop icon was how I started the program in the first place. There should be a button on the taskbar for any active application – not just one that is minimized. There are no application buttons at all appearing on the taskbar – minimized or otherwise.

    The only new software I had installed was the XP Powertoys. I had installed the Desktop Manager, Tweak UI, Taskbar Magnifier, and CmdHere. I had played with all of them except the CmdHere program.

  36. Mary Breden says:

    I created a new user & have been using the Desktop Manager, Tweak UI, etc. with no problems so far… The only thing that I haven’t tried to use is to turn off the "Shared Desktop" option, so that the application buttons only show up on the taskbar associated with the desktop window that they are "in". I am guessing that this is what "broke" everything before…

    Has anyone used Desk Manager with this otion turned off – and not experienced problems??

  37. gilad says:

    ""If the window is a top-level unowned window, then it will show (when visible)."

    In XP the above is true about 97% of the time."

    how can i enumerate all windows that have a taskbar button? more accurate, how will i filter out those that don’t…

    i’m using VB6, but just a general idea of what i have to do will help a lot..

    thanks.

  38. Alec Soroudi says:

    A little off topic but it seems that when explorer crashes and is restarted, any windows that were opened BEFORE it crashed get disconnected from the taskbar. The result is that you can no longer minimize the window by clicking on it’s taskbar button while it’s active. However any windows that are created AFTER the crash perform correctly. I assume that the taskbar keeps an internal list of windows and uses that to perform the minimize action and when it crashes, then it no longer has the old list correct? If so, then I am still confounded because the taskbar creates new buttons for existing windows when explorer is restarted, so why does it not allow you to minimize them by clicking their buttons?

  39. Raymond Chen says:

    Commenting on this topic has been closed.

Comments are closed.


*DISCLAIMER: I DO NOT OWN THIS CONTENT. If you are the owner and would like it removed, please contact me. The content herein is an archived reproduction of entries from Raymond Chen's "Old New Thing" Blog (most recent link is here). It may have slight formatting modifications for consistency and to improve readability.

WHY DID I DUPLICATE THIS CONTENT HERE? Let me first say this site has never had anything to sell and has never shown ads of any kind. I have nothing monetarily to gain by duplicating content here. Because I had made my own local copy of this content throughout the years, for ease of using tools like grep, I decided to put it online after I discovered some of the original content previously and publicly available, had disappeared approximately early to mid 2019. At the same time, I present the content in an easily accessible theme-agnostic way.

The information provided by Raymond's blog is, for all practical purposes, more authoritative on Windows Development than Microsoft's own MSDN documentation and should be considered supplemental reading to that documentation. The wealth of missing details provided by this blog that Microsoft could not or did not document about Windows over the years is vital enough, many would agree an online "backup" of these details is a necessary endeavor. Specifics include:

<-- Back to Old New Thing Archive Index