DrawThemedControl function
Return to Introduction  Previous page 
Unit
acXPThemes  

Declaration
procedure DrawThemedControl(Wnd: hWnd; DC: hDC; ClassList: lpCWStr; iPartId, iStateId: Integer; const Rect: TRect);  

Description
The DrawThemedControl function helps to quickly and easily draws the control without opening/closing the theme and painting the parent's background. It is helper for standard WinXP theme API.  
 
Parameters  
WndWindow handle of the control/window to be themed  
DCHandle to a device context (HDC) used for drawing the theme-defined background image;  
ClassListClass name (or list of names separated by semi-colon) to match to theme data section;  
iPartIdValue of type int that specifies the part to draw;  
iStateIdValue of type int that specifies the state of the part to draw;  
RectA TRect structure that contains the rectangle, in logical coordinates, in which the background image is drawn.  

Original code
procedure DrawThemedControl(Wnd: hWnd; DC: hDC; ClassList: lpCWStr; iPartId, iStateId: Integer; const Rect: TRect);  
var  
  Theme: hTheme;  
begin  
  Theme := OpenThemeData(Wnd, ClassList);  
  if Theme <> 0 then  
   begin  
    DrawThemeParentBackground(Wnd, DC, @Rect);  
    DrawThemeBackground(Theme, DC, iPartId, iStateId, Rect, nil);  
    CloseThemeData(Theme);  
   end;  
end;  

See also
IsXPThemeEnabled, OpenThemeData, CloseThemeData, DrawThemeBackground and DrawThemeParentBackground functions.