Source: msdn
This topic describes the use of the visual styles API to create custom controls or owner-drawn controls that take advantage of the visual styles available in Microsoft Windows XP and later versions of the operating system.
First your application should determine whether visual styles are available, by calling IsAppThemed. If visual styles are not available, use fallback code to draw the control.
If visual styles are available, you can use visual-styles functions such as DrawThemeText to render your control. Note that DrawThemeTextEx enables you to customize the appearance of text, retaining some properties of the theme font while modifying others.
To draw a control in the current visual style
- Call OpenThemeData, passing the hwnd of the control you want to apply visual styles to and a class list that describes the control’s type. The classes are defined in Vssym32.h. OpenThemeData returns an HTHEME handle, but if the visual styles manager is disabled or the current visual style does not supply specific information for a given control, the function returns NULL. If the return value is NULL, use non-visual-styles drawing functions.
- To draw the control background, call DrawThemeBackground or DrawThemeBackgroundEx.
- To determine the location of the content rectangle, call GetThemeBackgroundContentRect.
- To render text, use either DrawThemeText or DrawThemeTextEx, basing the coordinates on the rectangle returned by GetThemeBackgroundContentRect. These functions can render text either in the theme’s font for a specified control part and state, or in the font currently selected into the device context (DC).
- When your control receives a WM_DESTROY message, call CloseThemeData to release the theme handle that was returned when you called OpenThemeData.
Responding to Theme Changes
When your control receives a WM_THEMECHANGED message and is holding a global handle to the theme, it should do the following:
- Call CloseThemeData to close the existing theme handle.
- Call OpenThemeData to get the theme handle to the newly loaded visual style.