ReactOS  0.4.13-dev-563-g0561610
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)
 

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 }
LONG HRESULT
Definition: typedefs.h:77
HRESULT WINAPI CloseThemeFile(HTHEMEFILE hThemeFile)
Definition: system.c:1127
HRESULT WINAPI OpenThemeFile(LPCWSTR pszThemeFileName, LPCWSTR pszColorName, LPCWSTR pszSizeName, HTHEMEFILE *hThemeFile, DWORD unknown)
Definition: system.c:1101
HRESULT WINAPI ApplyTheme(HTHEMEFILE hThemeFile, char *unknown, HWND hWnd)
Definition: system.c:1158
#define SUCCEEDED(hr)
Definition: intsafe.h:57

Referenced by ActivateThemeFile().

◆ ActivateThemeFile()

BOOL ActivateThemeFile ( LPCWSTR  pwszFile)

Definition at line 1014 of file theme.c.

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

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 
354  RegSetValueExW(hKey,
356  0,
357  REG_SZ,
358  (BYTE *)clText,
359  (lstrlen(clText) + 1) * sizeof(WCHAR));
360  }
361  RegCloseKey(hKey);
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 }
DWORD WINAPI SHSetValueW(HKEY hKey, LPCWSTR lpszSubKey, LPCWSTR lpszValue, DWORD dwType, LPCVOID pvData, DWORD cbData)
Definition: reg.c:1306
#define TRUE
Definition: types.h:120
#define ERROR_SUCCESS
Definition: deptool.c:10
#define HKEY_CURRENT_USER
Definition: winreg.h:11
#define NUM_COLORS
Definition: appearance.h:28
#define GetRValue(rgb)
Definition: wingdi.h:2913
DWORD scheme
#define lstrlenW
Definition: compat.h:407
int32_t INT
Definition: typedefs.h:56
static const WCHAR * g_RegColorNames[NUM_COLORS]
Definition: theme.c:26
#define GetGValue(rgb)
Definition: wingdi.h:2914
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
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
static const WCHAR g_CPANewSchemes[]
Definition: theme.c:19
smooth NULL
Definition: ftsmooth.c:416
_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:426
#define IntToPtr(i)
Definition: basetsd.h:89
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:4895
BOOL WINAPI SystemParametersInfoW(_In_ UINT, _In_ UINT, _Inout_opt_ PVOID, _In_ UINT)
__wchar_t WCHAR
Definition: xmlstorage.h:180
BOOL WINAPI InvalidateRect(_In_opt_ HWND, _In_opt_ LPCRECT, _In_ BOOL)
static const WCHAR L[]
Definition: oid.c:1250
unsigned char BYTE
Definition: mem.h:68
LONG WINAPI RegCreateKeyW(HKEY hKey, LPCWSTR lpSubKey, PHKEY phkResult)
Definition: reg.c:1199
BOOL WINAPI SetSysColors(_In_ int cElements, _In_reads_(cElements) CONST INT *lpaElements, _In_reads_(cElements) CONST COLORREF *lpaRgbValues)
static const WCHAR g_CPColors[]
Definition: theme.c:18
#define SPIF_UPDATEINIFILE
Definition: winuser.h:1553
#define lstrlen
Definition: winbase.h:3690
#define SPIF_SENDCHANGE
Definition: winuser.h:1554
#define GetBValue(rgb)
Definition: wingdi.h:2915
#define SYS_CONFIG(__uiAction, __uiParam, __pvParam)
#define wsprintf
Definition: winuser.h:5731
static const WCHAR g_SelectedStyle[]
Definition: theme.c:21
#define REG_SZ
Definition: layer.c:22

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 }
PWSTR StyleName
Definition: appearance.h:83
#define free
Definition: debug_ros.c:5
struct _THEME_STYLE * NextStyle
Definition: appearance.h:81
PWSTR DisplayName
Definition: appearance.h:84
static void CleanupStyles(IN PTHEME_STYLE pStylesList)
Definition: theme.c:509
struct _THEME_STYLE * ChildStyle
Definition: appearance.h:82

