ReactOS 0.4.16-dev-117-g38f21f9
theme.c File Reference
#include "desk.h"
#include <shlwapi.h>
#include <uxtheme.h>
#include <uxundoc.h>
#include <vssym32.h>
Include dependency graph for theme.c:

Go to the source code of this file.

Macros

#define SYS_CONFIG(__uiAction, __uiParam, __pvParam)    SystemParametersInfoW(__uiAction, __uiParam, __pvParam, SPIF_UPDATEINIFILE | SPIF_SENDCHANGE)
 

Typedefs

typedef HRESULT(WINAPIENUMTHEMESTYLE) (LPCWSTR, LPWSTR, DWORD, PTHEMENAMES)
 

Functions

VOID SchemeSetMetric (IN COLOR_SCHEME *scheme, int id, int value)
 
int SchemeGetMetric (IN COLOR_SCHEME *scheme, int id)
 
PLOGFONTW SchemeGetFont (IN COLOR_SCHEME *scheme, int id)
 
BOOL LoadCurrentScheme (OUT COLOR_SCHEME *scheme)
 
BOOL LoadSchemeFromReg (OUT COLOR_SCHEME *scheme, IN PTHEME_SELECTION pSelectedTheme)
 
VOID ApplyScheme (IN COLOR_SCHEME *scheme, IN PTHEME_SELECTION pSelectedTheme)
 
static THEMECreateTheme (LPCWSTR pszName, LPCWSTR pszDisplayName)
 
static PTHEME_STYLE CreateStyle (LPCWSTR pszName, LPCWSTR pszDisplayName)
 
static void CleanupStyles (IN PTHEME_STYLE pStylesList)
 
void CleanupThemes (IN PTHEME pThemeList)
 
static PTHEME_STYLE FindStyle (IN PTHEME_STYLE pStylesList, IN PCWSTR StyleName)
 
static PTHEME_STYLE LoadSchemeSizes (IN HKEY hkScheme)
 
static THEME_STYLELoadClassicColorSchemes (VOID)
 
static THEME_STYLEEnumThemeStyles (IN LPCWSTR pszThemeFileName, IN ENUMTHEMESTYLE pfnEnumTheme)
 
PTHEME LoadTheme (IN LPCWSTR pszThemeFileName, IN LPCWSTR pszThemeName)
 
BOOL CALLBACK EnumThemeProc (IN LPVOID lpReserved, IN LPCWSTR pszThemeFileName, IN LPCWSTR pszThemeName, IN LPCWSTR pszToolTip, IN LPVOID lpReserved2, IN OUT LPVOID lpData)
 
PTHEME LoadThemes (VOID)
 
BOOL FindOrAppendTheme (IN PTHEME pThemeList, IN LPCWSTR pwszThemeFileName, IN LPCWSTR pwszColorBuff, IN LPCWSTR pwszSizeBuff, OUT PTHEME_SELECTION pSelectedTheme)
 
BOOL GetActiveTheme (IN PTHEME pThemeList, OUT PTHEME_SELECTION pSelectedTheme)
 
BOOL GetActiveClassicTheme (IN PTHEME pThemeList, OUT PTHEME_SELECTION pSelectedTheme)
 
BOOL ActivateTheme (IN PTHEME_SELECTION pSelectedTheme)
 
BOOL LoadSchemeFromTheme (OUT PCOLOR_SCHEME scheme, IN PTHEME_SELECTION pSelectedTheme)
 
BOOL DrawThemePreview (IN HDC hdcMem, IN PCOLOR_SCHEME scheme, IN PTHEME_SELECTION pSelectedTheme, IN PRECT prcWindow)
 
BOOL ActivateThemeFile (LPCWSTR pwszFile)
 
INT_PTR CALLBACK ThemesPageProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
 

Variables

static const WCHAR g_CPColors [] = L"Control Panel\\Colors"
 
static const WCHAR g_CPANewSchemes [] = L"Control Panel\\Appearance\\New Schemes"
 
static const WCHAR g_CPMetrics [] = L"Control Panel\\Desktop\\WindowMetrics"
 
static const WCHAR g_SelectedStyle [] = L"SelectedStyle"
 
static const WCHARg_RegColorNames [NUM_COLORS]
 

Macro Definition Documentation

◆ SYS_CONFIG

#define SYS_CONFIG (   __uiAction,
  __uiParam,
  __pvParam 
)     SystemParametersInfoW(__uiAction, __uiParam, __pvParam, SPIF_UPDATEINIFILE | SPIF_SENDCHANGE)

Typedef Documentation

◆ ENUMTHEMESTYLE

typedef HRESULT(WINAPI * ENUMTHEMESTYLE) (LPCWSTR, LPWSTR, DWORD, PTHEMENAMES)

Definition at line 684 of file theme.c.

Function Documentation

◆ ActivateTheme()

BOOL ActivateTheme ( IN PTHEME_SELECTION  pSelectedTheme)

Definition at line 911 of file theme.c.

912{
913 HTHEMEFILE hThemeFile = 0;
914 HRESULT hret;
915
916 if (pSelectedTheme->ThemeActive)
917 {
918 hret = OpenThemeFile(pSelectedTheme->Theme->ThemeFileName,
919 pSelectedTheme->Color->StyleName,
920 pSelectedTheme->Size->StyleName,
921 &hThemeFile,
922 0);
923
924 if (!SUCCEEDED(hret)) return FALSE;
925 }
926
927 hret = ApplyTheme(hThemeFile, 0, 0);
928
929 if (pSelectedTheme->ThemeActive)
930 {
931 CloseThemeFile(hThemeFile);
932 }
933
934 return SUCCEEDED(hret);
935}
#define FALSE
Definition: types.h:117
HRESULT WINAPI ApplyTheme(HTHEMEFILE hThemeFile, char *unknown, HWND hWnd)
Definition: system.c:1158
HRESULT WINAPI OpenThemeFile(LPCWSTR pszThemeFileName, LPCWSTR pszColorName, LPCWSTR pszSizeName, HTHEMEFILE *hThemeFile, DWORD unknown)
Definition: system.c:1101
HRESULT WINAPI CloseThemeFile(HTHEMEFILE hThemeFile)
Definition: system.c:1127
#define SUCCEEDED(hr)
Definition: intsafe.h:50

Referenced by ActivateThemeFile().

◆ ActivateThemeFile()

BOOL ActivateThemeFile ( LPCWSTR  pwszFile)

Definition at line 1015 of file theme.c.

1016{
1017 PTHEME pThemes;
1020 BOOL ret = FALSE;
1021
1022 pThemes = LoadThemes();
1023 if (!pThemes)
1024 return FALSE;
1025
1027
1028 if (pwszFile)
1029 {
1030 ret = FindOrAppendTheme(pThemes, pwszFile, NULL, NULL, &selection);
1031 if (!ret)
1032 goto cleanup;
1033
1035 if (!ret)
1036 goto cleanup;
1037 }
1038 else
1039 {
1040 ret = GetActiveClassicTheme(pThemes, &selection);
1041 if (!ret)
1042 goto cleanup;
1043
1045 if (!ret)
1046 goto cleanup;
1047 }
1048
1050 if (!ret)
1051 goto cleanup;
1052
1054
1055 ret = TRUE;
1056
1057cleanup:
1058 CleanupThemes(pThemes);
1059
1060 return ret;
1061}
int selection
Definition: ctm.c:92
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
void CleanupThemes(IN PTHEME pThemeList)
Definition: theme.c:527
BOOL FindOrAppendTheme(IN PTHEME pThemeList, IN LPCWSTR pwszThemeFileName, IN LPCWSTR pwszColorBuff, IN LPCWSTR pwszSizeBuff, OUT PTHEME_SELECTION pSelectedTheme)
Definition: theme.c:791
BOOL LoadSchemeFromTheme(OUT PCOLOR_SCHEME scheme, IN PTHEME_SELECTION pSelectedTheme)
Definition: theme.c:938
BOOL GetActiveClassicTheme(IN PTHEME pThemeList, OUT PTHEME_SELECTION pSelectedTheme)
Definition: theme.c:869
BOOL ActivateTheme(IN PTHEME_SELECTION pSelectedTheme)
Definition: theme.c:911
VOID ApplyScheme(IN COLOR_SCHEME *scheme, IN PTHEME_SELECTION pSelectedTheme)
Definition: theme.c:330
PTHEME LoadThemes(VOID)
Definition: theme.c:749
BOOL LoadSchemeFromReg(OUT COLOR_SCHEME *scheme, IN PTHEME_SELECTION pSelectedTheme)
Definition: theme.c:243
BOOL LoadCurrentScheme(OUT COLOR_SCHEME *scheme)
Definition: theme.c:122
static void cleanup(void)
Definition: main.c:1335
unsigned int BOOL
Definition: ntddk_ex.h:94
DWORD scheme
int ret

