Window Display Effects for VO: No. 2

Windows 2000 and higher support a feature to set the transparency of a window. This example shows how you can make the Windows Taskbar semi-transparent. While the taskbar is still visible any windows that are moved behind it still show through.

This same technique can be used on windows other than the taskbar as well.


METHOD Start() CLASS app
    // Sample to show how to make taskbar transparent (Win2000 and above)
    // Paul Piko, December 2001

    // Find the handle of the taskbar window
    hWnd := FindWindow(PSZ("Shell_TrayWnd"),NULL)
    // Set WS_EX_LAYERED on this window so that
    // SetLayeredWindowAttributes can be used on it
    SetWindowLong(hWnd, GWL_EXSTYLE, ;
           _or(GetWindowLong(hWnd, GWL_EXSTYLE),WS_EX_LAYERED))
    // Make the window (taskbar) 50% transparent
    // 0 means transparent, 255 means opaque
    SetLayeredWindowAttributes(hWnd, 0, INT(255 * 0.50), LWA_ALPHA)
DEFINE LWA_ALPHA := 0x00000002


_DLL FUNC SetLayeredWindowAttributes(hWnd AS PTR, nColor AS INT, ;
               bAlpha AS INT, dwFlags AS DWORD);
               AS LOGIC PASCAL:USER32.SetLayeredWindowAttributes

DEFINE WS_EX_LAYERED := 0x00080000
Page generated from source code by VO Export Explorer,
one of the utilities in the VO Productivity Pack