2003-12-04 21:55:30 +01:00
|
|
|
/*
|
|
|
|
* Win32 5.1 Theme system
|
|
|
|
*
|
|
|
|
* Copyright (C) 2003 Kevin Koltzau
|
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2003-12-04 21:55:30 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
|
|
|
|
#include <stdarg.h>
|
2005-08-12 17:51:13 +02:00
|
|
|
#include <stdio.h>
|
2003-12-04 21:55:30 +01:00
|
|
|
|
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
|
|
|
#include "wingdi.h"
|
2006-08-14 19:22:18 +02:00
|
|
|
#include "winuser.h"
|
2003-12-08 23:45:26 +01:00
|
|
|
#include "winreg.h"
|
2006-11-08 00:57:55 +01:00
|
|
|
#include "vfwmsgs.h"
|
2003-12-04 21:55:30 +01:00
|
|
|
#include "uxtheme.h"
|
2004-01-16 22:25:25 +01:00
|
|
|
#include "tmschema.h"
|
2003-12-04 21:55:30 +01:00
|
|
|
|
|
|
|
#include "uxthemedll.h"
|
2003-12-08 23:45:26 +01:00
|
|
|
#include "msstyles.h"
|
2003-12-04 21:55:30 +01:00
|
|
|
|
|
|
|
#include "wine/debug.h"
|
|
|
|
|
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(uxtheme);
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* Defines and global variables
|
|
|
|
*/
|
|
|
|
|
2003-12-08 23:45:26 +01:00
|
|
|
static const WCHAR szThemeManager[] = {
|
|
|
|
'S','o','f','t','w','a','r','e','\\',
|
|
|
|
'M','i','c','r','o','s','o','f','t','\\',
|
|
|
|
'W','i','n','d','o','w','s','\\',
|
|
|
|
'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\\',
|
|
|
|
'T','h','e','m','e','M','a','n','a','g','e','r','\0'
|
|
|
|
};
|
|
|
|
static const WCHAR szThemeActive[] = {'T','h','e','m','e','A','c','t','i','v','e','\0'};
|
|
|
|
static const WCHAR szSizeName[] = {'S','i','z','e','N','a','m','e','\0'};
|
|
|
|
static const WCHAR szColorName[] = {'C','o','l','o','r','N','a','m','e','\0'};
|
|
|
|
static const WCHAR szDllName[] = {'D','l','l','N','a','m','e','\0'};
|
|
|
|
|
2004-01-16 22:25:25 +01:00
|
|
|
static const WCHAR szIniDocumentation[] = {'d','o','c','u','m','e','n','t','a','t','i','o','n','\0'};
|
|
|
|
|
2011-05-13 18:23:06 +02:00
|
|
|
DECLSPEC_HIDDEN ATOM atDialogThemeEnabled;
|
2003-12-04 21:55:30 +01:00
|
|
|
|
2006-08-02 13:33:01 +02:00
|
|
|
static DWORD dwThemeAppProperties = STAP_ALLOW_NONCLIENT | STAP_ALLOW_CONTROLS;
|
|
|
|
static ATOM atWindowTheme;
|
|
|
|
static ATOM atSubAppName;
|
|
|
|
static ATOM atSubIdList;
|
|
|
|
|
|
|
|
static BOOL bThemeActive = FALSE;
|
|
|
|
static WCHAR szCurrentTheme[MAX_PATH];
|
|
|
|
static WCHAR szCurrentColor[64];
|
|
|
|
static WCHAR szCurrentSize[64];
|
2003-12-08 23:45:26 +01:00
|
|
|
|
2003-12-04 21:55:30 +01:00
|
|
|
/***********************************************************************/
|
|
|
|
|
2005-07-06 12:32:30 +02:00
|
|
|
static BOOL CALLBACK UXTHEME_broadcast_msg_enumchild (HWND hWnd, LPARAM msg)
|
|
|
|
{
|
|
|
|
PostMessageW(hWnd, msg, 0, 0);
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Broadcast a message to *all* windows, including children */
|
|
|
|
static BOOL CALLBACK UXTHEME_broadcast_msg (HWND hWnd, LPARAM msg)
|
|
|
|
{
|
|
|
|
if (hWnd == NULL)
|
|
|
|
{
|
|
|
|
EnumWindows (UXTHEME_broadcast_msg, msg);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
PostMessageW(hWnd, msg, 0, 0);
|
|
|
|
EnumChildWindows (hWnd, UXTHEME_broadcast_msg_enumchild, msg);
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
2005-09-02 14:29:02 +02:00
|
|
|
/* At the end of the day this is a subset of what SHRegGetPath() does - copied
|
|
|
|
* here to avoid linking against shlwapi. */
|
|
|
|
static DWORD query_reg_path (HKEY hKey, LPCWSTR lpszValue,
|
|
|
|
LPVOID pvData)
|
|
|
|
{
|
|
|
|
DWORD dwRet, dwType, dwUnExpDataLen = MAX_PATH, dwExpDataLen;
|
|
|
|
|
|
|
|
TRACE("(hkey=%p,%s,%p)\n", hKey, debugstr_w(lpszValue),
|
|
|
|
pvData);
|
|
|
|
|
|
|
|
dwRet = RegQueryValueExW(hKey, lpszValue, 0, &dwType, pvData, &dwUnExpDataLen);
|
|
|
|
if (dwRet!=ERROR_SUCCESS && dwRet!=ERROR_MORE_DATA)
|
|
|
|
return dwRet;
|
|
|
|
|
|
|
|
if (dwType == REG_EXPAND_SZ)
|
|
|
|
{
|
|
|
|
DWORD nBytesToAlloc;
|
|
|
|
|
|
|
|
/* Expand type REG_EXPAND_SZ into REG_SZ */
|
|
|
|
LPWSTR szData;
|
|
|
|
|
|
|
|
/* If the caller didn't supply a buffer or the buffer is too small we have
|
|
|
|
* to allocate our own
|
|
|
|
*/
|
|
|
|
if (dwRet == ERROR_MORE_DATA)
|
|
|
|
{
|
|
|
|
WCHAR cNull = '\0';
|
|
|
|
nBytesToAlloc = dwUnExpDataLen;
|
|
|
|
|
2008-11-02 22:35:17 +01:00
|
|
|
szData = LocalAlloc(LMEM_ZEROINIT, nBytesToAlloc);
|
2005-09-02 14:29:02 +02:00
|
|
|
RegQueryValueExW (hKey, lpszValue, 0, NULL, (LPBYTE)szData, &nBytesToAlloc);
|
|
|
|
dwExpDataLen = ExpandEnvironmentStringsW(szData, &cNull, 1);
|
|
|
|
dwUnExpDataLen = max(nBytesToAlloc, dwExpDataLen);
|
2009-01-13 10:55:29 +01:00
|
|
|
LocalFree(szData);
|
2005-09-02 14:29:02 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
nBytesToAlloc = (lstrlenW(pvData) + 1) * sizeof(WCHAR);
|
2008-11-02 22:35:17 +01:00
|
|
|
szData = LocalAlloc(LMEM_ZEROINIT, nBytesToAlloc );
|
2005-09-02 14:29:02 +02:00
|
|
|
lstrcpyW(szData, pvData);
|
|
|
|
dwExpDataLen = ExpandEnvironmentStringsW(szData, pvData, MAX_PATH );
|
|
|
|
if (dwExpDataLen > MAX_PATH) dwRet = ERROR_MORE_DATA;
|
|
|
|
dwUnExpDataLen = max(nBytesToAlloc, dwExpDataLen);
|
2009-01-13 10:55:29 +01:00
|
|
|
LocalFree(szData);
|
2005-09-02 14:29:02 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
RegCloseKey(hKey);
|
|
|
|
return dwRet;
|
|
|
|
}
|
|
|
|
|
2003-12-04 21:55:30 +01:00
|
|
|
/***********************************************************************
|
2004-01-16 22:25:25 +01:00
|
|
|
* UXTHEME_LoadTheme
|
|
|
|
*
|
|
|
|
* Set the current active theme from the registry
|
2003-12-04 21:55:30 +01:00
|
|
|
*/
|
2005-06-21 22:53:13 +02:00
|
|
|
static void UXTHEME_LoadTheme(void)
|
2003-12-04 21:55:30 +01:00
|
|
|
{
|
2003-12-08 23:45:26 +01:00
|
|
|
HKEY hKey;
|
2005-07-07 14:08:42 +02:00
|
|
|
DWORD buffsize;
|
2003-12-08 23:45:26 +01:00
|
|
|
HRESULT hr;
|
|
|
|
WCHAR tmp[10];
|
|
|
|
PTHEME_FILE pt;
|
2003-12-04 21:55:30 +01:00
|
|
|
|
2003-12-08 23:45:26 +01:00
|
|
|
/* Get current theme configuration */
|
|
|
|
if(!RegOpenKeyW(HKEY_CURRENT_USER, szThemeManager, &hKey)) {
|
|
|
|
TRACE("Loading theme config\n");
|
2018-09-18 20:38:19 +02:00
|
|
|
buffsize = ARRAY_SIZE(tmp);
|
2003-12-08 23:45:26 +01:00
|
|
|
if(!RegQueryValueExW(hKey, szThemeActive, NULL, NULL, (LPBYTE)tmp, &buffsize)) {
|
|
|
|
bThemeActive = (tmp[0] != '0');
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
bThemeActive = FALSE;
|
2006-10-08 19:34:18 +02:00
|
|
|
TRACE("Failed to get ThemeActive: %d\n", GetLastError());
|
2003-12-08 23:45:26 +01:00
|
|
|
}
|
2018-09-18 20:38:19 +02:00
|
|
|
buffsize = ARRAY_SIZE(szCurrentColor);
|
2003-12-08 23:45:26 +01:00
|
|
|
if(RegQueryValueExW(hKey, szColorName, NULL, NULL, (LPBYTE)szCurrentColor, &buffsize))
|
|
|
|
szCurrentColor[0] = '\0';
|
2018-09-18 20:38:19 +02:00
|
|
|
buffsize = ARRAY_SIZE(szCurrentSize);
|
2003-12-08 23:45:26 +01:00
|
|
|
if(RegQueryValueExW(hKey, szSizeName, NULL, NULL, (LPBYTE)szCurrentSize, &buffsize))
|
|
|
|
szCurrentSize[0] = '\0';
|
2005-09-02 14:29:02 +02:00
|
|
|
if (query_reg_path (hKey, szDllName, szCurrentTheme))
|
2003-12-08 23:45:26 +01:00
|
|
|
szCurrentTheme[0] = '\0';
|
|
|
|
RegCloseKey(hKey);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
TRACE("Failed to open theme registry key\n");
|
|
|
|
|
|
|
|
if(bThemeActive) {
|
|
|
|
/* Make sure the theme requested is actually valid */
|
|
|
|
hr = MSSTYLES_OpenThemeFile(szCurrentTheme,
|
|
|
|
szCurrentColor[0]?szCurrentColor:NULL,
|
|
|
|
szCurrentSize[0]?szCurrentSize:NULL,
|
|
|
|
&pt);
|
|
|
|
if(FAILED(hr)) {
|
|
|
|
bThemeActive = FALSE;
|
|
|
|
szCurrentTheme[0] = '\0';
|
|
|
|
szCurrentColor[0] = '\0';
|
|
|
|
szCurrentSize[0] = '\0';
|
|
|
|
}
|
|
|
|
else {
|
|
|
|
/* Make sure the global color & size match the theme */
|
2018-09-18 20:38:19 +02:00
|
|
|
lstrcpynW(szCurrentColor, pt->pszSelectedColor, ARRAY_SIZE(szCurrentColor));
|
|
|
|
lstrcpynW(szCurrentSize, pt->pszSelectedSize, ARRAY_SIZE(szCurrentSize));
|
2004-01-16 22:25:25 +01:00
|
|
|
|
2005-08-12 17:51:13 +02:00
|
|
|
MSSTYLES_SetActiveTheme(pt, FALSE);
|
2004-01-16 22:25:25 +01:00
|
|
|
TRACE("Theme active: %s %s %s\n", debugstr_w(szCurrentTheme),
|
|
|
|
debugstr_w(szCurrentColor), debugstr_w(szCurrentSize));
|
2003-12-08 23:45:26 +01:00
|
|
|
MSSTYLES_CloseThemeFile(pt);
|
|
|
|
}
|
|
|
|
}
|
2004-01-16 22:25:25 +01:00
|
|
|
if(!bThemeActive) {
|
2005-08-12 17:51:13 +02:00
|
|
|
MSSTYLES_SetActiveTheme(NULL, FALSE);
|
2006-11-12 19:51:37 +01:00
|
|
|
TRACE("Theming not active\n");
|
2004-01-16 22:25:25 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-08-12 17:51:13 +02:00
|
|
|
/***********************************************************************/
|
|
|
|
|
|
|
|
static const char * const SysColorsNames[] =
|
|
|
|
{
|
|
|
|
"Scrollbar", /* COLOR_SCROLLBAR */
|
|
|
|
"Background", /* COLOR_BACKGROUND */
|
|
|
|
"ActiveTitle", /* COLOR_ACTIVECAPTION */
|
|
|
|
"InactiveTitle", /* COLOR_INACTIVECAPTION */
|
|
|
|
"Menu", /* COLOR_MENU */
|
|
|
|
"Window", /* COLOR_WINDOW */
|
|
|
|
"WindowFrame", /* COLOR_WINDOWFRAME */
|
|
|
|
"MenuText", /* COLOR_MENUTEXT */
|
|
|
|
"WindowText", /* COLOR_WINDOWTEXT */
|
|
|
|
"TitleText", /* COLOR_CAPTIONTEXT */
|
|
|
|
"ActiveBorder", /* COLOR_ACTIVEBORDER */
|
|
|
|
"InactiveBorder", /* COLOR_INACTIVEBORDER */
|
|
|
|
"AppWorkSpace", /* COLOR_APPWORKSPACE */
|
|
|
|
"Hilight", /* COLOR_HIGHLIGHT */
|
|
|
|
"HilightText", /* COLOR_HIGHLIGHTTEXT */
|
|
|
|
"ButtonFace", /* COLOR_BTNFACE */
|
|
|
|
"ButtonShadow", /* COLOR_BTNSHADOW */
|
|
|
|
"GrayText", /* COLOR_GRAYTEXT */
|
|
|
|
"ButtonText", /* COLOR_BTNTEXT */
|
|
|
|
"InactiveTitleText", /* COLOR_INACTIVECAPTIONTEXT */
|
|
|
|
"ButtonHilight", /* COLOR_BTNHIGHLIGHT */
|
|
|
|
"ButtonDkShadow", /* COLOR_3DDKSHADOW */
|
|
|
|
"ButtonLight", /* COLOR_3DLIGHT */
|
|
|
|
"InfoText", /* COLOR_INFOTEXT */
|
|
|
|
"InfoWindow", /* COLOR_INFOBK */
|
|
|
|
"ButtonAlternateFace", /* COLOR_ALTERNATEBTNFACE */
|
|
|
|
"HotTrackingColor", /* COLOR_HOTLIGHT */
|
|
|
|
"GradientActiveTitle", /* COLOR_GRADIENTACTIVECAPTION */
|
|
|
|
"GradientInactiveTitle", /* COLOR_GRADIENTINACTIVECAPTION */
|
|
|
|
"MenuHilight", /* COLOR_MENUHILIGHT */
|
|
|
|
"MenuBar", /* COLOR_MENUBAR */
|
|
|
|
};
|
|
|
|
static const WCHAR strColorKey[] =
|
|
|
|
{ 'C','o','n','t','r','o','l',' ','P','a','n','e','l','\\',
|
|
|
|
'C','o','l','o','r','s',0 };
|
|
|
|
static const WCHAR keyFlatMenus[] = { 'F','l','a','t','M','e','n','u', 0};
|
2006-08-14 17:02:37 +02:00
|
|
|
static const WCHAR keyGradientCaption[] = { 'G','r','a','d','i','e','n','t',
|
|
|
|
'C','a','p','t','i','o','n', 0 };
|
2006-08-14 19:22:18 +02:00
|
|
|
static const WCHAR keyNonClientMetrics[] = { 'N','o','n','C','l','i','e','n','t',
|
|
|
|
'M','e','t','r','i','c','s',0 };
|
|
|
|
static const WCHAR keyIconTitleFont[] = { 'I','c','o','n','T','i','t','l','e',
|
|
|
|
'F','o','n','t',0 };
|
2005-08-12 17:51:13 +02:00
|
|
|
|
|
|
|
static const struct BackupSysParam
|
|
|
|
{
|
|
|
|
int spiGet, spiSet;
|
|
|
|
const WCHAR* keyName;
|
|
|
|
} backupSysParams[] =
|
|
|
|
{
|
|
|
|
{SPI_GETFLATMENU, SPI_SETFLATMENU, keyFlatMenus},
|
2006-08-14 17:02:37 +02:00
|
|
|
{SPI_GETGRADIENTCAPTIONS, SPI_SETGRADIENTCAPTIONS, keyGradientCaption},
|
2005-08-12 17:51:13 +02:00
|
|
|
{-1, -1, 0}
|
|
|
|
};
|
|
|
|
|
|
|
|
#define NUM_SYS_COLORS (COLOR_MENUBAR+1)
|
|
|
|
|
|
|
|
static void save_sys_colors (HKEY baseKey)
|
|
|
|
{
|
|
|
|
char colorStr[13];
|
|
|
|
HKEY hKey;
|
|
|
|
int i;
|
|
|
|
|
|
|
|
if (RegCreateKeyExW( baseKey, strColorKey,
|
|
|
|
0, 0, 0, KEY_ALL_ACCESS,
|
|
|
|
0, &hKey, 0 ) == ERROR_SUCCESS)
|
|
|
|
{
|
|
|
|
for (i = 0; i < NUM_SYS_COLORS; i++)
|
|
|
|
{
|
|
|
|
COLORREF col = GetSysColor (i);
|
|
|
|
|
|
|
|
sprintf (colorStr, "%d %d %d",
|
|
|
|
GetRValue (col), GetGValue (col), GetBValue (col));
|
|
|
|
|
|
|
|
RegSetValueExA (hKey, SysColorsNames[i], 0, REG_SZ,
|
|
|
|
(BYTE*)colorStr, strlen (colorStr)+1);
|
|
|
|
}
|
|
|
|
RegCloseKey (hKey);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Before activating a theme, query current system colors, certain settings
|
|
|
|
* and backup them in the registry, so they can be restored when the theme
|
|
|
|
* is deactivated */
|
|
|
|
static void UXTHEME_BackupSystemMetrics(void)
|
|
|
|
{
|
|
|
|
HKEY hKey;
|
|
|
|
const struct BackupSysParam* bsp = backupSysParams;
|
|
|
|
|
|
|
|
if (RegCreateKeyExW( HKEY_CURRENT_USER, szThemeManager,
|
|
|
|
0, 0, 0, KEY_ALL_ACCESS,
|
|
|
|
0, &hKey, 0) == ERROR_SUCCESS)
|
|
|
|
{
|
2006-08-14 19:22:18 +02:00
|
|
|
NONCLIENTMETRICSW ncm;
|
|
|
|
LOGFONTW iconTitleFont;
|
|
|
|
|
|
|
|
/* back up colors */
|
2005-08-12 17:51:13 +02:00
|
|
|
save_sys_colors (hKey);
|
|
|
|
|
2006-08-14 19:22:18 +02:00
|
|
|
/* back up "other" settings */
|
2005-08-12 17:51:13 +02:00
|
|
|
while (bsp->spiGet >= 0)
|
|
|
|
{
|
|
|
|
DWORD value;
|
|
|
|
|
|
|
|
SystemParametersInfoW (bsp->spiGet, 0, &value, 0);
|
|
|
|
RegSetValueExW (hKey, bsp->keyName, 0, REG_DWORD,
|
|
|
|
(LPBYTE)&value, sizeof (value));
|
|
|
|
|
|
|
|
bsp++;
|
|
|
|
}
|
2006-08-14 19:22:18 +02:00
|
|
|
|
|
|
|
/* back up non-client metrics */
|
|
|
|
memset (&ncm, 0, sizeof (ncm));
|
|
|
|
ncm.cbSize = sizeof (ncm);
|
|
|
|
SystemParametersInfoW (SPI_GETNONCLIENTMETRICS, sizeof (ncm), &ncm, 0);
|
|
|
|
RegSetValueExW (hKey, keyNonClientMetrics, 0, REG_BINARY, (LPBYTE)&ncm,
|
|
|
|
sizeof (ncm));
|
|
|
|
memset (&iconTitleFont, 0, sizeof (iconTitleFont));
|
|
|
|
SystemParametersInfoW (SPI_GETICONTITLELOGFONT, sizeof (iconTitleFont),
|
|
|
|
&iconTitleFont, 0);
|
|
|
|
RegSetValueExW (hKey, keyIconTitleFont, 0, REG_BINARY,
|
|
|
|
(LPBYTE)&iconTitleFont, sizeof (iconTitleFont));
|
2005-08-12 17:51:13 +02:00
|
|
|
|
|
|
|
RegCloseKey (hKey);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Read back old settings after a theme was deactivated */
|
|
|
|
static void UXTHEME_RestoreSystemMetrics(void)
|
|
|
|
{
|
|
|
|
HKEY hKey;
|
|
|
|
const struct BackupSysParam* bsp = backupSysParams;
|
|
|
|
|
|
|
|
if (RegOpenKeyExW (HKEY_CURRENT_USER, szThemeManager,
|
|
|
|
0, KEY_QUERY_VALUE, &hKey) == ERROR_SUCCESS)
|
|
|
|
{
|
|
|
|
HKEY colorKey;
|
|
|
|
|
|
|
|
/* read backed-up colors */
|
|
|
|
if (RegOpenKeyExW (hKey, strColorKey,
|
|
|
|
0, KEY_QUERY_VALUE, &colorKey) == ERROR_SUCCESS)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
COLORREF sysCols[NUM_SYS_COLORS];
|
|
|
|
int sysColsIndices[NUM_SYS_COLORS];
|
|
|
|
int sysColCount = 0;
|
|
|
|
|
|
|
|
for (i = 0; i < NUM_SYS_COLORS; i++)
|
|
|
|
{
|
|
|
|
DWORD type;
|
|
|
|
char colorStr[13];
|
|
|
|
DWORD count = sizeof(colorStr);
|
|
|
|
|
2005-08-15 12:23:48 +02:00
|
|
|
if (RegQueryValueExA (colorKey, SysColorsNames[i], 0,
|
2005-09-06 12:26:13 +02:00
|
|
|
&type, (LPBYTE) colorStr, &count) == ERROR_SUCCESS)
|
2005-08-12 17:51:13 +02:00
|
|
|
{
|
|
|
|
int r, g, b;
|
|
|
|
if (sscanf (colorStr, "%d %d %d", &r, &g, &b) == 3)
|
|
|
|
{
|
|
|
|
sysColsIndices[sysColCount] = i;
|
|
|
|
sysCols[sysColCount] = RGB(r, g, b);
|
|
|
|
sysColCount++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
RegCloseKey (colorKey);
|
|
|
|
|
|
|
|
SetSysColors (sysColCount, sysColsIndices, sysCols);
|
|
|
|
}
|
|
|
|
|
|
|
|
/* read backed-up other settings */
|
|
|
|
while (bsp->spiGet >= 0)
|
|
|
|
{
|
|
|
|
DWORD value;
|
|
|
|
DWORD count = sizeof(value);
|
|
|
|
DWORD type;
|
|
|
|
|
2005-08-15 12:23:48 +02:00
|
|
|
if (RegQueryValueExW (hKey, bsp->keyName, 0,
|
|
|
|
&type, (LPBYTE)&value, &count) == ERROR_SUCCESS)
|
2005-08-12 17:51:13 +02:00
|
|
|
{
|
2009-12-09 12:04:08 +01:00
|
|
|
SystemParametersInfoW (bsp->spiSet, 0, UlongToPtr(value), SPIF_UPDATEINIFILE);
|
2005-08-12 17:51:13 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
bsp++;
|
|
|
|
}
|
|
|
|
|
2006-08-14 19:22:18 +02:00
|
|
|
/* read backed-up non-client metrics */
|
|
|
|
{
|
|
|
|
NONCLIENTMETRICSW ncm;
|
|
|
|
LOGFONTW iconTitleFont;
|
|
|
|
DWORD count = sizeof(ncm);
|
|
|
|
DWORD type;
|
|
|
|
|
|
|
|
if (RegQueryValueExW (hKey, keyNonClientMetrics, 0,
|
|
|
|
&type, (LPBYTE)&ncm, &count) == ERROR_SUCCESS)
|
|
|
|
{
|
|
|
|
SystemParametersInfoW (SPI_SETNONCLIENTMETRICS,
|
2009-01-13 10:55:29 +01:00
|
|
|
count, &ncm, SPIF_UPDATEINIFILE);
|
2006-08-14 19:22:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
count = sizeof(iconTitleFont);
|
|
|
|
|
|
|
|
if (RegQueryValueExW (hKey, keyIconTitleFont, 0,
|
|
|
|
&type, (LPBYTE)&iconTitleFont, &count) == ERROR_SUCCESS)
|
|
|
|
{
|
|
|
|
SystemParametersInfoW (SPI_SETICONTITLELOGFONT,
|
2009-01-13 10:55:29 +01:00
|
|
|
count, &iconTitleFont, SPIF_UPDATEINIFILE);
|
2006-08-14 19:22:18 +02:00
|
|
|
}
|
|
|
|
}
|
2005-08-12 17:51:13 +02:00
|
|
|
|
|
|
|
RegCloseKey (hKey);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Make system settings persistent, so they're in effect even w/o uxtheme
|
2006-08-14 19:22:18 +02:00
|
|
|
* loaded.
|
|
|
|
* For efficiency reasons, only the last SystemParametersInfoW sets
|
|
|
|
* SPIF_SENDWININICHANGE */
|
2005-08-12 17:51:13 +02:00
|
|
|
static void UXTHEME_SaveSystemMetrics(void)
|
|
|
|
{
|
|
|
|
const struct BackupSysParam* bsp = backupSysParams;
|
2006-08-14 19:22:18 +02:00
|
|
|
NONCLIENTMETRICSW ncm;
|
|
|
|
LOGFONTW iconTitleFont;
|
2005-08-12 17:51:13 +02:00
|
|
|
|
|
|
|
save_sys_colors (HKEY_CURRENT_USER);
|
|
|
|
|
|
|
|
while (bsp->spiGet >= 0)
|
|
|
|
{
|
|
|
|
DWORD value;
|
|
|
|
|
|
|
|
SystemParametersInfoW (bsp->spiGet, 0, &value, 0);
|
2009-12-09 12:04:08 +01:00
|
|
|
SystemParametersInfoW (bsp->spiSet, 0, UlongToPtr(value), SPIF_UPDATEINIFILE);
|
2005-08-12 17:51:13 +02:00
|
|
|
bsp++;
|
|
|
|
}
|
2006-08-14 19:22:18 +02:00
|
|
|
|
|
|
|
memset (&ncm, 0, sizeof (ncm));
|
|
|
|
ncm.cbSize = sizeof (ncm);
|
2009-01-13 10:55:29 +01:00
|
|
|
SystemParametersInfoW (SPI_GETNONCLIENTMETRICS, sizeof (ncm), &ncm, 0);
|
|
|
|
SystemParametersInfoW (SPI_SETNONCLIENTMETRICS, sizeof (ncm), &ncm,
|
|
|
|
SPIF_UPDATEINIFILE);
|
2006-08-14 19:22:18 +02:00
|
|
|
|
|
|
|
memset (&iconTitleFont, 0, sizeof (iconTitleFont));
|
2009-01-13 10:55:29 +01:00
|
|
|
SystemParametersInfoW (SPI_GETICONTITLELOGFONT, sizeof (iconTitleFont),
|
|
|
|
&iconTitleFont, 0);
|
|
|
|
SystemParametersInfoW (SPI_SETICONTITLELOGFONT, sizeof (iconTitleFont),
|
|
|
|
&iconTitleFont, SPIF_UPDATEINIFILE | SPIF_SENDCHANGE);
|
2005-08-12 17:51:13 +02:00
|
|
|
}
|
|
|
|
|
2004-01-16 22:25:25 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* UXTHEME_SetActiveTheme
|
|
|
|
*
|
|
|
|
* Change the current active theme
|
|
|
|
*/
|
2007-02-01 22:52:58 +01:00
|
|
|
static HRESULT UXTHEME_SetActiveTheme(PTHEME_FILE tf)
|
2004-01-16 22:25:25 +01:00
|
|
|
{
|
|
|
|
HKEY hKey;
|
|
|
|
WCHAR tmp[2];
|
|
|
|
HRESULT hr;
|
|
|
|
|
2006-08-14 03:19:48 +02:00
|
|
|
if(tf && !bThemeActive) UXTHEME_BackupSystemMetrics();
|
2005-08-12 17:51:13 +02:00
|
|
|
hr = MSSTYLES_SetActiveTheme(tf, TRUE);
|
2004-01-16 22:25:25 +01:00
|
|
|
if(FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
if(tf) {
|
|
|
|
bThemeActive = TRUE;
|
2018-09-18 20:38:19 +02:00
|
|
|
lstrcpynW(szCurrentTheme, tf->szThemeFile, ARRAY_SIZE(szCurrentTheme));
|
|
|
|
lstrcpynW(szCurrentColor, tf->pszSelectedColor, ARRAY_SIZE(szCurrentColor));
|
|
|
|
lstrcpynW(szCurrentSize, tf->pszSelectedSize, ARRAY_SIZE(szCurrentSize));
|
2004-01-16 22:25:25 +01:00
|
|
|
}
|
|
|
|
else {
|
2005-08-12 17:51:13 +02:00
|
|
|
UXTHEME_RestoreSystemMetrics();
|
2004-01-16 22:25:25 +01:00
|
|
|
bThemeActive = FALSE;
|
|
|
|
szCurrentTheme[0] = '\0';
|
|
|
|
szCurrentColor[0] = '\0';
|
|
|
|
szCurrentSize[0] = '\0';
|
|
|
|
}
|
|
|
|
|
|
|
|
TRACE("Writing theme config to registry\n");
|
|
|
|
if(!RegCreateKeyW(HKEY_CURRENT_USER, szThemeManager, &hKey)) {
|
|
|
|
tmp[0] = bThemeActive?'1':'0';
|
|
|
|
tmp[1] = '\0';
|
|
|
|
RegSetValueExW(hKey, szThemeActive, 0, REG_SZ, (const BYTE*)tmp, sizeof(WCHAR)*2);
|
2004-02-17 22:03:33 +01:00
|
|
|
if(bThemeActive) {
|
2005-07-05 12:57:17 +02:00
|
|
|
RegSetValueExW(hKey, szColorName, 0, REG_SZ, (const BYTE*)szCurrentColor,
|
|
|
|
(lstrlenW(szCurrentColor)+1)*sizeof(WCHAR));
|
|
|
|
RegSetValueExW(hKey, szSizeName, 0, REG_SZ, (const BYTE*)szCurrentSize,
|
|
|
|
(lstrlenW(szCurrentSize)+1)*sizeof(WCHAR));
|
|
|
|
RegSetValueExW(hKey, szDllName, 0, REG_SZ, (const BYTE*)szCurrentTheme,
|
|
|
|
(lstrlenW(szCurrentTheme)+1)*sizeof(WCHAR));
|
2004-02-17 22:03:33 +01:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
RegDeleteValueW(hKey, szColorName);
|
|
|
|
RegDeleteValueW(hKey, szSizeName);
|
|
|
|
RegDeleteValueW(hKey, szDllName);
|
|
|
|
|
|
|
|
}
|
2004-01-16 22:25:25 +01:00
|
|
|
RegCloseKey(hKey);
|
|
|
|
}
|
2003-12-08 23:45:26 +01:00
|
|
|
else
|
2004-01-16 22:25:25 +01:00
|
|
|
TRACE("Failed to open theme registry key\n");
|
2005-08-12 17:51:13 +02:00
|
|
|
|
|
|
|
UXTHEME_SaveSystemMetrics ();
|
|
|
|
|
2004-01-16 22:25:25 +01:00
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* UXTHEME_InitSystem
|
|
|
|
*/
|
|
|
|
void UXTHEME_InitSystem(HINSTANCE hInst)
|
|
|
|
{
|
2004-04-19 22:12:14 +02:00
|
|
|
static const WCHAR szWindowTheme[] = {
|
2004-01-16 22:25:25 +01:00
|
|
|
'u','x','_','t','h','e','m','e','\0'
|
|
|
|
};
|
2004-04-19 22:12:14 +02:00
|
|
|
static const WCHAR szSubAppName[] = {
|
2004-01-16 22:25:25 +01:00
|
|
|
'u','x','_','s','u','b','a','p','p','\0'
|
|
|
|
};
|
2004-04-19 22:12:14 +02:00
|
|
|
static const WCHAR szSubIdList[] = {
|
2004-01-16 22:25:25 +01:00
|
|
|
'u','x','_','s','u','b','i','d','l','s','t','\0'
|
|
|
|
};
|
2005-07-15 18:32:37 +02:00
|
|
|
static const WCHAR szDialogThemeEnabled[] = {
|
|
|
|
'u','x','_','d','i','a','l','o','g','t','h','e','m','e','\0'
|
|
|
|
};
|
2004-01-16 22:25:25 +01:00
|
|
|
|
2005-07-15 18:32:37 +02:00
|
|
|
atWindowTheme = GlobalAddAtomW(szWindowTheme);
|
|
|
|
atSubAppName = GlobalAddAtomW(szSubAppName);
|
|
|
|
atSubIdList = GlobalAddAtomW(szSubIdList);
|
|
|
|
atDialogThemeEnabled = GlobalAddAtomW(szDialogThemeEnabled);
|
2004-01-16 22:25:25 +01:00
|
|
|
|
|
|
|
UXTHEME_LoadTheme();
|
2003-12-04 21:55:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* IsAppThemed (UXTHEME.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI IsAppThemed(void)
|
|
|
|
{
|
2003-12-08 23:45:26 +01:00
|
|
|
return IsThemeActive();
|
2003-12-04 21:55:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* IsThemeActive (UXTHEME.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI IsThemeActive(void)
|
|
|
|
{
|
2003-12-08 23:45:26 +01:00
|
|
|
TRACE("\n");
|
2008-10-27 10:04:48 +01:00
|
|
|
SetLastError(ERROR_SUCCESS);
|
2003-12-08 23:45:26 +01:00
|
|
|
return bThemeActive;
|
2003-12-04 21:55:30 +01:00
|
|
|
}
|
|
|
|
|
2017-10-18 15:40:10 +02:00
|
|
|
/************************************************************
|
|
|
|
* IsCompositionActive (UXTHEME.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI IsCompositionActive(void)
|
|
|
|
{
|
|
|
|
FIXME(": stub\n");
|
|
|
|
|
|
|
|
SetLastError(ERROR_CALL_NOT_IMPLEMENTED);
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2003-12-04 21:55:30 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* EnableTheming (UXTHEME.@)
|
|
|
|
*
|
|
|
|
* NOTES
|
2004-01-06 23:08:33 +01:00
|
|
|
* This is a global and persistent change
|
2003-12-04 21:55:30 +01:00
|
|
|
*/
|
|
|
|
HRESULT WINAPI EnableTheming(BOOL fEnable)
|
|
|
|
{
|
2003-12-08 23:45:26 +01:00
|
|
|
HKEY hKey;
|
|
|
|
WCHAR szEnabled[] = {'0','\0'};
|
|
|
|
|
|
|
|
TRACE("(%d)\n", fEnable);
|
|
|
|
|
|
|
|
if(fEnable != bThemeActive) {
|
2005-08-12 17:51:13 +02:00
|
|
|
if(fEnable)
|
|
|
|
UXTHEME_BackupSystemMetrics();
|
|
|
|
else
|
|
|
|
UXTHEME_RestoreSystemMetrics();
|
|
|
|
UXTHEME_SaveSystemMetrics ();
|
2003-12-08 23:45:26 +01:00
|
|
|
bThemeActive = fEnable;
|
|
|
|
if(bThemeActive) szEnabled[0] = '1';
|
|
|
|
if(!RegOpenKeyW(HKEY_CURRENT_USER, szThemeManager, &hKey)) {
|
|
|
|
RegSetValueExW(hKey, szThemeActive, 0, REG_SZ, (LPBYTE)szEnabled, sizeof(WCHAR));
|
|
|
|
RegCloseKey(hKey);
|
|
|
|
}
|
2005-07-06 12:32:30 +02:00
|
|
|
UXTHEME_broadcast_msg (NULL, WM_THEMECHANGED);
|
2003-12-08 23:45:26 +01:00
|
|
|
}
|
|
|
|
return S_OK;
|
2004-01-16 22:25:25 +01:00
|
|
|
}
|
2003-12-04 21:55:30 +01:00
|
|
|
|
2004-01-19 22:52:09 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* UXTHEME_SetWindowProperty
|
|
|
|
*
|
|
|
|
* I'm using atoms as there may be large numbers of duplicated strings
|
|
|
|
* and they do the work of keeping memory down as a cause of that quite nicely
|
|
|
|
*/
|
2007-02-01 22:52:58 +01:00
|
|
|
static HRESULT UXTHEME_SetWindowProperty(HWND hwnd, ATOM aProp, LPCWSTR pszValue)
|
2004-01-19 22:52:09 +01:00
|
|
|
{
|
2006-11-08 01:19:02 +01:00
|
|
|
ATOM oldValue = (ATOM)(size_t)RemovePropW(hwnd, (LPCWSTR)MAKEINTATOM(aProp));
|
2004-01-19 22:52:09 +01:00
|
|
|
if(oldValue)
|
|
|
|
DeleteAtom(oldValue);
|
|
|
|
if(pszValue) {
|
|
|
|
ATOM atValue = AddAtomW(pszValue);
|
|
|
|
if(!atValue
|
2006-11-08 01:19:02 +01:00
|
|
|
|| !SetPropW(hwnd, (LPCWSTR)MAKEINTATOM(aProp), (LPWSTR)MAKEINTATOM(atValue))) {
|
2004-01-19 22:52:09 +01:00
|
|
|
HRESULT hr = HRESULT_FROM_WIN32(GetLastError());
|
|
|
|
if(atValue) DeleteAtom(atValue);
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
2007-02-01 22:52:58 +01:00
|
|
|
static LPWSTR UXTHEME_GetWindowProperty(HWND hwnd, ATOM aProp, LPWSTR pszBuffer, int dwLen)
|
2004-01-19 22:52:09 +01:00
|
|
|
{
|
2006-11-08 01:19:02 +01:00
|
|
|
ATOM atValue = (ATOM)(size_t)GetPropW(hwnd, (LPCWSTR)MAKEINTATOM(aProp));
|
2004-01-19 22:52:09 +01:00
|
|
|
if(atValue) {
|
|
|
|
if(GetAtomNameW(atValue, pszBuffer, dwLen))
|
|
|
|
return pszBuffer;
|
|
|
|
TRACE("property defined, but unable to get value\n");
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2003-12-04 21:55:30 +01:00
|
|
|
/***********************************************************************
|
2011-03-23 19:29:59 +01:00
|
|
|
* OpenThemeDataEx (UXTHEME.61)
|
2003-12-04 21:55:30 +01:00
|
|
|
*/
|
2011-03-23 19:29:59 +01:00
|
|
|
HTHEME WINAPI OpenThemeDataEx(HWND hwnd, LPCWSTR pszClassList, DWORD flags)
|
2003-12-04 21:55:30 +01:00
|
|
|
{
|
2004-01-19 22:52:09 +01:00
|
|
|
WCHAR szAppBuff[256];
|
|
|
|
WCHAR szClassBuff[256];
|
|
|
|
LPCWSTR pszAppName;
|
|
|
|
LPCWSTR pszUseClassList;
|
2005-07-24 19:11:05 +02:00
|
|
|
HTHEME hTheme = NULL;
|
2011-03-23 19:29:59 +01:00
|
|
|
TRACE("(%p,%s, %x)\n", hwnd, debugstr_w(pszClassList), flags);
|
|
|
|
|
2011-08-30 15:15:25 +02:00
|
|
|
if(!pszClassList)
|
|
|
|
{
|
|
|
|
SetLastError(E_POINTER);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2011-03-23 19:29:59 +01:00
|
|
|
if(flags)
|
|
|
|
FIXME("unhandled flags: %x\n", flags);
|
2005-07-24 19:11:05 +02:00
|
|
|
|
|
|
|
if(bThemeActive)
|
|
|
|
{
|
2018-09-18 20:38:19 +02:00
|
|
|
pszAppName = UXTHEME_GetWindowProperty(hwnd, atSubAppName, szAppBuff, ARRAY_SIZE(szAppBuff));
|
2005-07-24 19:11:05 +02:00
|
|
|
/* If SetWindowTheme was used on the window, that overrides the class list passed to this function */
|
2018-09-18 20:38:19 +02:00
|
|
|
pszUseClassList = UXTHEME_GetWindowProperty(hwnd, atSubIdList, szClassBuff, ARRAY_SIZE(szClassBuff));
|
2005-07-24 19:11:05 +02:00
|
|
|
if(!pszUseClassList)
|
|
|
|
pszUseClassList = pszClassList;
|
|
|
|
|
|
|
|
if (pszUseClassList)
|
|
|
|
hTheme = MSSTYLES_OpenThemeClass(pszAppName, pszUseClassList);
|
|
|
|
}
|
2004-01-16 22:25:25 +01:00
|
|
|
if(IsWindow(hwnd))
|
2006-11-08 01:19:02 +01:00
|
|
|
SetPropW(hwnd, (LPCWSTR)MAKEINTATOM(atWindowTheme), hTheme);
|
2005-07-24 19:11:05 +02:00
|
|
|
TRACE(" = %p\n", hTheme);
|
2004-01-16 22:25:25 +01:00
|
|
|
return hTheme;
|
2003-12-04 21:55:30 +01:00
|
|
|
}
|
|
|
|
|
2011-03-23 19:29:59 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* OpenThemeData (UXTHEME.@)
|
|
|
|
*/
|
|
|
|
HTHEME WINAPI OpenThemeData(HWND hwnd, LPCWSTR classlist)
|
|
|
|
{
|
|
|
|
return OpenThemeDataEx(hwnd, classlist, 0);
|
|
|
|
}
|
|
|
|
|
2003-12-04 21:55:30 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* GetWindowTheme (UXTHEME.@)
|
|
|
|
*
|
2005-11-10 12:05:45 +01:00
|
|
|
* Retrieve the last theme opened for a window.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* hwnd [I] window to retrieve the theme for
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* The most recent theme.
|
2003-12-04 21:55:30 +01:00
|
|
|
*/
|
|
|
|
HTHEME WINAPI GetWindowTheme(HWND hwnd)
|
|
|
|
{
|
|
|
|
TRACE("(%p)\n", hwnd);
|
2006-11-08 01:19:02 +01:00
|
|
|
return GetPropW(hwnd, (LPCWSTR)MAKEINTATOM(atWindowTheme));
|
2003-12-04 21:55:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* SetWindowTheme (UXTHEME.@)
|
|
|
|
*
|
2004-01-06 23:08:33 +01:00
|
|
|
* Persistent through the life of the window, even after themes change
|
2003-12-04 21:55:30 +01:00
|
|
|
*/
|
|
|
|
HRESULT WINAPI SetWindowTheme(HWND hwnd, LPCWSTR pszSubAppName,
|
|
|
|
LPCWSTR pszSubIdList)
|
|
|
|
{
|
|
|
|
HRESULT hr;
|
|
|
|
TRACE("(%p,%s,%s)\n", hwnd, debugstr_w(pszSubAppName),
|
|
|
|
debugstr_w(pszSubIdList));
|
|
|
|
hr = UXTHEME_SetWindowProperty(hwnd, atSubAppName, pszSubAppName);
|
|
|
|
if(SUCCEEDED(hr))
|
2003-12-08 23:45:26 +01:00
|
|
|
hr = UXTHEME_SetWindowProperty(hwnd, atSubIdList, pszSubIdList);
|
|
|
|
if(SUCCEEDED(hr))
|
2005-07-06 12:32:30 +02:00
|
|
|
UXTHEME_broadcast_msg (hwnd, WM_THEMECHANGED);
|
2003-12-04 21:55:30 +01:00
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2018-01-04 21:00:27 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* SetWindowThemeAttribute (UXTHEME.@)
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI SetWindowThemeAttribute(HWND hwnd, enum WINDOWTHEMEATTRIBUTETYPE type,
|
|
|
|
PVOID attribute, DWORD size)
|
|
|
|
{
|
|
|
|
FIXME("(%p,%d,%p,%d): stub\n", hwnd, type, attribute, size);
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
2003-12-04 21:55:30 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* GetCurrentThemeName (UXTHEME.@)
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI GetCurrentThemeName(LPWSTR pszThemeFileName, int dwMaxNameChars,
|
|
|
|
LPWSTR pszColorBuff, int cchMaxColorChars,
|
|
|
|
LPWSTR pszSizeBuff, int cchMaxSizeChars)
|
|
|
|
{
|
2003-12-08 23:45:26 +01:00
|
|
|
if(!bThemeActive)
|
|
|
|
return E_PROP_ID_UNSUPPORTED;
|
|
|
|
if(pszThemeFileName) lstrcpynW(pszThemeFileName, szCurrentTheme, dwMaxNameChars);
|
|
|
|
if(pszColorBuff) lstrcpynW(pszColorBuff, szCurrentColor, cchMaxColorChars);
|
|
|
|
if(pszSizeBuff) lstrcpynW(pszSizeBuff, szCurrentSize, cchMaxSizeChars);
|
|
|
|
return S_OK;
|
2003-12-04 21:55:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* GetThemeAppProperties (UXTHEME.@)
|
|
|
|
*/
|
|
|
|
DWORD WINAPI GetThemeAppProperties(void)
|
|
|
|
{
|
|
|
|
return dwThemeAppProperties;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* SetThemeAppProperties (UXTHEME.@)
|
|
|
|
*/
|
|
|
|
void WINAPI SetThemeAppProperties(DWORD dwFlags)
|
|
|
|
{
|
2006-10-08 19:34:18 +02:00
|
|
|
TRACE("(0x%08x)\n", dwFlags);
|
2003-12-04 21:55:30 +01:00
|
|
|
dwThemeAppProperties = dwFlags;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* CloseThemeData (UXTHEME.@)
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI CloseThemeData(HTHEME hTheme)
|
|
|
|
{
|
2004-01-16 22:25:25 +01:00
|
|
|
TRACE("(%p)\n", hTheme);
|
2016-02-12 10:51:42 +01:00
|
|
|
if(!hTheme || hTheme == INVALID_HANDLE_VALUE)
|
2003-12-04 21:55:30 +01:00
|
|
|
return E_HANDLE;
|
2004-01-16 22:25:25 +01:00
|
|
|
return MSSTYLES_CloseThemeClass(hTheme);
|
2003-12-04 21:55:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* HitTestThemeBackground (UXTHEME.@)
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI HitTestThemeBackground(HTHEME hTheme, HDC hdc, int iPartId,
|
|
|
|
int iStateId, DWORD dwOptions,
|
|
|
|
const RECT *pRect, HRGN hrgn,
|
|
|
|
POINT ptTest, WORD *pwHitTestCode)
|
|
|
|
{
|
2006-10-08 19:34:18 +02:00
|
|
|
FIXME("%d %d 0x%08x: stub\n", iPartId, iStateId, dwOptions);
|
2003-12-04 21:55:30 +01:00
|
|
|
if(!hTheme)
|
|
|
|
return E_HANDLE;
|
2016-09-13 23:26:39 +02:00
|
|
|
return E_NOTIMPL;
|
2003-12-04 21:55:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* IsThemePartDefined (UXTHEME.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI IsThemePartDefined(HTHEME hTheme, int iPartId, int iStateId)
|
|
|
|
{
|
2004-01-19 22:52:09 +01:00
|
|
|
TRACE("(%p,%d,%d)\n", hTheme, iPartId, iStateId);
|
2004-11-09 21:02:39 +01:00
|
|
|
if(!hTheme) {
|
|
|
|
SetLastError(E_HANDLE);
|
|
|
|
return FALSE;
|
|
|
|
}
|
2004-01-23 05:34:02 +01:00
|
|
|
if(MSSTYLES_FindPartState(hTheme, iPartId, iStateId, NULL))
|
2004-01-19 22:52:09 +01:00
|
|
|
return TRUE;
|
2003-12-04 21:55:30 +01:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2004-01-16 22:25:25 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* GetThemeDocumentationProperty (UXTHEME.@)
|
|
|
|
*
|
|
|
|
* Try and retrieve the documentation property from string resources
|
|
|
|
* if that fails, get it from the [documentation] section of themes.ini
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI GetThemeDocumentationProperty(LPCWSTR pszThemeName,
|
|
|
|
LPCWSTR pszPropertyName,
|
|
|
|
LPWSTR pszValueBuff,
|
|
|
|
int cchMaxValChars)
|
|
|
|
{
|
|
|
|
const WORD wDocToRes[] = {
|
|
|
|
TMT_DISPLAYNAME,5000,
|
|
|
|
TMT_TOOLTIP,5001,
|
|
|
|
TMT_COMPANY,5002,
|
|
|
|
TMT_AUTHOR,5003,
|
|
|
|
TMT_COPYRIGHT,5004,
|
|
|
|
TMT_URL,5005,
|
|
|
|
TMT_VERSION,5006,
|
|
|
|
TMT_DESCRIPTION,5007
|
|
|
|
};
|
|
|
|
|
|
|
|
PTHEME_FILE pt;
|
|
|
|
HRESULT hr;
|
2004-09-22 04:46:38 +02:00
|
|
|
unsigned int i;
|
2004-01-23 05:34:02 +01:00
|
|
|
int iDocId;
|
2004-01-16 22:25:25 +01:00
|
|
|
TRACE("(%s,%s,%p,%d)\n", debugstr_w(pszThemeName), debugstr_w(pszPropertyName),
|
|
|
|
pszValueBuff, cchMaxValChars);
|
|
|
|
|
|
|
|
hr = MSSTYLES_OpenThemeFile(pszThemeName, NULL, NULL, &pt);
|
|
|
|
if(FAILED(hr)) return hr;
|
|
|
|
|
|
|
|
/* Try to load from string resources */
|
|
|
|
hr = E_PROP_ID_UNSUPPORTED;
|
2004-01-23 05:34:02 +01:00
|
|
|
if(MSSTYLES_LookupProperty(pszPropertyName, NULL, &iDocId)) {
|
2018-09-18 20:38:19 +02:00
|
|
|
for(i=0; i<ARRAY_SIZE(wDocToRes); i+=2) {
|
2004-01-23 05:34:02 +01:00
|
|
|
if(wDocToRes[i] == iDocId) {
|
2004-01-16 22:25:25 +01:00
|
|
|
if(LoadStringW(pt->hTheme, wDocToRes[i+1], pszValueBuff, cchMaxValChars)) {
|
|
|
|
hr = S_OK;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/* If loading from string resource failed, try getting it from the theme.ini */
|
|
|
|
if(FAILED(hr)) {
|
|
|
|
PUXINI_FILE uf = MSSTYLES_GetThemeIni(pt);
|
|
|
|
if(UXINI_FindSection(uf, szIniDocumentation)) {
|
|
|
|
LPCWSTR lpValue;
|
|
|
|
DWORD dwLen;
|
|
|
|
if(UXINI_FindValue(uf, pszPropertyName, &lpValue, &dwLen)) {
|
|
|
|
lstrcpynW(pszValueBuff, lpValue, min(dwLen+1,cchMaxValChars));
|
|
|
|
hr = S_OK;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
UXINI_CloseINI(uf);
|
|
|
|
}
|
|
|
|
|
|
|
|
MSSTYLES_CloseThemeFile(pt);
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2003-12-04 21:55:30 +01:00
|
|
|
/**********************************************************************
|
|
|
|
* Undocumented functions
|
|
|
|
*/
|
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
* QueryThemeServices (UXTHEME.1)
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* some kind of status flag
|
|
|
|
*/
|
2007-08-29 21:42:28 +02:00
|
|
|
DWORD WINAPI QueryThemeServices(void)
|
2003-12-04 21:55:30 +01:00
|
|
|
{
|
|
|
|
FIXME("stub\n");
|
|
|
|
return 3; /* This is what is returned under XP in most cases */
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
* OpenThemeFile (UXTHEME.2)
|
|
|
|
*
|
|
|
|
* Opens a theme file, which can be used to change the current theme, etc
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* pszThemeFileName Path to a msstyles theme file
|
|
|
|
* pszColorName Color defined in the theme, eg. NormalColor
|
|
|
|
* pszSizeName Size defined in the theme, eg. NormalSize
|
|
|
|
* hThemeFile Handle to theme file
|
2005-11-10 12:05:45 +01:00
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: S_OK
|
|
|
|
* Failure: HRESULT error-code
|
2003-12-04 21:55:30 +01:00
|
|
|
*/
|
|
|
|
HRESULT WINAPI OpenThemeFile(LPCWSTR pszThemeFileName, LPCWSTR pszColorName,
|
|
|
|
LPCWSTR pszSizeName, HTHEMEFILE *hThemeFile,
|
|
|
|
DWORD unknown)
|
|
|
|
{
|
2006-10-08 19:34:18 +02:00
|
|
|
TRACE("(%s,%s,%s,%p,%d)\n", debugstr_w(pszThemeFileName),
|
2003-12-08 23:45:26 +01:00
|
|
|
debugstr_w(pszColorName), debugstr_w(pszSizeName),
|
|
|
|
hThemeFile, unknown);
|
|
|
|
return MSSTYLES_OpenThemeFile(pszThemeFileName, pszColorName, pszSizeName, (PTHEME_FILE*)hThemeFile);
|
2003-12-04 21:55:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
* CloseThemeFile (UXTHEME.3)
|
|
|
|
*
|
|
|
|
* Releases theme file handle returned by OpenThemeFile
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* hThemeFile Handle to theme file
|
2005-11-10 12:05:45 +01:00
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: S_OK
|
|
|
|
* Failure: HRESULT error-code
|
2003-12-04 21:55:30 +01:00
|
|
|
*/
|
|
|
|
HRESULT WINAPI CloseThemeFile(HTHEMEFILE hThemeFile)
|
|
|
|
{
|
2003-12-08 23:45:26 +01:00
|
|
|
TRACE("(%p)\n", hThemeFile);
|
|
|
|
MSSTYLES_CloseThemeFile(hThemeFile);
|
2003-12-04 21:55:30 +01:00
|
|
|
return S_OK;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
* ApplyTheme (UXTHEME.4)
|
|
|
|
*
|
|
|
|
* Set a theme file to be the currently active theme
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* hThemeFile Handle to theme file
|
|
|
|
* unknown See notes
|
|
|
|
* hWnd Window requesting the theme change
|
|
|
|
*
|
2005-11-10 12:05:45 +01:00
|
|
|
* RETURNS
|
|
|
|
* Success: S_OK
|
|
|
|
* Failure: HRESULT error-code
|
|
|
|
*
|
2003-12-04 21:55:30 +01:00
|
|
|
* NOTES
|
|
|
|
* I'm not sure what the second parameter is (the datatype is likely wrong), other then this:
|
|
|
|
* Under XP if I pass
|
|
|
|
* char b[] = "";
|
|
|
|
* the theme is applied with the screen redrawing really badly (flickers)
|
|
|
|
* char b[] = "\0"; where \0 can be one or more of any character, makes no difference
|
|
|
|
* the theme is applied smoothly (screen does not flicker)
|
|
|
|
* char *b = "\0" or NULL; where \0 can be zero or more of any character, makes no difference
|
2008-11-25 17:42:38 +01:00
|
|
|
* the function fails returning invalid parameter... very strange
|
2003-12-04 21:55:30 +01:00
|
|
|
*/
|
|
|
|
HRESULT WINAPI ApplyTheme(HTHEMEFILE hThemeFile, char *unknown, HWND hWnd)
|
|
|
|
{
|
2004-01-16 22:25:25 +01:00
|
|
|
HRESULT hr;
|
|
|
|
TRACE("(%p,%s,%p)\n", hThemeFile, unknown, hWnd);
|
|
|
|
hr = UXTHEME_SetActiveTheme(hThemeFile);
|
2005-07-06 12:32:30 +02:00
|
|
|
UXTHEME_broadcast_msg (NULL, WM_THEMECHANGED);
|
2004-01-16 22:25:25 +01:00
|
|
|
return hr;
|
2003-12-04 21:55:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
* GetThemeDefaults (UXTHEME.7)
|
|
|
|
*
|
|
|
|
* Get the default color & size for a theme
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* pszThemeFileName Path to a msstyles theme file
|
2004-01-06 23:08:33 +01:00
|
|
|
* pszColorName Buffer to receive the default color name
|
2003-12-04 21:55:30 +01:00
|
|
|
* dwColorNameLen Length, in characters, of color name buffer
|
2004-01-06 23:08:33 +01:00
|
|
|
* pszSizeName Buffer to receive the default size name
|
2003-12-04 21:55:30 +01:00
|
|
|
* dwSizeNameLen Length, in characters, of size name buffer
|
2005-11-10 12:05:45 +01:00
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: S_OK
|
|
|
|
* Failure: HRESULT error-code
|
2003-12-04 21:55:30 +01:00
|
|
|
*/
|
|
|
|
HRESULT WINAPI GetThemeDefaults(LPCWSTR pszThemeFileName, LPWSTR pszColorName,
|
|
|
|
DWORD dwColorNameLen, LPWSTR pszSizeName,
|
|
|
|
DWORD dwSizeNameLen)
|
|
|
|
{
|
2003-12-08 23:45:26 +01:00
|
|
|
PTHEME_FILE pt;
|
|
|
|
HRESULT hr;
|
2006-10-08 19:34:18 +02:00
|
|
|
TRACE("(%s,%p,%d,%p,%d)\n", debugstr_w(pszThemeFileName),
|
2003-12-08 23:45:26 +01:00
|
|
|
pszColorName, dwColorNameLen,
|
|
|
|
pszSizeName, dwSizeNameLen);
|
|
|
|
|
|
|
|
hr = MSSTYLES_OpenThemeFile(pszThemeFileName, NULL, NULL, &pt);
|
|
|
|
if(FAILED(hr)) return hr;
|
|
|
|
|
|
|
|
lstrcpynW(pszColorName, pt->pszSelectedColor, dwColorNameLen);
|
|
|
|
lstrcpynW(pszSizeName, pt->pszSelectedSize, dwSizeNameLen);
|
|
|
|
|
|
|
|
MSSTYLES_CloseThemeFile(pt);
|
|
|
|
return S_OK;
|
2003-12-04 21:55:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
* EnumThemes (UXTHEME.8)
|
|
|
|
*
|
|
|
|
* Enumerate available themes, calls specified EnumThemeProc for each
|
|
|
|
* theme found. Passes lpData through to callback function.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* pszThemePath Path containing themes
|
|
|
|
* callback Called for each theme found in path
|
|
|
|
* lpData Passed through to callback
|
2005-11-10 12:05:45 +01:00
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: S_OK
|
|
|
|
* Failure: HRESULT error-code
|
2003-12-04 21:55:30 +01:00
|
|
|
*/
|
|
|
|
HRESULT WINAPI EnumThemes(LPCWSTR pszThemePath, EnumThemeProc callback,
|
|
|
|
LPVOID lpData)
|
|
|
|
{
|
2004-04-05 22:12:38 +02:00
|
|
|
WCHAR szDir[MAX_PATH];
|
|
|
|
WCHAR szPath[MAX_PATH];
|
2004-04-20 03:12:17 +02:00
|
|
|
static const WCHAR szStar[] = {'*','.','*','\0'};
|
|
|
|
static const WCHAR szFormat[] = {'%','s','%','s','\\','%','s','.','m','s','s','t','y','l','e','s','\0'};
|
|
|
|
static const WCHAR szDisplayName[] = {'d','i','s','p','l','a','y','n','a','m','e','\0'};
|
|
|
|
static const WCHAR szTooltip[] = {'t','o','o','l','t','i','p','\0'};
|
2004-04-05 22:12:38 +02:00
|
|
|
WCHAR szName[60];
|
|
|
|
WCHAR szTip[60];
|
|
|
|
HANDLE hFind;
|
|
|
|
WIN32_FIND_DATAW wfd;
|
|
|
|
HRESULT hr;
|
2005-09-02 14:29:02 +02:00
|
|
|
size_t pathLen;
|
2004-04-05 22:12:38 +02:00
|
|
|
|
|
|
|
TRACE("(%s,%p,%p)\n", debugstr_w(pszThemePath), callback, lpData);
|
|
|
|
|
|
|
|
if(!pszThemePath || !callback)
|
|
|
|
return E_POINTER;
|
|
|
|
|
|
|
|
lstrcpyW(szDir, pszThemePath);
|
2005-09-02 14:29:02 +02:00
|
|
|
pathLen = lstrlenW (szDir);
|
|
|
|
if ((pathLen > 0) && (pathLen < MAX_PATH-1) && (szDir[pathLen - 1] != '\\'))
|
|
|
|
{
|
|
|
|
szDir[pathLen] = '\\';
|
|
|
|
szDir[pathLen+1] = 0;
|
|
|
|
}
|
2004-04-05 22:12:38 +02:00
|
|
|
|
|
|
|
lstrcpyW(szPath, szDir);
|
|
|
|
lstrcatW(szPath, szStar);
|
|
|
|
TRACE("searching %s\n", debugstr_w(szPath));
|
|
|
|
|
|
|
|
hFind = FindFirstFileW(szPath, &wfd);
|
|
|
|
if(hFind != INVALID_HANDLE_VALUE) {
|
|
|
|
do {
|
|
|
|
if(wfd.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY
|
|
|
|
&& !(wfd.cFileName[0] == '.' && ((wfd.cFileName[1] == '.' && wfd.cFileName[2] == 0) || wfd.cFileName[1] == 0))) {
|
|
|
|
wsprintfW(szPath, szFormat, szDir, wfd.cFileName, wfd.cFileName);
|
|
|
|
|
2018-09-18 20:38:19 +02:00
|
|
|
hr = GetThemeDocumentationProperty(szPath, szDisplayName, szName, ARRAY_SIZE(szName));
|
2004-04-05 22:12:38 +02:00
|
|
|
if(SUCCEEDED(hr))
|
2018-09-18 20:38:19 +02:00
|
|
|
hr = GetThemeDocumentationProperty(szPath, szTooltip, szTip, ARRAY_SIZE(szTip));
|
2004-04-05 22:12:38 +02:00
|
|
|
if(SUCCEEDED(hr)) {
|
|
|
|
TRACE("callback(%s,%s,%s,%p)\n", debugstr_w(szPath), debugstr_w(szName), debugstr_w(szTip), lpData);
|
|
|
|
if(!callback(NULL, szPath, szName, szTip, NULL, lpData)) {
|
|
|
|
TRACE("callback ended enum\n");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} while(FindNextFileW(hFind, &wfd));
|
|
|
|
FindClose(hFind);
|
|
|
|
}
|
|
|
|
return S_OK;
|
2003-12-04 21:55:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
* EnumThemeColors (UXTHEME.9)
|
|
|
|
*
|
|
|
|
* Enumerate theme colors available with a particular size
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* pszThemeFileName Path to a msstyles theme file
|
|
|
|
* pszSizeName Theme size to enumerate available colors
|
|
|
|
* If NULL the default theme size is used
|
|
|
|
* dwColorNum Color index to retrieve, increment from 0
|
2005-08-30 10:54:45 +02:00
|
|
|
* pszColorNames Output color names
|
2003-12-04 21:55:30 +01:00
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* S_OK on success
|
|
|
|
* E_PROP_ID_UNSUPPORTED when dwColorName does not refer to a color
|
|
|
|
* or when pszSizeName does not refer to a valid size
|
|
|
|
*
|
|
|
|
* NOTES
|
2005-08-30 10:54:45 +02:00
|
|
|
* XP fails with E_POINTER when pszColorNames points to a buffer smaller than
|
|
|
|
* sizeof(THEMENAMES).
|
2003-12-08 23:45:26 +01:00
|
|
|
*
|
|
|
|
* Not very efficient that I'm opening & validating the theme every call, but
|
|
|
|
* this is undocumented and almost never called..
|
|
|
|
* (and this is how windows works too)
|
2003-12-04 21:55:30 +01:00
|
|
|
*/
|
|
|
|
HRESULT WINAPI EnumThemeColors(LPWSTR pszThemeFileName, LPWSTR pszSizeName,
|
2005-08-30 10:54:45 +02:00
|
|
|
DWORD dwColorNum, PTHEMENAMES pszColorNames)
|
2003-12-04 21:55:30 +01:00
|
|
|
{
|
2003-12-08 23:45:26 +01:00
|
|
|
PTHEME_FILE pt;
|
|
|
|
HRESULT hr;
|
|
|
|
LPWSTR tmp;
|
2005-08-30 10:54:45 +02:00
|
|
|
UINT resourceId = dwColorNum + 1000;
|
2006-10-08 19:34:18 +02:00
|
|
|
TRACE("(%s,%s,%d)\n", debugstr_w(pszThemeFileName),
|
2003-12-04 21:55:30 +01:00
|
|
|
debugstr_w(pszSizeName), dwColorNum);
|
2003-12-08 23:45:26 +01:00
|
|
|
|
|
|
|
hr = MSSTYLES_OpenThemeFile(pszThemeFileName, NULL, pszSizeName, &pt);
|
|
|
|
if(FAILED(hr)) return hr;
|
|
|
|
|
|
|
|
tmp = pt->pszAvailColors;
|
|
|
|
while(dwColorNum && *tmp) {
|
|
|
|
dwColorNum--;
|
|
|
|
tmp += lstrlenW(tmp)+1;
|
|
|
|
}
|
|
|
|
if(!dwColorNum && *tmp) {
|
|
|
|
TRACE("%s\n", debugstr_w(tmp));
|
2005-08-30 10:54:45 +02:00
|
|
|
lstrcpyW(pszColorNames->szName, tmp);
|
2018-09-18 20:38:19 +02:00
|
|
|
LoadStringW(pt->hTheme, resourceId, pszColorNames->szDisplayName,
|
|
|
|
ARRAY_SIZE(pszColorNames->szDisplayName));
|
|
|
|
LoadStringW(pt->hTheme, resourceId+1000, pszColorNames->szTooltip,
|
|
|
|
ARRAY_SIZE(pszColorNames->szTooltip));
|
2003-12-08 23:45:26 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
hr = E_PROP_ID_UNSUPPORTED;
|
|
|
|
|
|
|
|
MSSTYLES_CloseThemeFile(pt);
|
|
|
|
return hr;
|
2003-12-04 21:55:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
* EnumThemeSizes (UXTHEME.10)
|
|
|
|
*
|
|
|
|
* Enumerate theme colors available with a particular size
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* pszThemeFileName Path to a msstyles theme file
|
|
|
|
* pszColorName Theme color to enumerate available sizes
|
|
|
|
* If NULL the default theme color is used
|
|
|
|
* dwSizeNum Size index to retrieve, increment from 0
|
2005-08-30 10:54:45 +02:00
|
|
|
* pszSizeNames Output size names
|
2003-12-04 21:55:30 +01:00
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* S_OK on success
|
|
|
|
* E_PROP_ID_UNSUPPORTED when dwSizeName does not refer to a size
|
|
|
|
* or when pszColorName does not refer to a valid color
|
|
|
|
*
|
|
|
|
* NOTES
|
2005-08-30 10:54:45 +02:00
|
|
|
* XP fails with E_POINTER when pszSizeNames points to a buffer smaller than
|
|
|
|
* sizeof(THEMENAMES).
|
2003-12-08 23:45:26 +01:00
|
|
|
*
|
|
|
|
* Not very efficient that I'm opening & validating the theme every call, but
|
|
|
|
* this is undocumented and almost never called..
|
|
|
|
* (and this is how windows works too)
|
2003-12-04 21:55:30 +01:00
|
|
|
*/
|
|
|
|
HRESULT WINAPI EnumThemeSizes(LPWSTR pszThemeFileName, LPWSTR pszColorName,
|
2005-08-30 10:54:45 +02:00
|
|
|
DWORD dwSizeNum, PTHEMENAMES pszSizeNames)
|
2003-12-04 21:55:30 +01:00
|
|
|
{
|
2003-12-08 23:45:26 +01:00
|
|
|
PTHEME_FILE pt;
|
|
|
|
HRESULT hr;
|
|
|
|
LPWSTR tmp;
|
2005-08-30 10:54:45 +02:00
|
|
|
UINT resourceId = dwSizeNum + 3000;
|
2006-10-08 19:34:18 +02:00
|
|
|
TRACE("(%s,%s,%d)\n", debugstr_w(pszThemeFileName),
|
2003-12-08 23:45:26 +01:00
|
|
|
debugstr_w(pszColorName), dwSizeNum);
|
|
|
|
|
|
|
|
hr = MSSTYLES_OpenThemeFile(pszThemeFileName, pszColorName, NULL, &pt);
|
|
|
|
if(FAILED(hr)) return hr;
|
|
|
|
|
|
|
|
tmp = pt->pszAvailSizes;
|
|
|
|
while(dwSizeNum && *tmp) {
|
|
|
|
dwSizeNum--;
|
|
|
|
tmp += lstrlenW(tmp)+1;
|
|
|
|
}
|
|
|
|
if(!dwSizeNum && *tmp) {
|
|
|
|
TRACE("%s\n", debugstr_w(tmp));
|
2005-08-30 10:54:45 +02:00
|
|
|
lstrcpyW(pszSizeNames->szName, tmp);
|
2018-09-18 20:38:19 +02:00
|
|
|
LoadStringW(pt->hTheme, resourceId, pszSizeNames->szDisplayName,
|
|
|
|
ARRAY_SIZE(pszSizeNames->szDisplayName));
|
|
|
|
LoadStringW(pt->hTheme, resourceId+1000, pszSizeNames->szTooltip,
|
|
|
|
ARRAY_SIZE(pszSizeNames->szTooltip));
|
2003-12-08 23:45:26 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
hr = E_PROP_ID_UNSUPPORTED;
|
|
|
|
|
|
|
|
MSSTYLES_CloseThemeFile(pt);
|
|
|
|
return hr;
|
2003-12-04 21:55:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
* ParseThemeIniFile (UXTHEME.11)
|
|
|
|
*
|
|
|
|
* Enumerate data in a theme INI file.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* pszIniFileName Path to a theme ini file
|
|
|
|
* pszUnknown Cannot be NULL, L"" is valid
|
|
|
|
* callback Called for each found entry
|
|
|
|
* lpData Passed through to callback
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* S_OK on success
|
|
|
|
* 0x800706488 (Unknown property) when enumeration is canceled from callback
|
|
|
|
*
|
|
|
|
* NOTES
|
2008-04-22 08:18:14 +02:00
|
|
|
* When pszUnknown is NULL the callback is never called, the value does not seem to serve
|
2003-12-04 21:55:30 +01:00
|
|
|
* any other purpose
|
|
|
|
*/
|
|
|
|
HRESULT WINAPI ParseThemeIniFile(LPCWSTR pszIniFileName, LPWSTR pszUnknown,
|
|
|
|
ParseThemeIniFileProc callback, LPVOID lpData)
|
|
|
|
{
|
|
|
|
FIXME("%s %s: stub\n", debugstr_w(pszIniFileName), debugstr_w(pszUnknown));
|
2016-09-13 23:26:39 +02:00
|
|
|
return E_NOTIMPL;
|
2003-12-04 21:55:30 +01:00
|
|
|
}
|
2004-04-07 20:59:23 +02:00
|
|
|
|
|
|
|
/**********************************************************************
|
|
|
|
* CheckThemeSignature (UXTHEME.29)
|
|
|
|
*
|
|
|
|
* Validates the signature of a theme file
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* pszIniFileName Path to a theme file
|
2005-11-10 12:05:45 +01:00
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* Success: S_OK
|
|
|
|
* Failure: HRESULT error-code
|
2004-04-07 20:59:23 +02:00
|
|
|
*/
|
|
|
|
HRESULT WINAPI CheckThemeSignature(LPCWSTR pszThemeFileName)
|
|
|
|
{
|
|
|
|
PTHEME_FILE pt;
|
|
|
|
HRESULT hr;
|
|
|
|
TRACE("(%s)\n", debugstr_w(pszThemeFileName));
|
|
|
|
hr = MSSTYLES_OpenThemeFile(pszThemeFileName, NULL, NULL, &pt);
|
|
|
|
if(FAILED(hr))
|
|
|
|
return hr;
|
|
|
|
MSSTYLES_CloseThemeFile(pt);
|
|
|
|
return S_OK;
|
|
|
|
}
|