Referenced by DisplayApplet().

◆ ApplyScheme()

VOID ApplyScheme ( IN COLOR_SCHEME scheme,
IN PTHEME_SELECTION  pSelectedTheme 
)

Definition at line 330 of file theme.c.

331{
332 INT i, Result;
333 HKEY hKey;
334 WCHAR clText[16], *StyleName;
335 INT ColorList[NUM_COLORS];
336
337 /* Apply system colors */
338 for (i = 0; i < NUM_COLORS; i++)
339 ColorList[i] = i;
340 SetSysColors(NUM_COLORS, ColorList, scheme->crColor);
341
342 /* Save colors to registry */
344 if (Result == ERROR_SUCCESS)
345 {
346 for (i = 0; i < NUM_COLORS; i++)
347 {
348 wsprintf(clText,
349 L"%d %d %d",
350 GetRValue(scheme->crColor[i]),
351 GetGValue(scheme->crColor[i]),
352 GetBValue(scheme->crColor[i]));
353
356 0,
357 REG_SZ,
358 (BYTE *)clText,
359 (lstrlen(clText) + 1) * sizeof(WCHAR));
360 }
362 }
363
364 /* Apply non client metrics */
365 SystemParametersInfoW(SPI_SETNONCLIENTMETRICS,
366 sizeof(NONCLIENTMETRICS),
367 &scheme->ncMetrics,
369
370 /* Apply icon metrics */
371 SystemParametersInfoW(SPI_SETICONMETRICS,
372 sizeof(ICONMETRICS),
373 &scheme->icMetrics,
375
376 /* Effects, save only when needed: */
377 /* FIXME: XP seems to use grayed checkboxes to reflect differences between menu and tooltips settings
378 * Just keep them in sync for now.
379 */
380
381#define SYS_CONFIG(__uiAction, __uiParam, __pvParam) \
382 SystemParametersInfoW(__uiAction, __uiParam, __pvParam, SPIF_UPDATEINIFILE | SPIF_SENDCHANGE)
383
384 scheme->Effects.bTooltipAnimation = scheme->Effects.bMenuAnimation;
385 scheme->Effects.bTooltipFade = scheme->Effects.bMenuFade;
386
387 /* Use the following transition effect for menus and tooltips */
388 SYS_CONFIG(SPI_SETMENUANIMATION, 0, IntToPtr(scheme->Effects.bMenuAnimation));
389 SYS_CONFIG(SPI_SETMENUFADE, 0, IntToPtr(scheme->Effects.bMenuFade));
390
391 /* Use the following method to smooth edges of screen fonts */
392 SYS_CONFIG(SPI_SETFONTSMOOTHING, scheme->Effects.bFontSmoothing, 0);
393 SYS_CONFIG(SPI_SETFONTSMOOTHINGTYPE, 0, IntToPtr(scheme->Effects.uiFontSmoothingType));
394
395 /*
396 * Refresh and redraw all the windows, otherwise the font smoothing changes
397 * only appear after any future partial region invalidation.
398 * Not everyone listens for this WM_SETTINGCHANGE, including the shell and most third party programs.
399 */
401
402 /* Use large icons */
403 //SYS_CONFIG(SPI_GETDRAGFULLWINDOWS, (PVOID) g->SchemeAdv.Effects.bMenuFade);
404
405 /* Show shadows under menus */
406 SYS_CONFIG(SPI_SETDROPSHADOW, 0, IntToPtr(scheme->Effects.bDropShadow));
407
408 /* Show window contents while dragging */
409 SYS_CONFIG(SPI_SETDRAGFULLWINDOWS, scheme->Effects.bDragFullWindows, 0);
410
411 /* Hide underlined letters for keyboard navigation until I press the Alt key */
412 SYS_CONFIG(SPI_SETKEYBOARDCUES, 0, IntToPtr(scheme->Effects.bKeyboardCues));
413
414 SYS_CONFIG(SPI_SETFLATMENU, 0, IntToPtr(scheme->bFlatMenus));
415
416 // SYS_CONFIG(SPI_SETACTIVEWINDOWTRACKING, 0, IntToPtr(scheme->Effects.bActiveWindowTracking));
417 // SYS_CONFIG(SPI_SETCOMBOBOXANIMATION, 0, IntToPtr(scheme->Effects.bComboBoxAnimation));
418 // SYS_CONFIG(SPI_SETLISTBOXSMOOTHSCROLLING, 0, IntToPtr(scheme->Effects.bListBoxSmoothScrolling));
419 // SYS_CONFIG(SPI_SETGRADIENTCAPTIONS, 0, IntToPtr(scheme->Effects.bGradientCaptions));
420 // SYS_CONFIG(SPI_SETACTIVEWNDTRKZORDER, 0, IntToPtr(scheme->Effects.bActiveWndTrkZorder));
421 // SYS_CONFIG(SPI_SETHOTTRACKING, 0, IntToPtr(scheme->Effects.bHotTracking));
422 // SYS_CONFIG(SPI_SETSELECTIONFADE, 0, IntToPtr(scheme->Effects.bSelectionFade));
423 SYS_CONFIG(SPI_SETTOOLTIPANIMATION, 0, IntToPtr(scheme->Effects.bTooltipAnimation));
424 SYS_CONFIG(SPI_SETTOOLTIPFADE, 0, IntToPtr(scheme->Effects.bTooltipFade));
425 // SYS_CONFIG(SPI_SETCURSORSHADOW, 0, IntToPtr(scheme->Effects.bCursorShadow));
426 // SYS_CONFIG(SPI_SETUIEFFECTS, 0, IntToPtr(scheme->Effects.bUiEffects));
427
428#undef SYS_CONFIG
429
430 /* Save SchemeId in the registry */
431 if (pSelectedTheme->Theme != NULL && pSelectedTheme->ThemeActive == FALSE)
432 {
433 StyleName = pSelectedTheme->Color->StyleName;
437 REG_SZ,
438 StyleName,
439 (lstrlenW(StyleName) + 1) * sizeof(WCHAR));
440 }
441}
#define IntToPtr(i)
Definition: basetsd.h:89
#define RegCloseKey(hKey)
Definition: registry.h:49
#define ERROR_SUCCESS
Definition: deptool.c:10
static const WCHAR g_CPColors[]
Definition: theme.c:18
static const WCHAR * g_RegColorNames[NUM_COLORS]
Definition: theme.c:26
static const WCHAR g_SelectedStyle[]
Definition: theme.c:21
static const WCHAR g_CPANewSchemes[]
Definition: theme.c:19
#define SYS_CONFIG(__uiAction, __uiParam, __pvParam)
LONG WINAPI RegSetValueExW(_In_ HKEY hKey, _In_ LPCWSTR lpValueName, _In_ DWORD Reserved, _In_ DWORD dwType, _In_ CONST BYTE *lpData, _In_ DWORD cbData)
Definition: reg.c:4882
LONG WINAPI RegCreateKeyW(HKEY hKey, LPCWSTR lpSubKey, PHKEY phkResult)
Definition: reg.c:1201
#define lstrlenW
Definition: compat.h:750
DWORD WINAPI SHSetValueW(HKEY hKey, LPCWSTR lpszSubKey, LPCWSTR lpszValue, DWORD dwType, LPCVOID pvData, DWORD cbData)
Definition: reg.c:1306
#define GetBValue(quad)
Definition: precomp.h:75
#define GetGValue(quad)
Definition: precomp.h:74
#define GetRValue(quad)
Definition: precomp.h:73
FxAutoRegKey hKey
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
#define REG_SZ
Definition: layer.c:22
#define L(x)
Definition: ntvdm.h:50
#define NUM_COLORS
Definition: palettemodel.h:10
int32_t INT
Definition: typedefs.h:58
#define lstrlen
Definition: winbase.h:3876
#define HKEY_CURRENT_USER
Definition: winreg.h:11
BOOL WINAPI SetSysColors(_In_ int cElements, _In_reads_(cElements) CONST INT *lpaElements, _In_reads_(cElements) CONST COLORREF *lpaRgbValues)
#define SPIF_SENDCHANGE
Definition: winuser.h:1575
#define SPIF_UPDATEINIFILE
Definition: winuser.h:1574
#define wsprintf
Definition: winuser.h:5877
BOOL WINAPI SystemParametersInfoW(_In_ UINT uiAction, _In_ UINT uiParam, _Inout_opt_ PVOID pvParam, _In_ UINT fWinIni)
BOOL WINAPI InvalidateRect(_In_opt_ HWND, _In_opt_ LPCRECT, _In_ BOOL)
_At_(*)(_In_ PWSK_CLIENT Client, _In_opt_ PUNICODE_STRING NodeName, _In_opt_ PUNICODE_STRING ServiceName, _In_opt_ ULONG NameSpace, _In_opt_ GUID *Provider, _In_opt_ PADDRINFOEXW Hints, _Outptr_ PADDRINFOEXW *Result, _In_opt_ PEPROCESS OwningProcess, _In_opt_ PETHREAD OwningThread, _Inout_ PIRP Irp Result)(Mem)) NTSTATUS(WSKAPI *PFN_WSK_GET_ADDRESS_INFO
Definition: wsk.h:409
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned char BYTE
Definition: xxhash.c:193

Referenced by ActivateThemeFile().

◆ CleanupStyles()

static void CleanupStyles ( IN PTHEME_STYLE  pStylesList)
static

Definition at line 509 of file theme.c.

510{
511 PTHEME_STYLE pStyle, pStyleOld;
512
513 pStyle = pStylesList;
514 while (pStyle)
515 {
516 if (pStyle->ChildStyle) CleanupStyles(pStyle->ChildStyle);
517 if (pStyle->DisplayName) free(pStyle->DisplayName);
518 if (pStyle->StyleName) free(pStyle->StyleName);
519
520 pStyleOld = pStyle;
521 pStyle = pStyle->NextStyle;
522 free(pStyleOld);
523 }
524}
#define free
Definition: debug_ros.c:5
static void CleanupStyles(IN PTHEME_STYLE pStylesList)
Definition: theme.c:509
struct _THEME_STYLE * ChildStyle
Definition: appearance.h:82
PWSTR StyleName
Definition: appearance.h:83
struct _THEME_STYLE * NextStyle
Definition: appearance.h:81
PWSTR DisplayName
Definition: appearance.h:84

Referenced by CleanupStyles(), CleanupThemes(), and LoadClassicColorSchemes().

◆ CleanupThemes()

void CleanupThemes ( IN PTHEME  pThemeList)

Definition at line 527 of file theme.c.

528{
529 PTHEME pTheme, pThemeOld;
530
531 pTheme = pThemeList;
532 while (pTheme)
533 {
534 CleanupStyles(pTheme->ColoursList);
535 if (pTheme->SizesList) CleanupStyles(pTheme->SizesList);
536 if (pTheme->DisplayName) free(pTheme->DisplayName);
537 if (pTheme->ThemeFileName) free(pTheme->ThemeFileName);
538
539 pThemeOld = pTheme;
540 pTheme = pTheme->NextTheme;
541 free(pThemeOld);
542 }
543}
THEME_STYLE * SizesList
Definition: appearance.h:93
THEME_STYLE * ColoursList
Definition: appearance.h:92
PWSTR ThemeFileName
Definition: appearance.h:90
struct _THEME * NextTheme
Definition: appearance.h:89
PWSTR DisplayName
Definition: appearance.h:91

Referenced by ActivateThemeFile(), and LoadTheme().

◆ CreateStyle()

static PTHEME_STYLE CreateStyle ( LPCWSTR  pszName,
LPCWSTR  pszDisplayName 
)
static

Definition at line 480 of file theme.c.

481{
482 PTHEME_STYLE pStyle;
483
484 pStyle = (PTHEME_STYLE) malloc(sizeof(THEME_STYLE));
485 if (pStyle == NULL) return NULL;
486
487 pStyle->StyleName = _wcsdup(pszName);
488 if (pStyle->StyleName == NULL)
489 {
490 free(pStyle);
491 return NULL;
492 }
493
494 pStyle->DisplayName = _wcsdup(pszDisplayName);
495 if (pStyle->DisplayName == NULL)
496 {
497 free(pStyle->StyleName);
498 free(pStyle);
499 return NULL;
500 }
501
502 pStyle->ChildStyle = NULL;
503 pStyle->NextStyle = NULL;
504
505 return pStyle;
506}
struct _THEME_STYLE * PTHEME_STYLE
#define malloc
Definition: debug_ros.c:4
_Check_return_ _CRTIMP wchar_t *__cdecl _wcsdup(_In_z_ const wchar_t *_Str)

Referenced by EnumThemeStyles(), LoadClassicColorSchemes(), and LoadSchemeSizes().

◆ CreateTheme()

static THEME * CreateTheme ( LPCWSTR  pszName,
LPCWSTR  pszDisplayName 
)
static

Definition at line 444 of file theme.c.

445{
446 PTHEME pTheme;
447
448 pTheme = (PTHEME) malloc(sizeof(THEME));
449 if (pTheme == NULL) return NULL;
450
451 pTheme->DisplayName = _wcsdup(pszDisplayName);
452 if (pTheme->DisplayName == NULL)
453 {
454 free(pTheme);
455 return NULL;
456 }
457
458 pTheme->ColoursList = NULL;
459 pTheme->NextTheme = NULL;
460 pTheme->SizesList = NULL;
461
462 if (pszName == NULL)
463 {
464 pTheme->ThemeFileName = NULL;
465 return pTheme;
466 }
467
468 pTheme->ThemeFileName = _wcsdup(pszName);
469 if (pTheme->ThemeFileName == NULL)
470 {
471 free(pTheme->DisplayName);
472 free(pTheme);
473 return NULL;
474 }
475
476 return pTheme;
477}
struct _THEME * PTHEME

Referenced by LoadTheme(), and LoadThemes().

◆ DrawThemePreview()

BOOL DrawThemePreview ( IN HDC  hdcMem,
IN PCOLOR_SCHEME  scheme,
IN PTHEME_SELECTION  pSelectedTheme,
IN PRECT  prcWindow 
)

Definition at line 990 of file theme.c.

991{
992 HBRUSH hbrBack;
994
995 hbrBack = CreateSolidBrush(scheme->crColor[COLOR_DESKTOP]);
996
997 FillRect(hdcMem, prcWindow, hbrBack);
998 DeleteObject(hbrBack);
999
1000 InflateRect(prcWindow, -8, -8);
1001 prcWindow->bottom -= 12;
1002
1005 prcWindow,
1006 pSelectedTheme->Theme->ThemeFileName,
1007 pSelectedTheme->Color->StyleName,
1008 pSelectedTheme->Size->StyleName,
1009 &scheme->ncMetrics,
1010 scheme->crColor);
1011
1012 return SUCCEEDED(hres);
1013}
HRESULT WINAPI DrawNCPreview(HDC hDC, DWORD DNCP_Flag, LPRECT prcPreview, LPCWSTR pszThemeFileName, LPCWSTR pszColorName, LPCWSTR pszSizeName, PNONCLIENTMETRICSW pncMetrics, COLORREF *lpaRgbValues)
Definition: nonclient.c:1215
pKey DeleteObject()
HRESULT hres
Definition: protocol.c:465
#define DNCP_DRAW_ALL
Definition: uxundoc.h:106
HDC hdcMem
Definition: welcome.c:104
int WINAPI FillRect(HDC, LPCRECT, HBRUSH)
HBRUSH WINAPI CreateSolidBrush(_In_ COLORREF)
#define COLOR_DESKTOP
Definition: winuser.h:917
BOOL WINAPI InflateRect(_Inout_ LPRECT, _In_ int, _In_ int)

