SetWindowTheme function (uxtheme.h)

Causes a window to use a different set of visual style information than its class normally uses.


HRESULT SetWindowTheme(
  [in] HWND    hwnd,
  [in] LPCWSTR pszSubAppName,
  [in] LPCWSTR pszSubIdList


[in] hwnd

Type: HWND

Handle to the window whose visual style information is to be changed.

[in] pszSubAppName


Pointer to a string that contains the application name to use in place of the calling application's name. If this parameter is NULL, the calling application's name is used.

[in] pszSubIdList


Pointer to a string that contains a semicolon-separated list of CLSID names to use in place of the actual list passed by the window's class. If this parameter is NULL, the ID list from the calling class is used.

Return value


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


The theme manager retains the pszSubAppName and the pszSubIdList associations through the lifetime of the window, even if visual styles subsequently change. The window is sent a WM_THEMECHANGED message at the end of a SetWindowTheme call, so that the new visual style can be found and applied.

When pszSubAppName and pszSubIdList are NULL, the theme manager removes the previously applied associations. You can prevent visual styles from being applied to a specified window by specifying an empty string, (L" "), which does not match any section entries.


The following example code gives a list-view control the appearance of a Windows Explorer list:

SetWindowTheme(hwndList, L"Explorer", NULL);


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