*/
#include "desk.h"
+#include <shellapi.h>
+#include <cplext.h>
+#include <debug.h>
-#define NUM_APPLETS (1)
+#define NUM_APPLETS (1)
static LONG APIENTRY DisplayApplet(HWND hwnd, UINT uMsg, LPARAM wParam, LPARAM lParam);
}
static BOOL CALLBACK
-PropSheetAddPage(HPROPSHEETPAGE hpage, LPARAM lParam)
+DisplayAppletPropSheetAddPage(HPROPSHEETPAGE hpage, LPARAM lParam)
{
PROPSHEETHEADER *ppsh = (PROPSHEETHEADER *)lParam;
if (ppsh != NULL && ppsh->nPages < MAX_DESK_PAGES)
hPage = CreatePropertySheetPage(&psp);
if (hPage != NULL)
{
- return PropSheetAddPage(hPage, (LPARAM)ppsh);
+ return DisplayAppletPropSheetAddPage(hPage, (LPARAM)ppsh);
}
}
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 */
{
HPROPSHEETPAGE hpsp[MAX_DESK_PAGES];
PROPSHEETHEADER psh;
- HPSXA hpsxa;
+ HPSXA hpsxa = NULL;
TCHAR Caption[1024];
- LONG ret;
UINT i;
+ LPWSTR *argv = NULL;
+ LPCWSTR pwszSelectedTab = NULL;
+ LPCWSTR pwszFile = NULL;
+ LPCWSTR pwszAction = NULL;
- UNREFERENCED_PARAMETER(lParam);
UNREFERENCED_PARAMETER(wParam);
- UNREFERENCED_PARAMETER(uMsg);
- UNREFERENCED_PARAMETER(hwnd);
+ hCPLWindow = hwnd;
+
+ if (uMsg == CPL_STARTWPARMSW && lParam)
+ {
+ int argc;
+ int i;
+
+#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];
+ }
+ }
+ }
+
+ 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);
LoadString(hApplet, IDS_CPLNAME, Caption, sizeof(Caption) / sizeof(TCHAR));
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)
+ SHReplaceFromPropSheetExtArray(hpsxa, CPLPAGE_DISPLAY_BACKGROUND, DisplayAppletPropSheetAddPage, (LPARAM)&psh) != 0)
{
/* The shell extension added one or more pages to replace the background page.
Don't create the built-in page anymore! */
/* NOTE: Don't call SHAddFromPropSheetExtArray here because this applet only allows
replacing the background page but not extending the applet by more pages */
- ret = (LONG)(PropertySheet(&psh) != -1);
+ PropertySheet(&psh);
+cleanup:
if (hpsxa != NULL)
SHDestroyPropSheetExtArray(hpsxa);
- return ret;
+ if (argv)
+ LocalFree(argv);
+
+ return TRUE;
}
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;
}
+void
+WINAPI
+InstallScreenSaverW(
+ IN HWND hWindow,
+ IN HANDLE hInstance,
+ IN LPCWSTR pszFile,
+ IN UINT nCmdShow)
+{
+ WCHAR pszSystemDir[MAX_PATH];
+ WCHAR pszDrive[3];
+ WCHAR pszPath[MAX_PATH];
+ WCHAR pszFilename[MAX_PATH];
+ WCHAR pszExt[MAX_PATH];
+ LPWSTR pszOutName;
+ UINT uCompressionType=FILE_COMPRESSION_NONE;
+ DWORD dwSourceSize;
+ DWORD dwTargetSize;
+ DWORD rc;
+
+ if (!pszFile)
+ {
+ DPRINT("InstallScreenSaver() null file\n");
+ SetLastError(ERROR_INVALID_PARAMETER);
+ return;
+ }
+ DPRINT("InstallScreenSaver() Installing screensaver %ls\n", pszFile);
+
+ rc = SetupGetFileCompressionInfoW(pszFile, &pszOutName, &dwSourceSize, &dwTargetSize, &uCompressionType);
+ if (ERROR_SUCCESS != rc)
+ {
+ DPRINT("InstallScreenSaver() SetupGetFileCompressionInfo failed with error 0x%lx\n", rc);
+ SetLastError(rc);
+ return;
+ }
+ if (!GetSystemDirectoryW((LPWSTR)pszSystemDir, sizeof(pszSystemDir)/sizeof(WCHAR)))
+ {
+ MyFree(pszOutName);
+ DPRINT("InstallScreenSaver() GetSystemDirectory failed with error 0x%lx\n", GetLastError());
+ return;
+ }
+ _wsplitpath(pszOutName, pszDrive, pszPath, pszFilename, pszExt);
+ MyFree(pszOutName);
+ StringCbCatW(pszSystemDir, sizeof(pszSystemDir), L"\\");
+ StringCbCatW(pszSystemDir, sizeof(pszSystemDir), pszFilename);
+ StringCbCatW(pszSystemDir, sizeof(pszSystemDir), pszExt);
+ rc = SetupDecompressOrCopyFileW(pszFile, pszSystemDir, &uCompressionType);
+ DPRINT("InstallScreenSaver() Copying to %ls, compression type %d return 0x%lx\n", pszFile, uCompressionType, rc);
+}
+
+void
+WINAPI
+InstallScreenSaverA(
+ IN HWND hWindow,
+ IN HANDLE hInstance,
+ IN LPCSTR pszFile,
+ IN UINT nCmdShow)
+{
+ LPWSTR lpwString;
+
+ if (!pszFile)
+ {
+ DPRINT("InstallScreenSaver() null file\n");
+ SetLastError(ERROR_INVALID_PARAMETER);
+ return;
+ }
+ DPRINT("InstallScreenSaver() Install from file %s\n", pszFile);
+ lpwString = pSetupMultiByteToUnicode(pszFile, 0);
+ if (!lpwString)
+ {
+ DPRINT("InstallScreenSaver() not enough memory to convert string to unicode\n");
+ SetLastError(ERROR_NOT_ENOUGH_MEMORY);
+ return;
+ }
+ InstallScreenSaverW(hWindow, hInstance, lpwString, nCmdShow);
+ MyFree(lpwString);
+}
BOOL WINAPI
DllMain(HINSTANCE hInstDLL, DWORD dwReason, LPVOID lpvReserved)