Referenced by 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 }
#define free
Definition: debug_ros.c:5
THEME_STYLE * SizesList
Definition: appearance.h:93
PWSTR DisplayName
Definition: appearance.h:91
static void CleanupStyles(IN PTHEME_STYLE pStylesList)
Definition: theme.c:509
THEME_STYLE * ColoursList
Definition: appearance.h:92
struct _THEME * NextTheme
Definition: appearance.h:89
PWSTR ThemeFileName
Definition: appearance.h:90

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 }
PWSTR StyleName
Definition: appearance.h:83
#define free
Definition: debug_ros.c:5
struct _THEME_STYLE * NextStyle
Definition: appearance.h:81
PWSTR DisplayName
Definition: appearance.h:84
struct _THEME_STYLE * PTHEME_STYLE
smooth NULL
Definition: ftsmooth.c:416
struct _THEME_STYLE * ChildStyle
Definition: appearance.h:82
#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 }
#define free
Definition: debug_ros.c:5
THEME_STYLE * SizesList
Definition: appearance.h:93
PWSTR DisplayName
Definition: appearance.h:91
smooth NULL
Definition: ftsmooth.c:416
THEME_STYLE * ColoursList
Definition: appearance.h:92
struct _THEME * NextTheme
Definition: appearance.h:89
#define malloc
Definition: debug_ros.c:4
_Check_return_ _CRTIMP wchar_t *__cdecl _wcsdup(_In_z_ const wchar_t *_Str)
struct _THEME * PTHEME
PWSTR ThemeFileName
Definition: appearance.h:90

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;
993  HRESULT hres;
994 
995  hbrBack = CreateSolidBrush(scheme->crColor[COLOR_DESKTOP]);
996 
997  FillRect(hdcMem, prcWindow, hbrBack);
998  DeleteObject(hbrBack);
999 
1000  InflateRect(prcWindow, -10, -10);
1001 
1003  DNCP_DRAW_ALL,
1004  prcWindow,
1005  pSelectedTheme->Theme->ThemeFileName,
1006  pSelectedTheme->Color->StyleName,
1007  pSelectedTheme->Size->StyleName,
1008  &scheme->ncMetrics,
1009  scheme->crColor);
1010 
1011  return SUCCEEDED(hres);
1012 }
BOOL WINAPI InflateRect(_Inout_ LPRECT, _In_ int, _In_ int)
DWORD scheme
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
#define COLOR_DESKTOP
Definition: winuser.h:904
#define DNCP_DRAW_ALL
Definition: uxundoc.h:106
HRESULT hres
Definition: protocol.c:465
LONG HRESULT
Definition: typedefs.h:77
HBRUSH WINAPI CreateSolidBrush(_In_ COLORREF)
HRESULT WINAPI DrawNCPreview(HDC hDC, DWORD DNCP_Flag, LPRECT prcPreview, LPCWSTR pszThemeFileName, LPCWSTR pszColorName, LPCWSTR pszSizeName, PNONCLIENTMETRICSW pncMetrics, COLORREF *lpaRgbValues)
Definition: nonclient.c:1069
int WINAPI FillRect(HDC, LPCRECT, HBRUSH)
HDC hdcMem
Definition: welcome.c:104
#define SUCCEEDED(hr)
Definition: intsafe.h:57