◆ EnumThemeProc()

BOOL CALLBACK EnumThemeProc ( IN LPVOID  lpReserved,
IN LPCWSTR  pszThemeFileName,
IN LPCWSTR  pszThemeName,
IN LPCWSTR  pszToolTip,
IN LPVOID  lpReserved2,
IN OUT LPVOID  lpData 
)

Definition at line 725 of file theme.c.

731{
732 PTHEME *List, pTheme;
733
734 List = (PTHEME*)lpData;
735 pTheme = LoadTheme(pszThemeFileName, pszThemeName);
736 if (pTheme == NULL) return FALSE;
737
738 pTheme->NextTheme = *List;
739 *List = pTheme;
740
741 return TRUE;
742}
PTHEME LoadTheme(IN LPCWSTR pszThemeFileName, IN LPCWSTR pszThemeName)
Definition: theme.c:707
_Must_inspect_result_ _In_ WDFCMRESLIST List
Definition: wdfresource.h:550

Referenced by LoadThemes().

◆ EnumThemeStyles()

static THEME_STYLE * EnumThemeStyles ( IN LPCWSTR  pszThemeFileName,
IN ENUMTHEMESTYLE  pfnEnumTheme 
)
static

Definition at line 687 of file theme.c.

688{
689 DWORD index = 0;
691 THEME_STYLE *List = NULL, **ppPrevStyle, *pCurrentStyle;
692
693 ppPrevStyle = &List;
694
695 while (SUCCEEDED(pfnEnumTheme (pszThemeFileName, NULL, index++, &names)))
696 {
697 pCurrentStyle = CreateStyle(names.szName, names.szDisplayName);
698 if(pCurrentStyle == NULL) break;
699
700 *ppPrevStyle = pCurrentStyle;
701 ppPrevStyle = &pCurrentStyle->NextStyle;
702 }
703
704 return List;
705}
static PTHEME_STYLE CreateStyle(LPCWSTR pszName, LPCWSTR pszDisplayName)
Definition: theme.c:480
unsigned long DWORD
Definition: ntddk_ex.h:95
GLuint GLuint * names
Definition: glext.h:11545
GLuint index
Definition: glext.h:6031

