Author: gadamopoulos
Date: Mon May 8 18:45:35 2017
New Revision: 74506
URL:
http://svn.reactos.org/svn/reactos?rev=74506&view=rev
Log:
[DESK.CPL] -Implement opening msstyles files.
Modified:
trunk/reactos/dll/cpl/desk/appearance.c
trunk/reactos/dll/cpl/desk/appearance.h
trunk/reactos/dll/cpl/desk/desk.c
trunk/reactos/dll/cpl/desk/desk.h
trunk/reactos/dll/cpl/desk/theme.c
Modified: trunk/reactos/dll/cpl/desk/appearance.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/cpl/desk/appearance.c?…
==============================================================================
--- trunk/reactos/dll/cpl/desk/appearance.c [iso-8859-1] (original)
+++ trunk/reactos/dll/cpl/desk/appearance.c [iso-8859-1] Mon May 8 18:45:35 2017
@@ -117,8 +117,48 @@
g->pThemes = LoadThemes();
if (g->pThemes)
{
- if (!GetActiveTheme(g->pThemes, &g->ActiveTheme))
- g->ActiveTheme.ThemeActive = FALSE;
+ PTHEME pLoadedTheme = NULL;
+
+ 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;
+ }
+ }
+
+ if (pLoadedTheme)
+ {
+ g->ActiveTheme.ThemeActive = TRUE;
+ g->ActiveTheme.Theme = pLoadedTheme;
+ g->ActiveTheme.Color = pLoadedTheme->ColoursList;
+ g->ActiveTheme.Size = pLoadedTheme->SizesList;
+ }
+ else
+ {
+ if (!GetActiveTheme(g->pThemes, &g->ActiveTheme))
+ {
+ g->ActiveTheme.ThemeActive = FALSE;
+ }
+ }
/*
* Keep a copy of the selected classic theme in order to select this
Modified: trunk/reactos/dll/cpl/desk/appearance.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/cpl/desk/appearance.h?…
==============================================================================
--- trunk/reactos/dll/cpl/desk/appearance.h [iso-8859-1] (original)
+++ trunk/reactos/dll/cpl/desk/appearance.h [iso-8859-1] Mon May 8 18:45:35 2017
@@ -135,6 +135,7 @@
VOID SchemeSetMetric(COLOR_SCHEME *scheme, int id, int value);
int SchemeGetMetric(COLOR_SCHEME *scheme, int id);
PLOGFONTW SchemeGetFont(COLOR_SCHEME *scheme, int id);
+PTHEME LoadTheme(IN LPCWSTR pszThemeFileName,IN LPCWSTR pszThemeName);
PTHEME LoadThemes(VOID);
BOOL GetActiveTheme(PTHEME pThemeList, PTHEME_SELECTION pSelectedTheme);
BOOL GetActiveClassicTheme(PTHEME pThemeList, PTHEME_SELECTION pSelectedTheme);
Modified: trunk/reactos/dll/cpl/desk/desk.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/cpl/desk/desk.c?rev=74…
==============================================================================
--- trunk/reactos/dll/cpl/desk/desk.c [iso-8859-1] (original)
+++ trunk/reactos/dll/cpl/desk/desk.c [iso-8859-1] Mon May 8 18:45:35 2017
@@ -8,7 +8,7 @@
*/
#include "desk.h"
-
+#include <Shellapi.h>
#include <cplext.h>
#include <debug.h>
@@ -109,12 +109,13 @@
WORD idDlg;
DLGPROC DlgProc;
LPFNPSPCALLBACK Callback;
+ LPWSTR Name;
} PropPages[] =
{
- { IDD_BACKGROUND, BackgroundPageProc, NULL },
- { IDD_SCREENSAVER, ScreenSaverPageProc, NULL },
- { IDD_APPEARANCE, AppearancePageProc, NULL },
- { IDD_SETTINGS, SettingsPageProc, SettingsPageCallbackProc },
+ { IDD_BACKGROUND, BackgroundPageProc, NULL, L"Desktop" },
+ { IDD_SCREENSAVER, ScreenSaverPageProc, NULL, L"Screen Saver" },
+ { IDD_APPEARANCE, AppearancePageProc, NULL, L"Appearance" },
+ { IDD_SETTINGS, SettingsPageProc, SettingsPageCallbackProc, L"Settings" },
};
/* Display Applet */
@@ -127,12 +128,51 @@
TCHAR Caption[1024];
LONG ret;
UINT i;
-
- UNREFERENCED_PARAMETER(lParam);
+ LPWSTR *argv = NULL;
+ LPCWSTR pwszSelectedTab = NULL;
+ LPCWSTR pwszFile = NULL;
+ LPCWSTR pwszAction = NULL;
+
UNREFERENCED_PARAMETER(wParam);
- UNREFERENCED_PARAMETER(uMsg);
- UNREFERENCED_PARAMETER(hwnd);
-
+
+ hCPLWindow = hwnd;
+
+ if (uMsg == CPL_STARTWPARMSW && lParam)
+ {
+ int argc;
+ int i;
+ LPCWSTR pszCommandLine = (LPCWSTR)lParam;
+
+ argv = CommandLineToArgvW(pszCommandLine, &argc);
+
+ if (argv && argc)
+ {
+ for (i = 0; i<argc; i++)
+ {
+ if (argv[i][0] == L'@')
+ pwszSelectedTab = &argv[i][1];
+ else if (wcsncmp(argv[i], L"/Action:", 8) == 0)
+ pwszAction = &argv[i][8];
+ else if (wcsncmp(argv[i], L"/file:", 6) == 0)
+ pwszFile = &argv[i][6];
+ }
+ }
+
+ /* HACK: shell32 doesn't give the correct params to CPL_STARTWPARMSW so we
need to ... improvise */
+ if (wcsncmp(pszCommandLine, L"/file:", 6) == 0)
+ {
+ LPCWSTR pwszType = wcsrchr(pszCommandLine, L'.');
+ if (pwszType && wcsicmp(pwszType, L".msstyles") == 0)
+ {
+ pwszFile = &pszCommandLine[6];
+ pwszSelectedTab = L"Appearance";
+ pwszAction = L"OpenMSTheme";
+ }
+ }
+ }
+
+ g_GlobalData.pwszFile = pwszFile;
+ g_GlobalData.pwszAction = pwszAction;
g_GlobalData.desktop_color = GetSysColor(COLOR_DESKTOP);
LoadString(hApplet, IDS_CPLNAME, Caption, sizeof(Caption) / sizeof(TCHAR));
@@ -153,6 +193,9 @@
for (i = 0; i != sizeof(PropPages) / sizeof(PropPages[0]); i++)
{
+ if (pwszSelectedTab && wcsicmp(pwszSelectedTab, PropPages[i].Name) == 0)
+ psh.nStartPage = i;
+
/* Override the background page if requested by a shell extension */
if (PropPages[i].idDlg == IDD_BACKGROUND && hpsxa != NULL &&
SHReplaceFromPropSheetExtArray(hpsxa, CPLPAGE_DISPLAY_BACKGROUND,
PropSheetAddPage, (LPARAM)&psh) != 0)
@@ -173,7 +216,10 @@
if (hpsxa != NULL)
SHDestroyPropSheetExtArray(hpsxa);
- return ret;
+ if (argv)
+ LocalFree(argv);
+
+ return TRUE;
}
@@ -202,9 +248,10 @@
break;
case CPL_DBLCLK:
- hCPLWindow = hwndCPl;
Applets[i].AppletProc(hwndCPl, uMsg, lParam1, lParam2);
break;
+ case CPL_STARTWPARMSW:
+ return Applets[i].AppletProc(hwndCPl, uMsg, lParam1, lParam2);
}
return FALSE;
Modified: trunk/reactos/dll/cpl/desk/desk.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/cpl/desk/desk.h?rev=74…
==============================================================================
--- trunk/reactos/dll/cpl/desk/desk.h [iso-8859-1] (original)
+++ trunk/reactos/dll/cpl/desk/desk.h [iso-8859-1] Mon May 8 18:45:35 2017
@@ -104,6 +104,8 @@
typedef struct _GLOBAL_DATA
{
COLORREF desktop_color;
+ LPCWSTR pwszFile;
+ LPCWSTR pwszAction;
} GLOBAL_DATA, *PGLOBAL_DATA;
extern GLOBAL_DATA g_GlobalData;
Modified: trunk/reactos/dll/cpl/desk/theme.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/cpl/desk/theme.c?rev=7…
==============================================================================
--- trunk/reactos/dll/cpl/desk/theme.c [iso-8859-1] (original)
+++ trunk/reactos/dll/cpl/desk/theme.c [iso-8859-1] Mon May 8 18:45:35 2017
@@ -704,6 +704,23 @@
return List;
}
+PTHEME LoadTheme(IN LPCWSTR pszThemeFileName,IN LPCWSTR pszThemeName)
+{
+ PTHEME pTheme = CreateTheme(pszThemeFileName, pszThemeName);
+ if (pTheme == NULL)
+ return NULL;
+
+ pTheme->SizesList = EnumThemeStyles( pszThemeFileName,
(ENUMTHEMESTYLE)EnumThemeSizes);
+ pTheme->ColoursList = EnumThemeStyles( pszThemeFileName,
(ENUMTHEMESTYLE)EnumThemeColors);
+ if(pTheme->SizesList == NULL || pTheme->ColoursList == NULL)
+ {
+ CleanupThemes(pTheme);
+ return NULL;
+ }
+
+ return pTheme;
+}
+
BOOL CALLBACK
EnumThemeProc(IN LPVOID lpReserved,
IN LPCWSTR pszThemeFileName,
@@ -715,17 +732,8 @@
PTHEME *List, pTheme;
List = (PTHEME*)lpData;
-
- pTheme = CreateTheme(pszThemeFileName, pszThemeName);
+ pTheme = LoadTheme(pszThemeFileName, pszThemeName);
if (pTheme == NULL) return FALSE;
-
- pTheme->SizesList = EnumThemeStyles( pszThemeFileName,
(ENUMTHEMESTYLE)EnumThemeSizes);
- pTheme->ColoursList = EnumThemeStyles( pszThemeFileName,
(ENUMTHEMESTYLE)EnumThemeColors);
- if(pTheme->SizesList == NULL || pTheme->ColoursList == NULL)
- {
- CleanupThemes(pTheme);
- return FALSE;
- }
pTheme->NextTheme = *List;
*List = pTheme;