Share via


SetWindowCompositionFlags (Compact 7)

3/12/2014

This function sets composition flag values to adjust the opacity capabilities of the window. You can set flags to use varying levels of opacity for UI elements in the window, change the TrueColor technology mode of the entire window, or display video playback on the window.

Syntax

BOOL WINAPI SetWindowCompositionFlags(
    HWND hwnd,
    DWORD dwFlags
);

Parameters

  • hwnd
    [in] Handle to the window to set composition flag values.
  • dwFlags
    [in] Composition flag values that set the opacity capabilities of the window. It can have one or more of the following possible values:

    Flag Value Description

    WCF_ALPHATRANSPARENCY

    0x00000001

    Adds information about the alpha channel to the window back buffer so that transparency information is composed separately for each pixel. When you set this flag, you must also notify the application and make sure to draw valid RGBA values into any window device context that you use in graphics programming.

    WCF_TRUECOLOR

    0x00000002

    Forces the window back buffer into TrueColor technology mode. TrueColor technology mode supports 24 bits per pixel (bpp) or 32 bpp and draws content using a larger range of color values on TrueColor displays.

Return Value

Returns true if it is successful; otherwise, returns false.

Remarks

You can create visual effects by combining and overlapping multiple windows that contain user interface (UI) elements of varying degrees of opacity. For example, you can create the appearance of a semi-transparent UI that overlays a background window.

When you set the WCF_ALPHATRANSPARENCY flag for the target overlay window, you can use techniques such as alpha blending or alpha blitting to control the opacity level of individual UI elements it contains. You can also draw elements with colors created by the RGBA macro, with which you can specify an alpha value that controls the opacity of the source fill color.

You can use this function for many different window types in Windows Embedded Compact 7, such as windows with DirectX content and windows with Silverlight for Windows Embedded content.

You can set or unset the window composition flags at any time. However, if you change the flags for a specified window, all the buffered content it contains will be cleared and the entire client region will be invalidated.

To use hardware-accelerated graphics for windows that support different opacity levels, you must include an OpenGL driver (the platform-dependent driver (PDD) component) in your OS design that supports the OpenGL Embedded Systems (ES) 2.0 specification.

SetWindowCompositionFlags lets you set different opacity levels for UI elements on the window. To request an opacity level for the complete window and all its elements, use SetWindowOpacity.

Example

The following code example shows how to call the SetWindowCompositionFlags function.

Important

For readability, the following code example does not contain security checking or error handling. Do not use the following code in a production environment.

#include <winuser.h>
#include <windows.h>

BOOL fUpdated = FALSE;

void UpdateCompositionFlags(BOOL fRequestTransparency, HWND hwnd)
{
  DWORD dwNewCompositionFlags = fRequestTransparency ? WCF_ALPHATRANSPARENCY | WCF_TRUECOLOR : 0;
  if (dwNewCompositionFlags != GetWindowCompositionFlags(hwnd))
    {
      SetWindowCompositionFlags(hwnd, dwNewCompositionFlags);
      fUpdated = TRUE;
    }
}

Requirements

Header

CompositorAPI.h,
winuser.h

sysgen

SYSGEN_COMPOSITION

See Also

Reference

Window Compositor Functions
Window Functions
GetWindowCompositionFlags