Referenced by LoadTheme().

◆ FindOrAppendTheme()

BOOL FindOrAppendTheme ( IN PTHEME  pThemeList,
IN LPCWSTR  pwszThemeFileName,
IN LPCWSTR  pwszColorBuff,
IN LPCWSTR  pwszSizeBuff,
OUT PTHEME_SELECTION  pSelectedTheme 
)

Definition at line 791 of file theme.c.

796{
797 PTHEME pTheme;
798 PTHEME pFoundTheme = NULL;
799
800 ZeroMemory(pSelectedTheme, sizeof(THEME_SELECTION));
801
802 for (pTheme = pThemeList; pTheme; pTheme = pTheme->NextTheme)
803 {
804 if (pTheme->ThemeFileName &&
805 _wcsicmp(pTheme->ThemeFileName, pwszThemeFileName) == 0)
806 {
807 pFoundTheme = pTheme;
808 break;
809 }
810
811 if (pTheme->NextTheme == NULL)
812 break;
813 }
814
815 if (!pFoundTheme)
816 {
817 pFoundTheme = LoadTheme(pwszThemeFileName, pwszThemeFileName);
818 if (!pFoundTheme)
819 return FALSE;
820
821 pTheme->NextTheme = pFoundTheme;
822 }
823
824 pSelectedTheme->ThemeActive = TRUE;
825 pSelectedTheme->Theme = pFoundTheme;
826 if (pwszColorBuff)
827 pSelectedTheme->Color = FindStyle(pFoundTheme->ColoursList, pwszColorBuff);
828 else
829 pSelectedTheme->Color = pFoundTheme->ColoursList;
830
831 if (pwszSizeBuff)
832 pSelectedTheme->Size = FindStyle(pFoundTheme->SizesList, pwszSizeBuff);
833 else
834 pSelectedTheme->Size = pFoundTheme->SizesList;
835
836 return TRUE;
837}
static PTHEME_STYLE FindStyle(IN PTHEME_STYLE pStylesList, IN PCWSTR StyleName)
Definition: theme.c:546
_Check_return_ _CRTIMP int __cdecl _wcsicmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
#define ZeroMemory
Definition: winbase.h:1712

Referenced by ActivateThemeFile(), AppearancePage_OnInit(), and GetActiveTheme().

◆ FindStyle()

static PTHEME_STYLE FindStyle ( IN PTHEME_STYLE  pStylesList,
IN PCWSTR  StyleName 
)
static

Definition at line 546 of file theme.c.

547{
548 PTHEME_STYLE pStyle;
549
550 for (pStyle = pStylesList; pStyle; pStyle = pStyle->NextStyle)
551 {
552 if (_wcsicmp(pStyle->StyleName, StyleName) == 0)
553 {
554 return pStyle;
555 }
556 }
557
558 /* If we can't find the style requested, return the first one */
559 return pStylesList;
560}

Referenced by FindOrAppendTheme(), and GetActiveClassicTheme().

◆ GetActiveClassicTheme()

BOOL GetActiveClassicTheme ( IN PTHEME  pThemeList,
OUT PTHEME_SELECTION  pSelectedTheme 
)

Definition at line 869 of file theme.c.

870{
871 INT Result;
872 WCHAR szSelectedClassicScheme[5], szSelectedClassicSize[5];
873 HKEY hkNewSchemes;
874 DWORD dwType, dwDisplayNameLength;
875 PTHEME_STYLE pCurrentStyle, pCurrentSize;
876
877 ZeroMemory(pSelectedTheme, sizeof(THEME_SELECTION));
878
879 /* Assume failure */
880 szSelectedClassicScheme[0] = 0;
881 szSelectedClassicSize[0] = 0;
882
884 if (Result != ERROR_SUCCESS) return FALSE;
885
886 dwType = REG_SZ;
887 dwDisplayNameLength = sizeof(szSelectedClassicScheme);
888 Result = RegQueryValueEx(hkNewSchemes, L"SelectedStyle", NULL, &dwType,
889 (LPBYTE)&szSelectedClassicScheme, &dwDisplayNameLength);
890 if (Result == ERROR_SUCCESS)
891 {
892 dwType = REG_SZ;
893 dwDisplayNameLength = sizeof(szSelectedClassicSize);
894 Result = SHGetValue(hkNewSchemes, szSelectedClassicScheme, L"SelectedSize",
895 &dwType, szSelectedClassicSize, &dwDisplayNameLength);
896 }
897
898 RegCloseKey(hkNewSchemes);
899
900 pCurrentStyle = FindStyle(pThemeList->ColoursList, szSelectedClassicScheme);
901 pCurrentSize = FindStyle(pCurrentStyle->ChildStyle, szSelectedClassicSize);
902
903 pSelectedTheme->Theme = pThemeList;
904 pSelectedTheme->Color = pCurrentStyle;
905 pSelectedTheme->Size = pCurrentSize;
906
907 return TRUE;
908}
LONG WINAPI RegOpenKeyW(HKEY hKey, LPCWSTR lpSubKey, PHKEY phkResult)
Definition: reg.c:3268
#define SHGetValue
Definition: shlwapi.h:70
unsigned char * LPBYTE
Definition: typedefs.h:53
#define RegQueryValueEx
Definition: winreg.h:524