◆ 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 }
#define TRUE
Definition: types.h:120
smooth NULL
Definition: ftsmooth.c:416
LIST_ENTRY List
Definition: psmgr.c:57
struct _THEME * NextTheme
Definition: appearance.h:89
PTHEME LoadTheme(IN LPCWSTR pszThemeFileName, IN LPCWSTR pszThemeName)
Definition: theme.c:707

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 }
GLuint GLuint * names
Definition: glext.h:11545
smooth NULL
Definition: ftsmooth.c:416
GLuint index
Definition: glext.h:6031
LIST_ENTRY List
Definition: psmgr.c:57
unsigned long DWORD
Definition: ntddk_ex.h:95
static PTHEME_STYLE CreateStyle(LPCWSTR pszName, LPCWSTR pszDisplayName)
Definition: theme.c:480
#define SUCCEEDED(hr)
Definition: intsafe.h:57

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 }
#define TRUE
Definition: types.h:120
#define ZeroMemory
Definition: winbase.h:1635
THEME_STYLE * SizesList
Definition: appearance.h:93
smooth NULL
Definition: ftsmooth.c:416
THEME_STYLE * ColoursList
Definition: appearance.h:92
struct _THEME * NextTheme
Definition: appearance.h:89
static PTHEME_STYLE FindStyle(IN PTHEME_STYLE pStylesList, IN PCWSTR StyleName)
Definition: theme.c:546
PTHEME LoadTheme(IN LPCWSTR pszThemeFileName, IN LPCWSTR pszThemeName)
Definition: theme.c:707
_Check_return_ _CRTIMP int __cdecl _wcsicmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)
PWSTR ThemeFileName
Definition: appearance.h:90

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 }
PWSTR StyleName
Definition: appearance.h:83
struct _THEME_STYLE * NextStyle
Definition: appearance.h:81
_Check_return_ _CRTIMP int __cdecl _wcsicmp(_In_z_ const wchar_t *_Str1, _In_z_ const wchar_t *_Str2)

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 }
#define RegQueryValueEx
Definition: winreg.h:524
#define TRUE
Definition: types.h:120
#define ERROR_SUCCESS
Definition: deptool.c:10
#define HKEY_CURRENT_USER
Definition: winreg.h:11
#define ZeroMemory
Definition: winbase.h:1635
int32_t INT
Definition: typedefs.h:56
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
unsigned char * LPBYTE
Definition: typedefs.h:52
LONG WINAPI RegOpenKeyW(HKEY hKey, LPCWSTR lpSubKey, PHKEY phkResult)
Definition: reg.c:3296
static const WCHAR g_CPANewSchemes[]
Definition: theme.c:19
smooth NULL
Definition: ftsmooth.c:416
_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:426
#define SHGetValue
Definition: shlwapi.h:70
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned long DWORD
Definition: ntddk_ex.h:95
static const WCHAR L[]
Definition: oid.c:1250
struct _THEME_STYLE * ChildStyle
Definition: appearance.h:82
static PTHEME_STYLE FindStyle(IN PTHEME_STYLE pStylesList, IN PCWSTR StyleName)
Definition: theme.c:546
#define REG_SZ
Definition: layer.c:22

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 }
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:77
BOOL FindOrAppendTheme(IN PTHEME pThemeList, IN LPCWSTR pwszThemeFileName, IN LPCWSTR pwszColorBuff, IN LPCWSTR pwszSizeBuff, OUT PTHEME_SELECTION pSelectedTheme)
Definition: theme.c:791
#define MAX_PATH
Definition: compat.h:26
HRESULT WINAPI GetCurrentThemeName(LPWSTR pszThemeFileName, int dwMaxNameChars, LPWSTR pszColorBuff, int cchMaxColorChars, LPWSTR pszSizeBuff, int cchMaxSizeChars)
Definition: system.c:894

