Author: gadamopoulos Date: Fri Aug 4 08:53:06 2017 New Revision: 75476 URL: http://svn.reactos.org/svn/reactos?rev=75476&view=rev Log: [DESK.CPL] -Improve the hack that lets it process arguments by using the process command line instead of the one shell32 gives to the cpl. -Implement a new action called ActivateMSTheme that activates an msstyle file without showing any gui. If no file is passed, the classic theme is activated thus making it possible to switch themes from command line (or any other application may need to switch themes by launching desk.cpl).
Modified: trunk/reactos/dll/cpl/desk/appearance.h trunk/reactos/dll/cpl/desk/desk.c trunk/reactos/dll/cpl/desk/theme.c Modified: trunk/reactos/dll/cpl/desk/appearance.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/cpl/desk/appearance.h?rev=75476&r1=75475&r2=75476&view=diff ============================================================================== --- trunk/reactos/dll/cpl/desk/appearance.h [iso-8859-1] (original) +++ trunk/reactos/dll/cpl/desk/appearance.h [iso-8859-1] Fri Aug 4 08:53:06 2017 @@ -147,6 +147,7 @@ BOOL ActivateTheme(PTHEME_SELECTION pSelectedTheme); void CleanupThemes(IN PTHEME pThemeList); BOOL DrawThemePreview(HDC hdcMem, PCOLOR_SCHEME scheme, PTHEME_SELECTION pSelectedTheme, PRECT prcWindow); +BOOL ActivateThemeFile(LPCWSTR pwszFile); /* prototypes for appearance.c */ INT_PTR CALLBACK AppearancePageProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam); Modified: trunk/reactos/dll/cpl/desk/desk.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/cpl/desk/desk.c?rev=75476&r1=75475&r2=75476&view=diff ============================================================================== --- trunk/reactos/dll/cpl/desk/desk.c [iso-8859-1] (original) +++ trunk/reactos/dll/cpl/desk/desk.c [iso-8859-1] Fri Aug 4 08:53:06 2017 @@ -124,7 +124,7 @@ { HPROPSHEETPAGE hpsp[MAX_DESK_PAGES]; PROPSHEETHEADER psh; - HPSXA hpsxa; + HPSXA hpsxa = NULL; TCHAR Caption[1024]; UINT i; LPWSTR *argv = NULL; @@ -140,36 +140,38 @@ { int argc; int i; - LPCWSTR pszCommandLine = (LPCWSTR)lParam; - - argv = CommandLineToArgvW(pszCommandLine, &argc); + +#if 0 + argv = CommandLineToArgvW((LPCWSTR)lParam, &argc); +#else + argv = CommandLineToArgvW(GetCommandLineW(), &argc); +#endif if (argv && argc) { for (i = 0; i<argc; i++) { +#if 0 if (argv[i][0] == L'@') pwszSelectedTab = &argv[i][1]; +#else + if (wcsncmp(argv[i], L"desk,@", 6) == 0) + pwszSelectedTab = &argv[i][6]; +#endif 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"; - } - } - } - + } + + if(pwszAction && wcsncmp(pwszAction, L"ActivateMSTheme", 15) == 0) + { + ActivateThemeFile(pwszFile); + goto cleanup; + } + g_GlobalData.pwszFile = pwszFile; g_GlobalData.pwszAction = pwszAction; g_GlobalData.desktop_color = GetSysColor(COLOR_DESKTOP); @@ -212,6 +214,7 @@ PropertySheet(&psh); +cleanup: if (hpsxa != NULL) SHDestroyPropSheetExtArray(hpsxa); Modified: trunk/reactos/dll/cpl/desk/theme.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/cpl/desk/theme.c?rev=75476&r1=75475&r2=75476&view=diff ============================================================================== --- trunk/reactos/dll/cpl/desk/theme.c [iso-8859-1] (original) +++ trunk/reactos/dll/cpl/desk/theme.c [iso-8859-1] Fri Aug 4 08:53:06 2017 @@ -1010,3 +1010,51 @@ return SUCCEEDED(hres); } + +BOOL ActivateThemeFile(LPCWSTR pwszFile) +{ + PTHEME pThemes; + THEME_SELECTION selection; + COLOR_SCHEME scheme; + BOOL ret = FALSE; + + pThemes = LoadThemes(); + if (!pThemes) + return FALSE; + + LoadCurrentScheme(&scheme); + + if (pwszFile) + { + ret = FindOrAppendTheme(pThemes, pwszFile, NULL, NULL, &selection); + if (!ret) + goto cleanup; + + ret = LoadSchemeFromTheme(&scheme, &selection); + if (!ret) + goto cleanup; + } + else + { + ret = GetActiveClassicTheme(pThemes, &selection); + if (!ret) + goto cleanup; + + ret = LoadSchemeFromReg(&scheme, &selection); + if (!ret) + goto cleanup; + } + + ret = ActivateTheme(&selection); + if (!ret) + goto cleanup; + + ApplyScheme(&scheme, &selection); + + ret = TRUE; + +cleanup: + CleanupThemes(pThemes); + + return ret; +}