Referenced by ActivateThemeFile().

◆ GetActiveTheme()

BOOL GetActiveTheme ( IN PTHEME  pThemeList,
OUT PTHEME_SELECTION  pSelectedTheme 
)

Definition at line 844 of file theme.c.

845{
846 WCHAR szThemeFileName[MAX_PATH];
847 WCHAR szColorBuff[MAX_PATH];
848 WCHAR szSizeBuff[MAX_PATH];
849 HRESULT hret;
850
851 /* Retrieve the name of the current theme */
852 hret = GetCurrentThemeName(szThemeFileName,
853 MAX_PATH,
854 szColorBuff,
855 MAX_PATH,
856 szSizeBuff,
857 MAX_PATH);
858 if (FAILED(hret))
859 return FALSE;
860
861 return FindOrAppendTheme(pThemeList, szThemeFileName, szColorBuff, szSizeBuff, pSelectedTheme);
862}
#define MAX_PATH
Definition: compat.h:34
HRESULT WINAPI GetCurrentThemeName(LPWSTR pszThemeFileName, int dwMaxNameChars, LPWSTR pszColorBuff, int cchMaxColorChars, LPWSTR pszSizeBuff, int cchMaxSizeChars)
Definition: system.c:894
#define FAILED(hr)
Definition: intsafe.h:51

◆ LoadClassicColorSchemes()

static THEME_STYLE * LoadClassicColorSchemes ( VOID  )
static

Definition at line 625 of file theme.c.

626{
627 INT Result;
628 HKEY hkNewSchemes, hkScheme;
629 INT iStyle;
630 WCHAR wstrStyleName[5], wstrDisplayName[50];
631 THEME_STYLE *List = NULL, *pCurrentStyle;
632
634 if (Result != ERROR_SUCCESS) return NULL;
635
636 iStyle = 0;
637 while ((RegEnumKeyW(hkNewSchemes, iStyle, wstrStyleName, 5) == ERROR_SUCCESS))
638 {
639 iStyle++;
640
641 Result = RegOpenKeyW(hkNewSchemes, wstrStyleName, &hkScheme);
642 if (Result != ERROR_SUCCESS) continue;
643
644 Result = RegLoadMUIStringW(hkScheme,
645 L"DisplayName",
646 wstrDisplayName,
647 sizeof(wstrDisplayName),
648 NULL,
649 0,
650 NULL);
651 if (Result != ERROR_SUCCESS)
652 {
653 Result = RegLoadMUIStringW(hkScheme,
654 L"LegacyName",
655 wstrDisplayName,
656 sizeof(wstrDisplayName),
657 NULL,
658 0,
659 NULL);
660 }
661
662 if (Result == ERROR_SUCCESS)
663 pCurrentStyle = CreateStyle(wstrStyleName, wstrDisplayName);
664 else
665 pCurrentStyle = CreateStyle(wstrStyleName, wstrStyleName);
666
667 if (pCurrentStyle != NULL)
668 {
669 pCurrentStyle->NextStyle = List;
670 pCurrentStyle->ChildStyle = LoadSchemeSizes(hkScheme);
671 if(pCurrentStyle->ChildStyle == NULL)
672 CleanupStyles(pCurrentStyle);
673 else
674 List = pCurrentStyle;
675 }
676
677 RegCloseKey(hkScheme);
678 }
679
680 RegCloseKey(hkNewSchemes);
681 return List;
682}
LONG RegLoadMUIStringW(IN HKEY hKey, IN LPCWSTR pszValue OPTIONAL, OUT LPWSTR pszOutBuf, IN DWORD cbOutBuf, OUT LPDWORD pcbData OPTIONAL, IN DWORD Flags, IN LPCWSTR pszDirectory OPTIONAL)
Definition: muireg.c:53
static PTHEME_STYLE LoadSchemeSizes(IN HKEY hkScheme)
Definition: theme.c:566
LONG WINAPI RegEnumKeyW(HKEY hKey, DWORD dwIndex, LPWSTR lpName, DWORD cbName)
Definition: reg.c:2393

Referenced by LoadThemes().

◆ LoadCurrentScheme()

BOOL LoadCurrentScheme ( OUT COLOR_SCHEME scheme)

Definition at line 122 of file theme.c.

123{
124 INT i, Result;
125 HKEY hKey;
126 BOOL ret;
127#if (WINVER >= 0x0600)
129#endif
130
131 /* Load colors */
132 for (i = 0; i < NUM_COLORS; i++)
133 {
134 scheme->crColor[i] = (COLORREF)GetSysColor(i);
135 }
136
137 /* Load non client metrics */
138 scheme->ncMetrics.cbSize = sizeof(NONCLIENTMETRICSW);
139
140#if (WINVER >= 0x0600)
141 /* Size of NONCLIENTMETRICSA/W depends on current version of the OS.
142 * see:
143 * https://msdn.microsoft.com/en-us/library/windows/desktop/ff729175%28v=vs.85%29.aspx
144 */
145 if (GetVersionEx(&osvi))
146 {
147 /* Windows XP and earlier */
148 if (osvi.dwMajorVersion <= 5)
149 scheme->ncMetrics.cbSize -= sizeof(scheme->ncMetrics.iPaddedBorderWidth);
150 }
151#endif
152
153 ret = SystemParametersInfoW(SPI_GETNONCLIENTMETRICS,
154 sizeof(NONCLIENTMETRICSW),
155 &scheme->ncMetrics,
156 0);
157 if (!ret) return FALSE;
158
159 /* Load icon metrics */
160 scheme->icMetrics.cbSize = sizeof(ICONMETRICSW);
161 ret = SystemParametersInfoW(SPI_GETICONMETRICS,
162 sizeof(ICONMETRICSW),
163 &scheme->icMetrics,
164 0);
165 if (!ret) return FALSE;
166
167 /* Load flat menu style */
168 ret = SystemParametersInfoW(SPI_GETFLATMENU,
169 0,
170 &scheme->bFlatMenus,
171 0);
172 if (!ret) return FALSE;
173
174 /* Effects */
175 /* Use the following transition effect for menus and tooltips */
176 ret = SystemParametersInfoW(SPI_GETMENUANIMATION,
177 0,
178 &scheme->Effects.bMenuAnimation,
179 0);
180 if (!ret) return FALSE;
181
182 ret = SystemParametersInfoW(SPI_GETMENUFADE,
183 0,
184 &scheme->Effects.bMenuFade,
185 0);
186 if (!ret) return FALSE;
187
188 /* FIXME: XP seems to use grayed checkboxes to reflect differences between menu and tooltips settings
189 * Just keep them in sync for now:
190 */
191 scheme->Effects.bTooltipAnimation = scheme->Effects.bMenuAnimation;
192 scheme->Effects.bTooltipFade = scheme->Effects.bMenuFade;
193
194 /* Use the following transition effect for menus and tooltips */
195 ret = SystemParametersInfoW(SPI_GETFONTSMOOTHING,
196 0,
197 &scheme->Effects.bFontSmoothing,
198 0);
199 if (!ret) return FALSE;
200
201 ret = SystemParametersInfoW(SPI_GETFONTSMOOTHINGTYPE,
202 0,
203 &scheme->Effects.uiFontSmoothingType,
204 0);
205 if (!ret) return FALSE;
206
207 /* Show shadows under menus */
208 ret = SystemParametersInfoW(SPI_GETDROPSHADOW,
209 0,
210 &scheme->Effects.bDropShadow,
211 0);
212 if (!ret) return FALSE;
213
214 /* Show content of windows during dragging */
215 ret = SystemParametersInfoW(SPI_GETDRAGFULLWINDOWS,
216 0,
217 &scheme->Effects.bDragFullWindows,
218 0);
219 if (!ret) return FALSE;
220
221 /* Hide underlined letters for keyboard navigation until the Alt key is pressed */
222 ret = SystemParametersInfoW(SPI_GETKEYBOARDCUES,
223 0,
224 &scheme->Effects.bKeyboardCues,
225 0);
226 if (!ret) return FALSE;
227
228 /* Read the icon size from registry */
230 if(Result == ERROR_SUCCESS)
231 {
232 scheme->iIconSize = SHRegGetIntW(hKey, L"Shell Icon Size", 32);
234 }
235
236 return TRUE;
237}
static const WCHAR g_CPMetrics[]
Definition: theme.c:20
int WINAPI SHRegGetIntW(HKEY hKey, LPCWSTR lpszValue, int iDefault)
Definition: reg.c:2374
ULONG dwMajorVersion
Definition: rtltypes.h:238
OSVERSIONINFO osvi
Definition: ver.c:28
#define GetVersionEx
Definition: winbase.h:3852
DWORD COLORREF
Definition: windef.h:300
DWORD WINAPI GetSysColor(_In_ int)

