g->pThemes = LoadThemes();
if (g->pThemes)
{
- PTHEME pLoadedTheme = NULL;
-
+ BOOL bLoadedTheme = FALSE;
+
if (g_GlobalData.pwszAction &&
g_GlobalData.pwszFile &&
wcscmp(g_GlobalData.pwszAction, L"OpenMSTheme") == 0)
{
- /* Check if the theme specified was already loaded */
- for (pTheme = g->pThemes; pTheme; pTheme = pTheme->NextTheme)
- {
- if (pTheme->ThemeFileName && wcsicmp(pTheme->ThemeFileName, g_GlobalData.pwszFile) == 0)
- {
- pLoadedTheme = pTheme;
- break;
- }
-
- if (!pTheme->NextTheme)
- break;
- }
-
- if (!pLoadedTheme)
- {
- /* Load it now and insert it in the list */
- pLoadedTheme = LoadTheme(g_GlobalData.pwszFile, g_GlobalData.pwszFile);
- if (pLoadedTheme)
- pTheme->NextTheme = pLoadedTheme;
- }
+ bLoadedTheme = FindOrAppendTheme(g->pThemes,
+ g_GlobalData.pwszFile,
+ NULL,
+ NULL,
+ &g->ActiveTheme);
}
- if (pLoadedTheme)
+ if (bLoadedTheme)
{
- g->ActiveTheme.ThemeActive = TRUE;
- g->ActiveTheme.Theme = pLoadedTheme;
- g->ActiveTheme.Color = pLoadedTheme->ColoursList;
- g->ActiveTheme.Size = pLoadedTheme->SizesList;
+ g->bThemeChanged = TRUE;
+ g->bSchemeChanged = TRUE;
+
+ PostMessageW(GetParent(hwndDlg), PSM_CHANGED, (WPARAM)hwndDlg, 0);
+
+ AppearancePage_LoadSelectedScheme(hwndDlg, g);
}
else
{
}
/*
- * GetActiveTheme: Gets the active theme and populates pSelectedTheme
- * with entries from the list of loaded themes
+ * FindSelectedTheme: Finds the specified theme in the list of themes
+ * or loads it if it was not loaded already.
*/
BOOL
-GetActiveTheme(IN PTHEME pThemeList, OUT PTHEME_SELECTION pSelectedTheme)
+FindOrAppendTheme(IN PTHEME pThemeList,
+ IN LPCWSTR pwszThemeFileName,
+ IN LPCWSTR pwszColorBuff,
+ IN LPCWSTR pwszSizeBuff,
+ OUT PTHEME_SELECTION pSelectedTheme)
{
- WCHAR szThemeFileName[MAX_PATH];
- WCHAR szColorBuff[MAX_PATH];
- WCHAR szSizeBuff[MAX_PATH];
PTHEME pTheme;
- HRESULT hret;
+ PTHEME pFoundTheme = NULL;
ZeroMemory(pSelectedTheme, sizeof(THEME_SELECTION));
- /* Retrieve the name of the current theme */
- hret = GetCurrentThemeName(szThemeFileName,
- MAX_PATH,
- szColorBuff,
- MAX_PATH,
- szSizeBuff,
- MAX_PATH);
- if (FAILED(hret)) return FALSE;
-
for (pTheme = pThemeList; pTheme; pTheme = pTheme->NextTheme)
{
if (pTheme->ThemeFileName &&
- _wcsicmp(pTheme->ThemeFileName, szThemeFileName) == 0)
+ _wcsicmp(pTheme->ThemeFileName, pwszThemeFileName) == 0)
{
+ pFoundTheme = pTheme;
break;
}
+
+ if (pTheme->NextTheme == NULL)
+ break;
}
- if (pTheme == NULL) return FALSE;
+ if (!pFoundTheme)
+ {
+ pFoundTheme = LoadTheme(pwszThemeFileName, pwszThemeFileName);
+ if (!pFoundTheme)
+ return FALSE;
+
+ pTheme->NextTheme = pFoundTheme;
+ }
pSelectedTheme->ThemeActive = TRUE;
- pSelectedTheme->Theme = pTheme;
- pSelectedTheme->Color = FindStyle(pTheme->ColoursList, szColorBuff);
- pSelectedTheme->Size = FindStyle(pTheme->SizesList, szSizeBuff);
+ pSelectedTheme->Theme = pFoundTheme;
+ if (pwszColorBuff)
+ pSelectedTheme->Color = FindStyle(pFoundTheme->ColoursList, pwszColorBuff);
+ else
+ pSelectedTheme->Color = pFoundTheme->ColoursList;
+
+ if (pwszSizeBuff)
+ pSelectedTheme->Size = FindStyle(pFoundTheme->SizesList, pwszSizeBuff);
+ else
+ pSelectedTheme->Size = pFoundTheme->SizesList;
return TRUE;
}
+/*
+ * GetActiveTheme: Gets the active theme and populates pSelectedTheme
+ * with entries from the list of loaded themes.
+ */
+BOOL
+GetActiveTheme(IN PTHEME pThemeList, OUT PTHEME_SELECTION pSelectedTheme)
+{
+ WCHAR szThemeFileName[MAX_PATH];
+ WCHAR szColorBuff[MAX_PATH];
+ WCHAR szSizeBuff[MAX_PATH];
+ HRESULT hret;
+
+ /* Retrieve the name of the current theme */
+ hret = GetCurrentThemeName(szThemeFileName,
+ MAX_PATH,
+ szColorBuff,
+ MAX_PATH,
+ szSizeBuff,
+ MAX_PATH);
+ if (FAILED(hret))
+ return FALSE;
+
+ return FindOrAppendTheme(pThemeList, szThemeFileName, szColorBuff, szSizeBuff, pSelectedTheme);
+}
+
/*
* GetActiveTheme: Gets the active classic theme and populates pSelectedTheme
* with entries from the list of loaded themes