Windows XP Alt-Tab Application Icon Rendering

The Windows XP Alt-Tab task switcher provided a fast visual index of open windows by querying, caching, and drawing application icons in a centered, floating grid. This article details the underlying Win32 mechanisms Windows XP used to locate these visual assets, prevent system hangs from unresponsive processes, and render 32-bit alpha-blended icons to the screen.

Querying Window Icons

When the user presses Alt + Tab, the internal desktop window manager in user32.dll constructs a list of eligible top-level windows. To represent each program, the system attempts to resolve a 32x32 pixel icon handle (HICON) through a prioritized fallback sequence:

  1. WM_GETICON (ICON_BIG): The switcher queries the window directly for a developer-defined large icon.
  2. Class Icon (GCLP_HICON): If the window returns NULL, the switcher queries the window class registered during application initialization using GetClassLongPtr.
  3. WM_GETICON (ICON_SMALL2) or WM_GETICON (ICON_SMALL): If no large icon exists, the switcher attempts to fetch an explicit small icon.
  4. Small Class Icon (GCLP_HICONSM): The switcher checks for a small icon registered to the window class.
  5. Default System Icon: If all queries fail, Windows XP assigns the generic Win32 executable icon (an outline of an application window).

Unresponsive Process Protection

Querying an application via standard message routing (SendMessage) poses a reliability risk: if a target application is hung or deadlocked, the Alt-Tab UI will freeze while waiting for a response.

To prevent switcher lockups, Windows XP queries WM_GETICON using SendMessageTimeout. The call specifies flags such as SMTO_ABORTIFHUNG and SMTO_BLOCK, alongside a short timeout (typically 100 to 200 milliseconds). If an application fails to respond within that window, the query aborts immediately, and the switcher falls back to the window class icon or the generic placeholder.

Graphical Rendering and Alpha Transparency

Once icon handles are acquired, the switcher calculates the grid dimensions based on the total number of qualifying tasks, maintaining a maximum column width before wrapping into additional rows.

Windows XP was the first consumer Windows release to support 32-bit ARGB (alpha-blended) icons alongside traditional 1-bit transparency masks. Icon rendering in the Alt-Tab dialog relies on the following graphics pipeline:

  • DC Acquisition: The switcher creates a memory Device Context (DC) compatible with the desktop to eliminate flicker.
  • DrawIconEx Invocation: Each icon is drawn onto the memory DC using DrawIconEx. The function is configured with the target coordinates, the desired dimension (32x32 pixels), and flags (DI_NORMAL) directing the API to combine both color and mask data.
  • Alpha Blending: If the icon file contains a 32-bit ARGB DIB (Device-Independent Bitmap), the GDI rendering subsystem automatically composites the icon's semi-transparent pixels directly against the Alt-Tab dialog's background color (either classic gray or the Luna theme's styled panel).
  • Selection Highlighting: When an item is selected, the switcher renders a 1-pixel highlight rectangle around the icon slot and blits the cached memory DC to the screen using BitBlt.