Referenced by ActivateThemeFile().

◆ LoadSchemeFromReg()

BOOL LoadSchemeFromReg ( OUT COLOR_SCHEME scheme,
IN PTHEME_SELECTION  pSelectedTheme 
)

Definition at line 243 of file theme.c.

244{
245 INT i;
246 WCHAR strValueName[10], strSchemeKey[MAX_PATH];
247 HKEY hkScheme = NULL;
248 DWORD dwType, dwLength;
249 UINT64 iSize;
250 BOOL Ret = TRUE;
251 LONG result;
252
253 wsprintf(strSchemeKey, L"%s\\%s\\Sizes\\%s",
255 pSelectedTheme->Color->StyleName,
256 pSelectedTheme->Size->StyleName);
257
258 result = RegOpenKeyW(HKEY_CURRENT_USER, strSchemeKey, &hkScheme);
259 if (result != ERROR_SUCCESS) return FALSE;
260
261 scheme->bFlatMenus = SHRegGetIntW(hkScheme, L"FlatMenus", 0);
262
263 for (i = 0; i < NUM_COLORS; i++)
264 {
265 wsprintf(strValueName, L"Color #%d", i);
266 dwLength = sizeof(COLORREF);
267 result = RegQueryValueExW(hkScheme,
268 strValueName,
269 NULL,
270 &dwType,
271 (LPBYTE)&scheme->crColor[i],
272 &dwLength);
273 if (result != ERROR_SUCCESS || dwType != REG_DWORD)
274 {
275 /* Failed to read registry value, initialize with current setting for now */
276 scheme->crColor[i] = GetSysColor(i);
277 }
278 }
279
280 for (i = 0; i < NUM_FONTS; i++)
281 {
282 PLOGFONTW lpfFont = SchemeGetFont(scheme, i);
283
284 wsprintf(strValueName, L"Font #%d", i);
285 dwLength = sizeof(LOGFONT);
286 result = RegQueryValueExW(hkScheme,
287 strValueName,
288 NULL,
289 &dwType,
290 (LPBYTE)lpfFont,
291 &dwLength);
292 if (result != ERROR_SUCCESS || dwType != REG_BINARY ||
293 dwLength != sizeof(LOGFONT))
294 {
295 /* Failed to read registry value */
296 Ret = FALSE;
297 }
298 }
299
300 for (i = 0; i < NUM_SIZES; i++)
301 {
302 wsprintf(strValueName, L"Size #%d", i);
303 dwLength = sizeof(UINT64);
304 result = RegQueryValueExW(hkScheme,
305 strValueName,
306 NULL,
307 &dwType,
308 (LPBYTE)&iSize,
309 &dwLength);
310 if (result != ERROR_SUCCESS || dwType != REG_QWORD ||
311 dwLength != sizeof(UINT64))
312 {
313 /* Failed to read registry value, initialize with current setting for now */
314 }
315 else
316 {
317 SchemeSetMetric(scheme, i, (int)iSize);
318 }
319 }
320
321 RegCloseKey(hkScheme);
322
323 return Ret;
324}
unsigned long long UINT64
#define NUM_FONTS
Definition: appearance.h:26
#define NUM_SIZES
Definition: appearance.h:27
VOID SchemeSetMetric(IN COLOR_SCHEME *scheme, int id, int value)
Definition: theme.c:63
PLOGFONTW SchemeGetFont(IN COLOR_SCHEME *scheme, int id)
Definition: theme.c:104
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4103
static DWORD DWORD * dwLength
Definition: fusion.c:86
GLuint64EXT * result
Definition: glext.h:11304
#define REG_BINARY
Definition: nt_native.h:1496
long LONG
Definition: pedump.c:60
#define REG_QWORD
Definition: sdbapi.c:597
#define REG_DWORD
Definition: sdbapi.c:596
LOGFONTA LOGFONT
Definition: wingdi.h:4415

Referenced by ActivateThemeFile().

◆ LoadSchemeFromTheme()

BOOL LoadSchemeFromTheme ( OUT PCOLOR_SCHEME  scheme,
IN PTHEME_SELECTION  pSelectedTheme 
)

Definition at line 938 of file theme.c.

