DrawThemeBackground function

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

Syntax

THEMEAPI DrawThemeBackground(
  HTHEME  hTheme,
  HDC     hdc,
  int     iPartId,
  int     iStateId,
  LPCRECT pRect,
  LPCRECT pClipRect
);

Parameters

hTheme

Type: HTHEME

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

hdc

Type: HDC

HDC used for drawing the theme-defined background image.

iPartId

Type: int

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

iStateId

Type: int

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

pRect

Type: const RECT*

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

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.

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

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

Requirements

   
Windows version Windows Vista [desktop apps only] Windows Server 2003 [desktop apps only]
Target Platform Windows
Header uxtheme.h
Library UxTheme.lib
DLL UxTheme.dll

See Also

Property Identifiers