◆ 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 }
static PTHEME_STYLE LoadSchemeSizes(IN HKEY hkScheme)
Definition: theme.c:566
#define ERROR_SUCCESS
Definition: deptool.c:10
#define HKEY_CURRENT_USER
Definition: winreg.h:11
int32_t INT
Definition: typedefs.h:56
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
LONG WINAPI RegOpenKeyW(HKEY hKey, LPCWSTR lpSubKey, PHKEY phkResult)
Definition: reg.c:3296
static const WCHAR g_CPANewSchemes[]
Definition: theme.c:19
smooth NULL
Definition: ftsmooth.c:416
_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:426
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
LIST_ENTRY List
Definition: psmgr.c:57
__wchar_t WCHAR
Definition: xmlstorage.h:180
static void CleanupStyles(IN PTHEME_STYLE pStylesList)
Definition: theme.c:509
static const WCHAR L[]
Definition: oid.c:1250
LONG WINAPI RegEnumKeyW(HKEY hKey, DWORD dwIndex, LPWSTR lpName, DWORD cbName)
Definition: reg.c:2416
static PTHEME_STYLE CreateStyle(LPCWSTR pszName, LPCWSTR pszDisplayName)
Definition: theme.c:480

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);
233  RegCloseKey(hKey);
234  }
235 
236  return TRUE;
237 }
#define TRUE
Definition: types.h:120
ULONG dwMajorVersion
Definition: rtltypes.h:234
#define ERROR_SUCCESS
Definition: deptool.c:10
OSVERSIONINFO osvi
Definition: ver.c:28
#define HKEY_CURRENT_USER
Definition: winreg.h:11
#define NUM_COLORS
Definition: appearance.h:28
DWORD scheme
int32_t INT
Definition: typedefs.h:56
DWORD WINAPI GetSysColor(_In_ int)
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
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
unsigned int BOOL
Definition: ntddk_ex.h:94
LONG WINAPI RegOpenKeyW(HKEY hKey, LPCWSTR lpSubKey, PHKEY phkResult)
Definition: reg.c:3296
_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:426
BOOL WINAPI SystemParametersInfoW(_In_ UINT, _In_ UINT, _Inout_opt_ PVOID, _In_ UINT)
DWORD COLORREF
Definition: windef.h:285
int ret
static const WCHAR L[]
Definition: oid.c:1250
int WINAPI SHRegGetIntW(HKEY hKey, LPCWSTR lpszValue, int iDefault)
Definition: reg.c:2374
#define GetVersionEx
Definition: winbase.h:3666
static const WCHAR g_CPMetrics[]
Definition: theme.c:20

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 }
#define TRUE
Definition: types.h:120
#define ERROR_SUCCESS
Definition: deptool.c:10
#define NUM_SIZES
Definition: appearance.h:27
#define REG_BINARY
Definition: nt_native.h:1496
#define HKEY_CURRENT_USER
Definition: winreg.h:11
LOGFONTA LOGFONT
Definition: wingdi.h:4393
#define NUM_COLORS
Definition: appearance.h:28
DWORD scheme
int32_t INT
Definition: typedefs.h:56
DWORD WINAPI GetSysColor(_In_ int)
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
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
unsigned char * LPBYTE
Definition: typedefs.h:52
unsigned int BOOL
Definition: ntddk_ex.h:94
long LONG
Definition: pedump.c:60
LONG WINAPI RegOpenKeyW(HKEY hKey, LPCWSTR lpSubKey, PHKEY phkResult)
Definition: reg.c:3296
static const WCHAR g_CPANewSchemes[]
Definition: theme.c:19
smooth NULL
Definition: ftsmooth.c:416
VOID SchemeSetMetric(IN COLOR_SCHEME *scheme, int id, int value)
Definition: theme.c:63
LONG WINAPI RegQueryValueExW(_In_ HKEY hkeyorg, _In_ LPCWSTR name, _In_ LPDWORD reserved, _In_ LPDWORD type, _In_ LPBYTE data, _In_ LPDWORD count)
Definition: reg.c:4116
__wchar_t WCHAR
Definition: xmlstorage.h:180
static DWORD DWORD * dwLength
Definition: fusion.c:83
DWORD COLORREF
Definition: windef.h:285
#define MAX_PATH
Definition: compat.h:26
unsigned long DWORD
Definition: ntddk_ex.h:95
static const WCHAR L[]
Definition: oid.c:1250
int WINAPI SHRegGetIntW(HKEY hKey, LPCWSTR lpszValue, int iDefault)
Definition: reg.c:2374
PLOGFONTW SchemeGetFont(IN COLOR_SCHEME *scheme, int id)
Definition: theme.c:104
#define REG_QWORD
Definition: sdbapi.c:597
#define NUM_FONTS
Definition: appearance.h:26
unsigned long long UINT64
#define wsprintf
Definition: winuser.h:5731
GLuint64EXT * result
Definition: glext.h:11304
#define REG_DWORD
Definition: sdbapi.c:596

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 }
int WINAPI GetThemeSysSize(HTHEME hTheme, int iSizeID)
Definition: metric.c:154
HWND hCPLWindow
Definition: access.c:18
#define SM_CYHSCROLL
Definition: winuser.h:952
#define TRUE
Definition: types.h:120
#define SM_CYSIZE
Definition: winuser.h:982
#define SM_CYMENUSIZE
Definition: winuser.h:1008
#define NUM_COLORS
Definition: appearance.h:28
DWORD scheme
static HTHEME(WINAPI *pOpenThemeDataEx)(HWND
#define TMT_MENUFONT
Definition: vssym32.h:166
#define SM_CXFRAME
Definition: winuser.h:984
#define TMT_MSGBOXFONT
Definition: vssym32.h:168
#define TMT_CAPTIONFONT
Definition: vssym32.h:164
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 TMT_ICONTITLEFONT
Definition: vssym32.h:169
HRESULT WINAPI GetThemeSysFont(HTHEME hTheme, int iFontID, LOGFONTW *plf)
Definition: metric.c:91
smooth NULL
Definition: ftsmooth.c:416
#define SM_CYSMSIZE
Definition: winuser.h:1006
LONG HRESULT
Definition: typedefs.h:77
#define SM_CXSMSIZE
Definition: winuser.h:1005
static const WCHAR L[]
Definition: oid.c:1250
COLORREF WINAPI GetThemeSysColor(HTHEME hTheme, int iColorID)
Definition: metric.c:58
HRESULT WINAPI OpenThemeFile(LPCWSTR pszThemeFileName, LPCWSTR pszColorName, LPCWSTR pszSizeName, HTHEMEFILE *hThemeFile, DWORD unknown)
Definition: system.c:1101
#define SM_CXVSCROLL
Definition: winuser.h:951
#define TMT_FLATMENUS
Definition: vssym32.h:175
#define SM_CXSIZE
Definition: winuser.h:981
#define TMT_SMALLCAPTIONFONT
Definition: vssym32.h:165
HTHEME WINAPI OpenThemeDataFromFile(HTHEMEFILE hThemeFile, HWND hwnd, LPCWSTR pszClassList, DWORD flags)
Definition: system.c:827
BOOL WINAPI GetThemeSysBool(HTHEME hTheme, int iBoolID)
Definition: metric.c:26
HRESULT WINAPI CloseThemeData(HTHEME hTheme)
Definition: system.c:950
#define SUCCEEDED(hr)
Definition: intsafe.h:57
#define TMT_STATUSFONT
Definition: vssym32.h:167
#define SM_CXMENUSIZE
Definition: winuser.h:1007

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 }
#define ERROR_SUCCESS
Definition: deptool.c:10
int32_t INT
Definition: typedefs.h:56
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
LONG WINAPI RegOpenKeyW(HKEY hKey, LPCWSTR lpSubKey, PHKEY phkResult)
Definition: reg.c:3296
smooth NULL
Definition: ftsmooth.c:416
_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:426
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
LIST_ENTRY List
Definition: psmgr.c:57
__wchar_t WCHAR
Definition: xmlstorage.h:180
static const WCHAR L[]
Definition: oid.c:1250
LONG WINAPI RegEnumKeyW(HKEY hKey, DWORD dwIndex, LPWSTR lpName, DWORD cbName)
Definition: reg.c:2416
static PTHEME_STYLE CreateStyle(LPCWSTR pszName, LPCWSTR pszDisplayName)
Definition: theme.c:480

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 * CreateTheme(LPCWSTR pszName, LPCWSTR pszDisplayName)
Definition: theme.c:444
void CleanupThemes(IN PTHEME pThemeList)
Definition: theme.c:527
THEME_STYLE * SizesList
Definition: appearance.h:93
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
smooth NULL
Definition: ftsmooth.c:416
HRESULT WINAPI EnumThemeColors(LPWSTR pszThemeFileName, LPWSTR pszSizeName, DWORD dwColorNum, PTHEMENAMES pszColorNames)
Definition: system.c:1310
THEME_STYLE * ColoursList
Definition: appearance.h:92
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));
766  hret = SHGetFolderPathW (NULL, CSIDL_RESOURCES, NULL, SHGFP_TYPE_DEFAULT, 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 }
static THEME * CreateTheme(LPCWSTR pszName, LPCWSTR pszDisplayName)
Definition: theme.c:444
#define free
Definition: debug_ros.c:5
#define ZeroMemory
Definition: winbase.h:1635
HINSTANCE hApplet
Definition: access.c:17
PWSTR DisplayName
Definition: appearance.h:91
static THEME_STYLE * LoadClassicColorSchemes(VOID)
Definition: theme.c:625
smooth NULL
Definition: ftsmooth.c:416
#define IDS_CLASSIC_THEME
Definition: resource.h:100
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:77
#define MAX_PATH
Definition: compat.h:26
static const WCHAR L[]
Definition: oid.c:1250
THEME_STYLE * ColoursList
Definition: appearance.h:92
struct _THEME * NextTheme
Definition: appearance.h:89
#define CSIDL_RESOURCES
Definition: shlobj.h:2055
HRESULT WINAPI SHGetFolderPathW(HWND hwndOwner, int nFolder, HANDLE hToken, DWORD dwFlags, LPWSTR pszPath)
Definition: shellpath.c:2085
GLuint res
Definition: glext.h:9613
LPWSTR WINAPI lstrcatW(LPWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:274
HRESULT WINAPI EnumThemes(LPCWSTR pszThemePath, ENUMTHEMEPROC callback, LPVOID lpData)
Definition: system.c:1221
#define LoadString
Definition: winuser.h:5685
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

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 }
DWORD scheme
#define FONT_STATUS
Definition: appearance.h:21
#define FONT_SMCAPTION
Definition: appearance.h:19
smooth NULL
Definition: ftsmooth.c:416
#define FONT_ICON
Definition: appearance.h:23
#define FONT_CAPTION
Definition: appearance.h:18
#define FONT_MENU
Definition: appearance.h:20
#define FONT_MESSAGE
Definition: appearance.h:22

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_SM_CAPTION_HEIGHT
Definition: appearance.h:10
#define SIZE_CAPTION_HEIGHT
Definition: appearance.h:8
#define SIZE_SM_CAPTION_WIDTH
Definition: appearance.h:9
DWORD scheme
#define SIZE_CAPTION_WIDTH
Definition: appearance.h:7
#define SIZE_ICON
Definition: appearance.h:16
#define SIZE_SCROLL_HEIGHT
Definition: appearance.h:6
#define SIZE_ICON_SPACE_X
Definition: appearance.h:14
#define SIZE_MENU_HEIGHT
Definition: appearance.h:12
#define SIZE_BORDER_WIDTH
Definition: appearance.h:4
#define SIZE_ICON_SPACE_Y
Definition: appearance.h:15
#define SIZE_SCROLL_WIDTH
Definition: appearance.h:5

◆ 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 }
#define SIZE_MENU_WIDTH
Definition: appearance.h:11
#define SIZE_SM_CAPTION_HEIGHT
Definition: appearance.h:10
#define SIZE_CAPTION_HEIGHT
Definition: appearance.h:8
#define SIZE_SM_CAPTION_WIDTH
Definition: appearance.h:9
DWORD scheme
#define SIZE_CAPTION_WIDTH
Definition: appearance.h:7
#define SIZE_ICON
Definition: appearance.h:16
#define SIZE_SCROLL_HEIGHT
Definition: appearance.h:6
#define SIZE_ICON_SPACE_X
Definition: appearance.h:14
#define SIZE_MENU_HEIGHT
Definition: appearance.h:12
GLsizei const GLfloat * value
Definition: glext.h:6069
#define SIZE_BORDER_WIDTH
Definition: appearance.h:4
#define SIZE_ICON_SPACE_Y
Definition: appearance.h:15
#define SIZE_SCROLL_WIDTH
Definition: appearance.h:5

Referenced by LoadSchemeFromReg().

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().