939{
940 HTHEMEFILE hThemeFile = 0;
941 HRESULT hret;
942 HTHEME hTheme;
943 int i;
944
945 hret = OpenThemeFile(pSelectedTheme->Theme->ThemeFileName,
946 pSelectedTheme->Color->StyleName,
947 pSelectedTheme->Size->StyleName,
948 &hThemeFile,
949 0);
950
951 if (!SUCCEEDED(hret)) return FALSE;
952
953 hTheme = OpenThemeDataFromFile(hThemeFile, hCPLWindow, L"WINDOW", 0);
954 if (hTheme == NULL) return FALSE;
955
956 /* Load colors */
957 for (i = 0; i < NUM_COLORS; i++)
958 {
959 scheme->crColor[i] = GetThemeSysColor(hTheme,i);
960 }
961
962 /* Load sizes */
963 /* I wonder why GetThemeSysInt doesn't work here */
964 scheme->ncMetrics.iBorderWidth = GetThemeSysSize(hTheme, SM_CXFRAME);
965 scheme->ncMetrics.iScrollWidth = GetThemeSysSize(hTheme, SM_CXVSCROLL);
966 scheme->ncMetrics.iScrollHeight = GetThemeSysSize(hTheme, SM_CYHSCROLL);
967 scheme->ncMetrics.iCaptionWidth = GetThemeSysSize(hTheme, SM_CXSIZE);
968 scheme->ncMetrics.iCaptionHeight = GetThemeSysSize(hTheme, SM_CYSIZE);
969 scheme->ncMetrics.iSmCaptionWidth = GetThemeSysSize(hTheme, SM_CXSMSIZE);
970 scheme->ncMetrics.iSmCaptionHeight = GetThemeSysSize(hTheme, SM_CYSMSIZE);
971 scheme->ncMetrics.iMenuWidth = GetThemeSysSize(hTheme, SM_CXMENUSIZE);
972 scheme->ncMetrics.iMenuHeight = GetThemeSysSize(hTheme, SM_CYMENUSIZE);
973
974 /* Load fonts */
975 GetThemeSysFont(hTheme, TMT_CAPTIONFONT, &scheme->ncMetrics.lfCaptionFont);
976 GetThemeSysFont(hTheme, TMT_SMALLCAPTIONFONT, &scheme->ncMetrics.lfSmCaptionFont);
977 GetThemeSysFont(hTheme, TMT_MENUFONT, &scheme->ncMetrics.lfMenuFont );
978 GetThemeSysFont(hTheme, TMT_STATUSFONT, &scheme->ncMetrics.lfStatusFont);
979 GetThemeSysFont(hTheme, TMT_MSGBOXFONT, &scheme->ncMetrics.lfMessageFont);
980 GetThemeSysFont(hTheme, TMT_ICONTITLEFONT, &scheme->icMetrics.lfFont);
981
982 scheme->bFlatMenus = GetThemeSysBool(hTheme, TMT_FLATMENUS);
983
984 CloseThemeData(hTheme);
985
986 return TRUE;
987}
HWND hCPLWindow
Definition: desk.c:38
COLORREF WINAPI GetThemeSysColor(HTHEME hTheme, int iColorID)
Definition: metric.c:58
HRESULT WINAPI GetThemeSysFont(HTHEME hTheme, int iFontID, LOGFONTW *plf)
Definition: metric.c:91
int WINAPI GetThemeSysSize(HTHEME hTheme, int iSizeID)
Definition: metric.c:154
BOOL WINAPI GetThemeSysBool(HTHEME hTheme, int iBoolID)
Definition: metric.c:26
HTHEME WINAPI OpenThemeDataFromFile(HTHEMEFILE hThemeFile, HWND hwnd, LPCWSTR pszClassList, DWORD flags)
Definition: system.c:827
HRESULT WINAPI CloseThemeData(HTHEME hTheme)
Definition: system.c:950
static HTHEME(WINAPI *pOpenThemeDataEx)(HWND
#define TMT_SMALLCAPTIONFONT
Definition: vssym32.h:165
#define TMT_FLATMENUS
Definition: vssym32.h:175
#define TMT_CAPTIONFONT
Definition: vssym32.h:164
#define TMT_MENUFONT
Definition: vssym32.h:166
#define TMT_MSGBOXFONT
Definition: vssym32.h:168
#define TMT_ICONTITLEFONT
Definition: vssym32.h:169
#define TMT_STATUSFONT
Definition: vssym32.h:167
#define SM_CYSIZE
Definition: winuser.h:995
#define SM_CXVSCROLL
Definition: winuser.h:964
#define SM_CXFRAME
Definition: winuser.h:997
#define SM_CXSIZE
Definition: winuser.h:994
#define SM_CYHSCROLL
Definition: winuser.h:965
#define SM_CXSMSIZE
Definition: winuser.h:1018
#define SM_CXMENUSIZE
Definition: winuser.h:1020
#define SM_CYSMSIZE
Definition: winuser.h:1019
#define SM_CYMENUSIZE
Definition: winuser.h:1021

Referenced by ActivateThemeFile().

◆ LoadSchemeSizes()

static PTHEME_STYLE LoadSchemeSizes ( IN HKEY  hkScheme)
static

Definition at line 566 of file theme.c.

567{
568 HKEY hkSizes, hkSize;
569 INT Result;
570 INT iStyle;
571 WCHAR wstrSizeName[5], wstrDisplayName[50];
572 THEME_STYLE *List = NULL, *pCurrentStyle;
573
574 Result = RegOpenKeyW(hkScheme, L"Sizes", &hkSizes);
575 if (Result != ERROR_SUCCESS) return NULL;
576
577 iStyle = 0;
578 while ((RegEnumKeyW(hkSizes, iStyle, wstrSizeName, 5) == ERROR_SUCCESS))
579 {
580 iStyle++;
581
582 Result = RegOpenKeyW(hkSizes, wstrSizeName, &hkSize);
583 if (Result != ERROR_SUCCESS) continue;
584
585 Result = RegLoadMUIStringW(hkSize,
586 L"DisplayName",
587 wstrDisplayName,
588 sizeof(wstrDisplayName),
589 NULL,
590 0,
591 NULL);
592 if (Result != ERROR_SUCCESS)
593 {
594 Result = RegLoadMUIStringW(hkSize,
595 L"LegacyName",
596 wstrDisplayName,
597 sizeof(wstrDisplayName),
598 NULL,
599 0,
600 NULL);
601 }
602
603 if (Result == ERROR_SUCCESS)
604 pCurrentStyle = CreateStyle(wstrSizeName, wstrDisplayName);
605 else
606 pCurrentStyle = CreateStyle(wstrSizeName, wstrSizeName);
607
608 if (pCurrentStyle != NULL)
609 {
610 pCurrentStyle->NextStyle = List;
611 List = pCurrentStyle;
612 }
613
614 RegCloseKey(hkSize);
615 }
616
617 RegCloseKey(hkSizes);
618 return List;
619}

Referenced by LoadClassicColorSchemes().

◆ LoadTheme()

PTHEME LoadTheme ( IN LPCWSTR  pszThemeFileName,
IN LPCWSTR  pszThemeName 
)

Definition at line 707 of file theme.c.

708{
709 PTHEME pTheme = CreateTheme(pszThemeFileName, pszThemeName);
710 if (pTheme == NULL)
711 return NULL;
712
713 pTheme->SizesList = EnumThemeStyles( pszThemeFileName, (ENUMTHEMESTYLE)EnumThemeSizes);
714 pTheme->ColoursList = EnumThemeStyles( pszThemeFileName, (ENUMTHEMESTYLE)EnumThemeColors);
715 if(pTheme->SizesList == NULL || pTheme->ColoursList == NULL)
716 {
717 CleanupThemes(pTheme);
718 return NULL;
719 }
720
721 return pTheme;
722}
static THEME_STYLE * EnumThemeStyles(IN LPCWSTR pszThemeFileName, IN ENUMTHEMESTYLE pfnEnumTheme)
Definition: theme.c:687
HRESULT(WINAPI * ENUMTHEMESTYLE)(LPCWSTR, LPWSTR, DWORD, PTHEMENAMES)
Definition: theme.c:684
static THEME * CreateTheme(LPCWSTR pszName, LPCWSTR pszDisplayName)
Definition: theme.c:444
HRESULT WINAPI EnumThemeColors(LPWSTR pszThemeFileName, LPWSTR pszSizeName, DWORD dwColorNum, PTHEMENAMES pszColorNames)
Definition: system.c:1310
HRESULT WINAPI EnumThemeSizes(LPWSTR pszThemeFileName, LPWSTR pszColorName, DWORD dwSizeNum, PTHEMENAMES pszSizeNames)
Definition: system.c:1373

Referenced by EnumThemeProc(), and FindOrAppendTheme().

◆ LoadThemes()

PTHEME LoadThemes ( VOID  )

Definition at line 749 of file theme.c.

750{
751 HRESULT hret;
752 PTHEME pClassicTheme;
753 WCHAR strClassicTheme[40];
754 WCHAR szThemesPath[MAX_PATH], *pszClassicTheme;
755 int res;
756
757 /* Insert the classic theme */
758 res = LoadString(hApplet, IDS_CLASSIC_THEME, strClassicTheme, 40);
759 pszClassicTheme = (res > 0 ? strClassicTheme : L"Classic Theme");
760 pClassicTheme = CreateTheme(NULL, pszClassicTheme);
761 if (pClassicTheme == NULL) return NULL;
762 pClassicTheme->ColoursList = LoadClassicColorSchemes();
763
764 /* Get path to themes folder */
765 ZeroMemory(szThemesPath, sizeof(szThemesPath));
767 if (FAILED(hret)) return pClassicTheme;
768 lstrcatW (szThemesPath, L"\\Themes");
769
770 /* Enumerate themes */
771 hret = EnumThemes( szThemesPath, EnumThemeProc, &pClassicTheme->NextTheme);
772 if (FAILED(hret))
773 {
774 pClassicTheme->NextTheme = NULL;
775 if (pClassicTheme->ColoursList == NULL)
776 {
777 free(pClassicTheme->DisplayName);
778 free(pClassicTheme);
779 return NULL;
780 }
781 }
782
783 return pClassicTheme;
784}
HINSTANCE hApplet
Definition: access.c:17
#define IDS_CLASSIC_THEME
Definition: resource.h:111
BOOL CALLBACK EnumThemeProc(IN LPVOID lpReserved, IN LPCWSTR pszThemeFileName, IN LPCWSTR pszThemeName, IN LPCWSTR pszToolTip, IN LPVOID lpReserved2, IN OUT LPVOID lpData)
Definition: theme.c:725
static THEME_STYLE * LoadClassicColorSchemes(VOID)
Definition: theme.c:625
HRESULT WINAPI SHGetFolderPathW(HWND hwndOwner, int nFolder, HANDLE hToken, DWORD dwFlags, LPWSTR pszPath)
Definition: shellpath.c:2589
HRESULT WINAPI EnumThemes(LPCWSTR pszThemePath, ENUMTHEMEPROC callback, LPVOID lpData)
Definition: system.c:1221
GLuint res
Definition: glext.h:9613
LPWSTR WINAPI lstrcatW(LPWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:274
@ SHGFP_TYPE_DEFAULT
Definition: shlobj.h:2150
#define CSIDL_RESOURCES
Definition: shlobj.h:2225
#define LoadString
Definition: winuser.h:5831

Referenced by ActivateThemeFile(), and AppearancePage_OnInit().

◆ SchemeGetFont()

PLOGFONTW SchemeGetFont ( IN COLOR_SCHEME scheme,
int  id 
)

Definition at line 104 of file theme.c.

105{
106 switch (id)
107 {
108 case FONT_CAPTION: return &scheme->ncMetrics.lfCaptionFont;
109 case FONT_SMCAPTION: return &scheme->ncMetrics.lfSmCaptionFont;
110 case FONT_MENU: return &scheme->ncMetrics.lfMenuFont;
111 case FONT_STATUS: return &scheme->ncMetrics.lfStatusFont;
112 case FONT_MESSAGE: return &scheme->ncMetrics.lfMessageFont;
113 case FONT_ICON: return &scheme->icMetrics.lfFont;
114 }
115 return NULL;
116}
#define FONT_MESSAGE
Definition: appearance.h:22
#define FONT_CAPTION
Definition: appearance.h:18
#define FONT_SMCAPTION
Definition: appearance.h:19
#define FONT_STATUS
Definition: appearance.h:21
#define FONT_ICON
Definition: appearance.h:23
#define FONT_MENU
Definition: appearance.h:20

Referenced by LoadSchemeFromReg().

◆ SchemeGetMetric()

int SchemeGetMetric ( IN COLOR_SCHEME scheme,
int  id 
)

Definition at line 83 of file theme.c.

84{
85 switch (id)
86 {
87 case SIZE_BORDER_WIDTH: return scheme->ncMetrics.iBorderWidth;
88 case SIZE_SCROLL_WIDTH: return scheme->ncMetrics.iScrollWidth;
89 case SIZE_SCROLL_HEIGHT: return scheme->ncMetrics.iScrollHeight;
90 case SIZE_CAPTION_WIDTH: return scheme->ncMetrics.iCaptionWidth;
91 case SIZE_CAPTION_HEIGHT: return scheme->ncMetrics.iCaptionHeight;
92 case SIZE_SM_CAPTION_WIDTH: return scheme->ncMetrics.iSmCaptionWidth;
93 case SIZE_SM_CAPTION_HEIGHT: return scheme->ncMetrics.iSmCaptionHeight;
94 case SIZE_MENU_WIDTH: return scheme->ncMetrics.iMenuWidth;
95 case SIZE_MENU_HEIGHT: return scheme->ncMetrics.iMenuHeight;
96 case SIZE_ICON: return scheme->iIconSize;
97 case SIZE_ICON_SPACE_X: return scheme->icMetrics.iHorzSpacing;
98 case SIZE_ICON_SPACE_Y: return scheme->icMetrics.iVertSpacing;
99 }
100 return 0;
101}
#define SIZE_MENU_WIDTH
Definition: appearance.h:11
#define SIZE_CAPTION_WIDTH
Definition: appearance.h:7
#define SIZE_ICON_SPACE_X
Definition: appearance.h:14
#define SIZE_SCROLL_HEIGHT
Definition: appearance.h:6
#define SIZE_SM_CAPTION_WIDTH
Definition: appearance.h:9
#define SIZE_ICON_SPACE_Y
Definition: appearance.h:15
#define SIZE_SCROLL_WIDTH
Definition: appearance.h:5
#define SIZE_MENU_HEIGHT
Definition: appearance.h:12
#define SIZE_BORDER_WIDTH
Definition: appearance.h:4
#define SIZE_ICON
Definition: appearance.h:16
#define SIZE_CAPTION_HEIGHT
Definition: appearance.h:8
#define SIZE_SM_CAPTION_HEIGHT
Definition: appearance.h:10

◆ SchemeSetMetric()

VOID SchemeSetMetric ( IN COLOR_SCHEME scheme,
int  id,
int  value 
)

Definition at line 63 of file theme.c.

64{
65 switch (id)
66 {
67 case SIZE_BORDER_WIDTH: scheme->ncMetrics.iBorderWidth = value; break;
68 case SIZE_SCROLL_WIDTH: scheme->ncMetrics.iScrollWidth = value; break;
69 case SIZE_SCROLL_HEIGHT: scheme->ncMetrics.iScrollHeight = value; break;
70 case SIZE_CAPTION_WIDTH: scheme->ncMetrics.iCaptionWidth = value; break;
71 case SIZE_CAPTION_HEIGHT: scheme->ncMetrics.iCaptionHeight = value; break;
72 case SIZE_SM_CAPTION_WIDTH: scheme->ncMetrics.iSmCaptionWidth = value; break;
73 case SIZE_SM_CAPTION_HEIGHT: scheme->ncMetrics.iSmCaptionHeight = value; break;
74 case SIZE_MENU_WIDTH: scheme->ncMetrics.iMenuWidth = value; break;
75 case SIZE_MENU_HEIGHT: scheme->ncMetrics.iMenuHeight = value; break;
76 case SIZE_ICON: scheme->iIconSize = value; break;
77 case SIZE_ICON_SPACE_X: scheme->icMetrics.iHorzSpacing = value; break;
78 case SIZE_ICON_SPACE_Y: scheme->icMetrics.iVertSpacing = value; break;
79 }
80}
Definition: pdh_main.c:94

Referenced by LoadSchemeFromReg().

◆ ThemesPageProc()

INT_PTR CALLBACK ThemesPageProc ( HWND  hwndDlg,
UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam 
)

Definition at line 1065 of file theme.c.

1066{
1067 LPNMHDR lpnm;
1068
1069 switch (uMsg)
1070 {
1071 case WM_INITDIALOG:
1072 break;
1073
1074 case WM_COMMAND:
1075 break;
1076
1077 case WM_NOTIFY:
1078 lpnm = (LPNMHDR)lParam;
1079 switch (lpnm->code)
1080 {
1081 case PSN_APPLY:
1083 return TRUE;
1084 }
1085 break;
1086
1087 case WM_DESTROY:
1088 break;
1089 }
1090
1091 return FALSE;
1092}
LPARAM lParam
Definition: combotst.c:139
#define TEXT(s)
Definition: k32.h:26
#define PSN_APPLY
Definition: prsht.h:117
#define WM_NOTIFY
Definition: richedit.h:61
UINT code
Definition: winuser.h:3162
LONG_PTR LPARAM
Definition: windef.h:208
#define HWND_BROADCAST
Definition: winuser.h:1207
#define WM_COMMAND
Definition: winuser.h:1743
#define WM_INITDIALOG
Definition: winuser.h:1742
#define WM_SETTINGCHANGE
Definition: winuser.h:1632
struct tagNMHDR * LPNMHDR
#define SendMessage
Definition: winuser.h:5855
#define WM_DESTROY
Definition: winuser.h:1612

Variable Documentation

◆ g_CPANewSchemes

const WCHAR g_CPANewSchemes[] = L"Control Panel\\Appearance\\New Schemes"
static

◆ g_CPColors

const WCHAR g_CPColors[] = L"Control Panel\\Colors"
static

Definition at line 18 of file theme.c.

Referenced by ApplyScheme().

◆ g_CPMetrics

const WCHAR g_CPMetrics[] = L"Control Panel\\Desktop\\WindowMetrics"
static

Definition at line 20 of file theme.c.

Referenced by LoadCurrentScheme().

◆ g_RegColorNames

const WCHAR* g_RegColorNames[NUM_COLORS]
static

Definition at line 26 of file theme.c.

Referenced by ApplyScheme().

◆ g_SelectedStyle

const WCHAR g_SelectedStyle[] = L"SelectedStyle"
static

Definition at line 21 of file theme.c.

Referenced by ApplyScheme().