DrawThemeBackground function (uxtheme.h)

Draws the border and fill defined by the visual style for the specified control part.

Syntax

HRESULT DrawThemeBackground(
  [in] HTHEME  hTheme,
  [in] HDC     hdc,
  [in] int     iPartId,
  [in] int     iStateId,
  [in] LPCRECT pRect,
  [in] LPCRECT pClipRect
);

Parameters

[in] hTheme

Type: HTHEME

Handle to a window's specified theme data. Use OpenThemeData to create an HTHEME.

[in] hdc

Type: HDC

HDC used for drawing the theme-defined background image.

[in] iPartId

Type: int

Value of type int that specifies the part to draw. See Parts and States.

[in] iStateId

Type: int

Value of type int that specifies the state of the part to draw. See Parts and States.

[in] pRect

Type: const RECT*

Pointer to a RECT structure that contains the rectangle, in logical coordinates, in which the background image is drawn.

[in] pClipRect

Type: const RECT*

Pointer to a RECT structure that contains a clipping rectangle. This parameter may be set to NULL.

Return value

Type: HRESULT

If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.

Remarks

Drawing operations are scaled to fit and not exceed the rectangle specified in pRect. Your application should not draw outside the rectangle specified by pClipRect.

Examples

Prior to calling DrawThemeBackground to draw the background image for a window, you may call IsThemeBackgroundPartiallyTransparent. This method determines whether DrawThemeParentBackground should be called to draw in backgrounds behind partially-transparent or alpha-blended child controls, and is demonstrated in the following example.

if (_hTheme)
{
  if (IsThemeBackgroundPartiallyTransparent(_hTheme, BP_PUSHBUTTON, _iStateId))
  {
    DrawThemeParentBackground(_hwnd, hdcPaint, prcPaint);
  }

  DrawThemeBackground(_hTheme,
                    hdcPaint,
                    BP_PUSHBUTTON,
                    _iStateId,
                    &rcClient,
                    prcPaint);
}

Requirements

Requirement Value
Minimum supported client Windows Vista [desktop apps only]
Minimum supported server Windows Server 2003 [desktop apps only]
Target Platform Windows
Header uxtheme.h
Library UxTheme.lib
DLL UxTheme.dll

See also

Property Identifiers