My app leaves a phantom gray button on the taskbar.

You get this problem when you change the window styles that affect the visibility of a window in the taskbar, you naughty little tinker.

For example, if you change your windows extended style to include WS_EX_TOOLWINDOW style (a common trick to prevent a window appearing in the taskbar) and then fail to reset the extended style before closing the window, the taskbar shows a phantom gray button, which vanishes when clicked.

Solutions?

  1. Reset the style bits of the window before closing your app, or
  2. Call ShowWindow with SW_HIDE for the application's main window while processing WM_CLOSE or WM_DESTROY.