Layered window

Quick links: Download - Description

The Layered window demonstrates transparent windows available under NT 5+.

Layered window requires at least Windows 2000.


Layered window, (2003-02-18)


This program was written as an experiment with Layered Windows as supported by the Windows API.

To use transparency, we override the default processing of the WM_PAINT message, setting the WS_EX_LAYERED extended style and calling SetLayeredWindowAttributes() to specify an alpha value.

device = BeginPaint(window, &ps);
SetWindowLongPtr(window, GWL_EXSTYLE, GetWindowLongPtr(window, GWL_EXSTYLE) | WS_EX_LAYERED);
SetLayeredWindowAttributes(window, 0, alpha, LWA_ALPHA);
EndPaint(window, &ps);

The application uses a slider bar to control the transparency value. Don't forget to call InitCommonControls() before trying to use the slide.