2007-10-19 23:21:45 +00:00
|
|
|
/*
|
2005-02-04 20:39:10 +00:00
|
|
|
* COPYRIGHT: See COPYING in the top level directory
|
|
|
|
* PROJECT: ReactOS Display Control Panel
|
2007-04-13 04:23:35 +00:00
|
|
|
* FILE: dll/cpl/desk/screensaver.c
|
2005-02-04 20:39:10 +00:00
|
|
|
* PURPOSE: Screen saver property page
|
2007-10-19 23:21:45 +00:00
|
|
|
*
|
2005-02-04 20:39:10 +00:00
|
|
|
* PROGRAMMERS: Trevor McCort (lycan359@gmail.com)
|
2007-04-13 04:23:35 +00:00
|
|
|
* Ged Murphy (gedmurphy@reactos.org)
|
2005-02-04 20:39:10 +00:00
|
|
|
*/
|
|
|
|
|
2005-04-14 20:23:02 +00:00
|
|
|
#include "desk.h"
|
2006-11-19 21:06:30 +00:00
|
|
|
|
2005-04-14 20:23:02 +00:00
|
|
|
#define MAX_SCREENSAVERS 100
|
|
|
|
|
2022-10-03 14:32:42 +00:00
|
|
|
static const TCHAR szPreviewWndClass[] = TEXT("SSDemoParent");
|
|
|
|
|
2006-11-19 21:06:30 +00:00
|
|
|
typedef struct
|
|
|
|
{
|
2005-04-14 20:23:02 +00:00
|
|
|
BOOL bIsScreenSaver; /* Is this background a wallpaper */
|
|
|
|
TCHAR szFilename[MAX_PATH];
|
|
|
|
TCHAR szDisplayName[256];
|
|
|
|
} ScreenSaverItem;
|
|
|
|
|
|
|
|
|
2010-09-19 11:54:33 +00:00
|
|
|
typedef struct _DATA
|
2006-11-26 12:47:56 +00:00
|
|
|
{
|
2010-10-06 14:13:00 +00:00
|
|
|
ScreenSaverItem ScreenSaverItems[MAX_SCREENSAVERS];
|
2007-04-13 04:23:35 +00:00
|
|
|
PROCESS_INFORMATION PrevWindowPi;
|
2010-10-06 14:13:00 +00:00
|
|
|
int Selection;
|
2022-10-03 14:34:10 +00:00
|
|
|
WNDPROC OldPreviewProc;
|
2010-10-06 14:13:00 +00:00
|
|
|
UINT ScreenSaverCount;
|
2022-10-03 14:32:42 +00:00
|
|
|
HWND ScreenSaverPreviewParent;
|
2010-09-19 11:54:33 +00:00
|
|
|
} DATA, *PDATA;
|
2006-11-26 12:47:56 +00:00
|
|
|
|
2005-04-14 20:23:02 +00:00
|
|
|
|
2007-04-13 04:23:35 +00:00
|
|
|
static LPTSTR
|
|
|
|
GetCurrentScreenSaverValue(LPTSTR lpValue)
|
|
|
|
{
|
|
|
|
HKEY hKey;
|
|
|
|
LPTSTR lpBuf = NULL;
|
|
|
|
DWORD BufSize, Type = REG_SZ;
|
|
|
|
LONG Ret;
|
|
|
|
|
|
|
|
Ret = RegOpenKeyEx(HKEY_CURRENT_USER,
|
|
|
|
_T("Control Panel\\Desktop"),
|
|
|
|
0,
|
|
|
|
KEY_READ,
|
|
|
|
&hKey);
|
|
|
|
if (Ret != ERROR_SUCCESS)
|
|
|
|
return NULL;
|
|
|
|
|
|
|
|
Ret = RegQueryValueEx(hKey,
|
|
|
|
lpValue,
|
|
|
|
0,
|
|
|
|
&Type,
|
|
|
|
NULL,
|
|
|
|
&BufSize);
|
|
|
|
if (Ret == ERROR_SUCCESS)
|
|
|
|
{
|
|
|
|
lpBuf = HeapAlloc(GetProcessHeap(),
|
|
|
|
0,
|
|
|
|
BufSize);
|
|
|
|
if (lpBuf)
|
|
|
|
{
|
2007-10-19 23:21:45 +00:00
|
|
|
Ret = RegQueryValueEx(hKey,
|
2007-04-13 04:23:35 +00:00
|
|
|
lpValue,
|
|
|
|
0,
|
|
|
|
&Type,
|
|
|
|
(LPBYTE)lpBuf,
|
|
|
|
&BufSize);
|
|
|
|
if (Ret != ERROR_SUCCESS)
|
2014-04-06 13:38:06 +00:00
|
|
|
{
|
|
|
|
HeapFree(GetProcessHeap(), 0, lpBuf);
|
2007-04-13 04:23:35 +00:00
|
|
|
lpBuf = NULL;
|
2014-04-06 13:38:06 +00:00
|
|
|
}
|
2007-04-13 04:23:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
RegCloseKey(hKey);
|
2007-10-19 23:21:45 +00:00
|
|
|
|
2007-04-13 04:23:35 +00:00
|
|
|
return lpBuf;
|
|
|
|
}
|
|
|
|
|
2006-11-26 12:47:56 +00:00
|
|
|
|
|
|
|
static VOID
|
2010-09-19 11:54:33 +00:00
|
|
|
SelectionChanged(HWND hwndDlg, PDATA pData)
|
2005-02-04 20:39:10 +00:00
|
|
|
{
|
2007-04-13 04:23:35 +00:00
|
|
|
HWND hwndCombo;
|
2006-11-19 21:06:30 +00:00
|
|
|
BOOL bEnable;
|
2007-04-13 04:23:35 +00:00
|
|
|
INT i;
|
2006-11-19 21:06:30 +00:00
|
|
|
|
2007-04-13 04:23:35 +00:00
|
|
|
hwndCombo = GetDlgItem(hwndDlg, IDC_SCREENS_LIST);
|
2006-11-19 21:06:30 +00:00
|
|
|
|
2007-04-13 04:23:35 +00:00
|
|
|
i = (INT)SendMessage(hwndCombo, CB_GETCURSEL, 0, 0);
|
|
|
|
i = (INT)SendMessage(hwndCombo, CB_GETITEMDATA, i, 0);
|
2006-11-19 21:06:30 +00:00
|
|
|
|
2010-09-19 11:54:33 +00:00
|
|
|
pData->Selection = i;
|
2006-11-19 21:06:30 +00:00
|
|
|
|
2007-04-13 04:23:35 +00:00
|
|
|
bEnable = (i != 0);
|
2006-11-19 21:06:30 +00:00
|
|
|
|
|
|
|
EnableWindow(GetDlgItem(hwndDlg, IDC_SCREENS_SETTINGS), bEnable);
|
|
|
|
EnableWindow(GetDlgItem(hwndDlg, IDC_SCREENS_TESTSC), bEnable);
|
|
|
|
EnableWindow(GetDlgItem(hwndDlg, IDC_SCREENS_USEPASSCHK), bEnable);
|
|
|
|
EnableWindow(GetDlgItem(hwndDlg, IDC_SCREENS_TIMEDELAY), bEnable);
|
|
|
|
EnableWindow(GetDlgItem(hwndDlg, IDC_SCREENS_TIME), bEnable);
|
2007-04-13 04:23:35 +00:00
|
|
|
EnableWindow(GetDlgItem(hwndDlg, IDC_WAITTEXT), bEnable);
|
|
|
|
EnableWindow(GetDlgItem(hwndDlg, IDC_MINTEXT), bEnable);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-10-03 14:34:10 +00:00
|
|
|
LRESULT CALLBACK
|
|
|
|
RedrawSubclassProc(HWND hwndDlg,
|
|
|
|
UINT uMsg,
|
|
|
|
WPARAM wParam,
|
|
|
|
LPARAM lParam)
|
|
|
|
{
|
|
|
|
HWND hwnd;
|
|
|
|
PDATA pData;
|
|
|
|
LRESULT Ret = FALSE;
|
|
|
|
|
|
|
|
pData = (PDATA)GetWindowLongPtr(hwndDlg, GWLP_USERDATA);
|
|
|
|
if (!pData)
|
|
|
|
return Ret;
|
|
|
|
|
|
|
|
Ret = CallWindowProc(pData->OldPreviewProc, hwndDlg, uMsg, wParam, lParam);
|
|
|
|
|
|
|
|
if (uMsg == WM_PAINT)
|
|
|
|
{
|
|
|
|
hwnd = pData->ScreenSaverPreviewParent;
|
|
|
|
if (hwnd)
|
|
|
|
RedrawWindow(hwnd, NULL, NULL, RDW_INVALIDATE | RDW_ERASE | RDW_ALLCHILDREN);
|
|
|
|
}
|
|
|
|
|
|
|
|
return Ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2022-10-03 14:32:42 +00:00
|
|
|
static VOID
|
|
|
|
ShowScreenSaverPreview(IN LPDRAWITEMSTRUCT draw, IN PDATA pData)
|
|
|
|
{
|
|
|
|
HBRUSH hBrush;
|
|
|
|
HDC hDC;
|
|
|
|
HGDIOBJ hOldObj;
|
|
|
|
RECT rcItem = {
|
|
|
|
MONITOR_LEFT,
|
|
|
|
MONITOR_TOP,
|
|
|
|
MONITOR_RIGHT,
|
|
|
|
MONITOR_BOTTOM
|
|
|
|
};
|
|
|
|
|
|
|
|
hDC = CreateCompatibleDC(draw->hDC);
|
|
|
|
hOldObj = SelectObject(hDC, g_GlobalData.hMonitorBitmap);
|
|
|
|
|
|
|
|
if (!IsWindowVisible(pData->ScreenSaverPreviewParent))
|
|
|
|
{
|
|
|
|
/* FIXME: Draw static bitmap inside monitor. */
|
|
|
|
hBrush = CreateSolidBrush(g_GlobalData.desktop_color);
|
|
|
|
FillRect(hDC, &rcItem, hBrush);
|
|
|
|
DeleteObject(hBrush);
|
|
|
|
}
|
|
|
|
|
|
|
|
GdiTransparentBlt(draw->hDC,
|
|
|
|
draw->rcItem.left, draw->rcItem.top,
|
|
|
|
draw->rcItem.right - draw->rcItem.left + 1,
|
|
|
|
draw->rcItem.bottom - draw->rcItem.top + 1,
|
|
|
|
hDC,
|
|
|
|
0, 0,
|
|
|
|
g_GlobalData.bmMonWidth, g_GlobalData.bmMonHeight,
|
|
|
|
MONITOR_ALPHA);
|
|
|
|
|
|
|
|
SelectObject(hDC, hOldObj);
|
|
|
|
DeleteDC(hDC);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-04-13 04:23:35 +00:00
|
|
|
static VOID
|
2010-09-19 11:54:33 +00:00
|
|
|
SetScreenSaverPreviewBox(HWND hwndDlg, PDATA pData)
|
2007-04-13 04:23:35 +00:00
|
|
|
{
|
2022-10-03 14:32:42 +00:00
|
|
|
HWND hPreview = pData->ScreenSaverPreviewParent;
|
2007-04-13 04:23:35 +00:00
|
|
|
STARTUPINFO si;
|
|
|
|
TCHAR szCmdline[2048];
|
|
|
|
|
2011-11-29 14:55:58 +00:00
|
|
|
/* Kill off the previous preview process */
|
2010-09-19 11:54:33 +00:00
|
|
|
if (pData->PrevWindowPi.hProcess)
|
2007-04-13 04:23:35 +00:00
|
|
|
{
|
2010-09-19 11:54:33 +00:00
|
|
|
TerminateProcess(pData->PrevWindowPi.hProcess, 0);
|
|
|
|
CloseHandle(pData->PrevWindowPi.hProcess);
|
|
|
|
CloseHandle(pData->PrevWindowPi.hThread);
|
|
|
|
pData->PrevWindowPi.hThread = pData->PrevWindowPi.hProcess = NULL;
|
2007-04-13 04:23:35 +00:00
|
|
|
}
|
2022-10-03 14:32:42 +00:00
|
|
|
ShowWindow(pData->ScreenSaverPreviewParent, SW_HIDE);
|
2007-04-13 04:23:35 +00:00
|
|
|
|
2010-09-19 11:54:33 +00:00
|
|
|
if (pData->Selection > 0)
|
2007-04-13 04:23:35 +00:00
|
|
|
{
|
2007-10-19 23:21:45 +00:00
|
|
|
_stprintf(szCmdline,
|
2014-08-24 19:32:54 +00:00
|
|
|
_T("%s /p %Iu"),
|
2010-09-19 11:54:33 +00:00
|
|
|
pData->ScreenSaverItems[pData->Selection].szFilename,
|
2014-08-24 17:16:50 +00:00
|
|
|
(ULONG_PTR)hPreview);
|
2007-04-13 04:23:35 +00:00
|
|
|
|
|
|
|
ZeroMemory(&si, sizeof(si));
|
|
|
|
si.cb = sizeof(si);
|
2010-09-19 11:54:33 +00:00
|
|
|
ZeroMemory(&pData->PrevWindowPi, sizeof(pData->PrevWindowPi));
|
2007-04-13 04:23:35 +00:00
|
|
|
|
2022-10-03 14:32:42 +00:00
|
|
|
ShowWindow(pData->ScreenSaverPreviewParent, SW_SHOW);
|
|
|
|
|
2007-10-19 23:21:45 +00:00
|
|
|
if (!CreateProcess(NULL,
|
|
|
|
szCmdline,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
FALSE,
|
|
|
|
0,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
&si,
|
2010-09-19 11:54:33 +00:00
|
|
|
&pData->PrevWindowPi))
|
2007-04-13 04:23:35 +00:00
|
|
|
{
|
2010-09-19 11:54:33 +00:00
|
|
|
pData->PrevWindowPi.hThread = pData->PrevWindowPi.hProcess = NULL;
|
2007-04-13 04:23:35 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static BOOL
|
|
|
|
WaitForSettingsDialog(HWND hwndDlg,
|
|
|
|
HANDLE hProcess)
|
|
|
|
{
|
2010-06-03 18:47:37 +00:00
|
|
|
DWORD dwResult;
|
|
|
|
MSG msg;
|
|
|
|
|
2007-04-13 04:23:35 +00:00
|
|
|
while (TRUE)
|
|
|
|
{
|
2010-06-03 18:47:37 +00:00
|
|
|
dwResult = MsgWaitForMultipleObjects(1,
|
|
|
|
&hProcess,
|
|
|
|
FALSE,
|
|
|
|
INFINITE,
|
|
|
|
QS_ALLINPUT);
|
|
|
|
if (dwResult == WAIT_OBJECT_0 + 1)
|
2007-10-19 23:21:45 +00:00
|
|
|
{
|
2010-06-03 18:47:37 +00:00
|
|
|
if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
|
2007-04-13 04:23:35 +00:00
|
|
|
{
|
2010-06-03 18:47:37 +00:00
|
|
|
if (msg.message == WM_QUIT)
|
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
if (IsDialogMessage(hwndDlg, &msg))
|
|
|
|
{
|
|
|
|
TranslateMessage(&msg);
|
|
|
|
DispatchMessage(&msg);
|
|
|
|
}
|
2007-04-13 04:23:35 +00:00
|
|
|
}
|
2015-03-14 10:10:06 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
2007-04-13 04:23:35 +00:00
|
|
|
}
|
2015-03-14 10:10:06 +00:00
|
|
|
else if (dwResult == WAIT_OBJECT_0)
|
2007-04-13 04:23:35 +00:00
|
|
|
{
|
|
|
|
return TRUE;
|
2007-10-19 23:21:45 +00:00
|
|
|
}
|
2015-03-14 10:10:06 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
return FALSE;
|
|
|
|
}
|
2007-04-13 04:23:35 +00:00
|
|
|
}
|
2005-04-14 20:23:02 +00:00
|
|
|
}
|
|
|
|
|
2006-11-26 12:47:56 +00:00
|
|
|
|
|
|
|
static VOID
|
2010-09-19 11:54:33 +00:00
|
|
|
ScreensaverConfig(HWND hwndDlg, PDATA pData)
|
2006-04-28 15:34:58 +00:00
|
|
|
{
|
|
|
|
/*
|
2014-08-24 17:16:50 +00:00
|
|
|
* /c:<hwnd> Run configuration, hwnd is handle of calling window
|
|
|
|
*/
|
2006-04-28 15:34:58 +00:00
|
|
|
|
2007-04-13 04:23:35 +00:00
|
|
|
TCHAR szCmdline[2048];
|
2006-04-28 15:34:58 +00:00
|
|
|
STARTUPINFO si;
|
2006-11-19 21:06:30 +00:00
|
|
|
PROCESS_INFORMATION pi;
|
|
|
|
|
2010-09-19 11:54:33 +00:00
|
|
|
if (pData->Selection < 1)
|
2006-11-19 21:06:30 +00:00
|
|
|
return;
|
|
|
|
|
2007-10-19 23:21:45 +00:00
|
|
|
_stprintf(szCmdline,
|
2014-08-24 19:32:54 +00:00
|
|
|
_T("%s /c:%Iu"),
|
2010-09-19 11:54:33 +00:00
|
|
|
pData->ScreenSaverItems[pData->Selection].szFilename,
|
2014-08-24 17:16:50 +00:00
|
|
|
(ULONG_PTR)hwndDlg);
|
2006-04-28 15:34:58 +00:00
|
|
|
|
2006-11-26 12:47:56 +00:00
|
|
|
ZeroMemory(&si, sizeof(si));
|
2006-04-28 15:34:58 +00:00
|
|
|
si.cb = sizeof(si);
|
2006-11-26 12:47:56 +00:00
|
|
|
ZeroMemory(&pi, sizeof(pi));
|
2016-10-26 21:14:39 +00:00
|
|
|
if (CreateProcess(NULL,
|
2007-04-13 04:23:35 +00:00
|
|
|
szCmdline,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
FALSE,
|
|
|
|
0,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
&si,
|
|
|
|
&pi))
|
2006-11-19 21:06:30 +00:00
|
|
|
{
|
2011-11-29 14:55:58 +00:00
|
|
|
/* Kill off the previous preview process */
|
2010-09-19 11:54:33 +00:00
|
|
|
if (pData->PrevWindowPi.hProcess)
|
2007-04-13 04:23:35 +00:00
|
|
|
{
|
2010-09-19 11:54:33 +00:00
|
|
|
TerminateProcess(pData->PrevWindowPi.hProcess, 0);
|
|
|
|
CloseHandle(pData->PrevWindowPi.hProcess);
|
|
|
|
CloseHandle(pData->PrevWindowPi.hThread);
|
|
|
|
pData->PrevWindowPi.hThread = pData->PrevWindowPi.hProcess = NULL;
|
2007-04-13 04:23:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
if (WaitForSettingsDialog(hwndDlg, pi.hProcess))
|
2010-09-19 11:54:33 +00:00
|
|
|
SetScreenSaverPreviewBox(hwndDlg, pData);
|
2006-11-19 21:06:30 +00:00
|
|
|
}
|
2006-04-28 15:34:58 +00:00
|
|
|
}
|
|
|
|
|
2006-11-26 12:47:56 +00:00
|
|
|
|
|
|
|
static VOID
|
2010-09-19 11:54:33 +00:00
|
|
|
ScreensaverPreview(HWND hwndDlg, PDATA pData)
|
2006-04-28 15:34:58 +00:00
|
|
|
{
|
|
|
|
/*
|
|
|
|
/s Run normal
|
|
|
|
*/
|
|
|
|
|
2010-10-06 14:13:00 +00:00
|
|
|
TCHAR szCmdline[2048];
|
2006-04-28 15:34:58 +00:00
|
|
|
STARTUPINFO si;
|
2006-11-19 21:06:30 +00:00
|
|
|
PROCESS_INFORMATION pi;
|
|
|
|
|
2010-09-19 11:54:33 +00:00
|
|
|
if (pData->Selection < 1)
|
2006-11-19 21:06:30 +00:00
|
|
|
return;
|
|
|
|
|
2011-11-29 14:55:58 +00:00
|
|
|
/* Kill off the previous preview process */
|
2010-09-19 11:54:33 +00:00
|
|
|
if (pData->PrevWindowPi.hProcess)
|
2007-04-13 04:23:35 +00:00
|
|
|
{
|
2010-09-19 11:54:33 +00:00
|
|
|
TerminateProcess(pData->PrevWindowPi.hProcess, 0);
|
|
|
|
CloseHandle(pData->PrevWindowPi.hProcess);
|
|
|
|
CloseHandle(pData->PrevWindowPi.hThread);
|
|
|
|
pData->PrevWindowPi.hThread = pData->PrevWindowPi.hProcess = NULL;
|
2007-04-13 04:23:35 +00:00
|
|
|
}
|
|
|
|
|
2007-10-19 23:21:45 +00:00
|
|
|
_stprintf(szCmdline,
|
2007-04-13 04:23:35 +00:00
|
|
|
_T("%s /s"),
|
2010-09-19 11:54:33 +00:00
|
|
|
pData->ScreenSaverItems[pData->Selection].szFilename);
|
2006-04-28 15:34:58 +00:00
|
|
|
|
2006-11-26 12:47:56 +00:00
|
|
|
ZeroMemory(&si, sizeof(si));
|
2006-04-28 15:34:58 +00:00
|
|
|
si.cb = sizeof(si);
|
2006-11-26 12:47:56 +00:00
|
|
|
ZeroMemory(&pi, sizeof(pi));
|
2016-10-26 21:14:39 +00:00
|
|
|
if (CreateProcess(NULL,
|
2007-04-13 04:23:35 +00:00
|
|
|
szCmdline,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
FALSE,
|
|
|
|
0,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
&si,
|
|
|
|
&pi))
|
2006-11-19 21:06:30 +00:00
|
|
|
{
|
2007-04-13 04:23:35 +00:00
|
|
|
WaitForSingleObject(pi.hProcess, INFINITE);
|
2006-11-26 12:47:56 +00:00
|
|
|
CloseHandle(pi.hProcess);
|
|
|
|
CloseHandle(pi.hThread);
|
2006-11-19 21:06:30 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2006-11-26 12:47:56 +00:00
|
|
|
|
|
|
|
static VOID
|
|
|
|
CheckRegScreenSaverIsSecure(HWND hwndDlg)
|
2005-04-14 20:23:02 +00:00
|
|
|
{
|
|
|
|
HKEY hKey;
|
|
|
|
TCHAR szBuffer[2];
|
|
|
|
DWORD bufferSize = sizeof(szBuffer);
|
|
|
|
DWORD varType = REG_SZ;
|
|
|
|
LONG result;
|
|
|
|
|
2007-04-13 04:23:35 +00:00
|
|
|
if (RegOpenKeyEx(HKEY_CURRENT_USER,
|
|
|
|
_T("Control Panel\\Desktop"),
|
|
|
|
0,
|
|
|
|
KEY_ALL_ACCESS,
|
|
|
|
&hKey) == ERROR_SUCCESS)
|
2006-11-19 21:06:30 +00:00
|
|
|
{
|
2007-04-13 04:23:35 +00:00
|
|
|
result = RegQueryValueEx(hKey,
|
|
|
|
_T("ScreenSaverIsSecure"),
|
|
|
|
0,
|
|
|
|
&varType,
|
|
|
|
(LPBYTE)szBuffer,
|
|
|
|
&bufferSize);
|
|
|
|
RegCloseKey(hKey);
|
|
|
|
|
|
|
|
if (result == ERROR_SUCCESS)
|
2006-11-19 21:06:30 +00:00
|
|
|
{
|
2007-04-13 04:23:35 +00:00
|
|
|
if (_ttoi(szBuffer) == 1)
|
|
|
|
{
|
|
|
|
SendDlgItemMessage(hwndDlg,
|
|
|
|
IDC_SCREENS_USEPASSCHK,
|
|
|
|
BM_SETCHECK,
|
|
|
|
(WPARAM)BST_CHECKED,
|
|
|
|
0);
|
|
|
|
return;
|
|
|
|
}
|
2006-11-19 21:06:30 +00:00
|
|
|
}
|
|
|
|
|
2007-04-13 04:23:35 +00:00
|
|
|
SendDlgItemMessage(hwndDlg,
|
|
|
|
IDC_SCREENS_USEPASSCHK,
|
|
|
|
BM_SETCHECK,
|
|
|
|
(WPARAM)BST_UNCHECKED,
|
|
|
|
0);
|
|
|
|
}
|
2005-04-14 20:23:02 +00:00
|
|
|
}
|
|
|
|
|
2006-11-19 21:06:30 +00:00
|
|
|
|
2006-11-26 12:47:56 +00:00
|
|
|
static VOID
|
2010-10-06 14:13:00 +00:00
|
|
|
SearchScreenSavers(HWND hwndScreenSavers,
|
|
|
|
LPCTSTR pszSearchPath,
|
|
|
|
PDATA pData)
|
2005-04-14 20:23:02 +00:00
|
|
|
{
|
2010-10-06 14:13:00 +00:00
|
|
|
WIN32_FIND_DATA fd;
|
|
|
|
TCHAR szSearchPath[MAX_PATH];
|
|
|
|
HANDLE hFind;
|
|
|
|
ScreenSaverItem *ScreenSaverItem;
|
|
|
|
HANDLE hModule;
|
|
|
|
UINT i, ScreenSaverCount;
|
2014-01-19 19:15:08 +00:00
|
|
|
HRESULT hr;
|
2005-04-14 20:23:02 +00:00
|
|
|
|
2010-10-06 14:13:00 +00:00
|
|
|
ScreenSaverCount = pData->ScreenSaverCount;
|
2006-11-19 21:06:30 +00:00
|
|
|
|
2014-01-19 19:15:08 +00:00
|
|
|
hr = StringCbCopy(szSearchPath, sizeof(szSearchPath), pszSearchPath);
|
|
|
|
if (FAILED(hr))
|
|
|
|
return;
|
|
|
|
hr = StringCbCat(szSearchPath, sizeof(szSearchPath), TEXT("\\*.scr"));
|
|
|
|
if (FAILED(hr))
|
|
|
|
return;
|
2006-11-19 21:06:30 +00:00
|
|
|
|
2005-04-14 20:23:02 +00:00
|
|
|
hFind = FindFirstFile(szSearchPath, &fd);
|
2010-10-06 14:13:00 +00:00
|
|
|
|
|
|
|
if (hFind == INVALID_HANDLE_VALUE)
|
|
|
|
return;
|
|
|
|
|
|
|
|
while (ScreenSaverCount < MAX_SCREENSAVERS)
|
2005-04-14 20:23:02 +00:00
|
|
|
{
|
|
|
|
/* Don't add any hidden screensavers */
|
2006-11-19 21:06:30 +00:00
|
|
|
if ((fd.dwFileAttributes & FILE_ATTRIBUTE_HIDDEN) == 0)
|
2005-04-14 20:23:02 +00:00
|
|
|
{
|
|
|
|
TCHAR filename[MAX_PATH];
|
2006-11-19 21:06:30 +00:00
|
|
|
|
2014-01-19 19:15:08 +00:00
|
|
|
hr = StringCbCopy(filename, sizeof(filename), pszSearchPath);
|
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
|
|
|
FindClose(hFind);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
hr = StringCbCat(filename, sizeof(filename), _T("\\"));
|
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
|
|
|
FindClose(hFind);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
hr = StringCbCat(filename, sizeof(filename), fd.cFileName);
|
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
|
|
|
FindClose(hFind);
|
|
|
|
return;
|
|
|
|
}
|
2006-11-19 21:06:30 +00:00
|
|
|
|
2010-10-06 14:13:00 +00:00
|
|
|
ScreenSaverItem = pData->ScreenSaverItems + ScreenSaverCount;
|
2005-04-14 20:23:02 +00:00
|
|
|
|
|
|
|
ScreenSaverItem->bIsScreenSaver = TRUE;
|
2006-11-19 21:06:30 +00:00
|
|
|
|
2007-04-13 04:23:35 +00:00
|
|
|
hModule = LoadLibraryEx(filename,
|
|
|
|
NULL,
|
2007-07-29 18:09:42 +00:00
|
|
|
DONT_RESOLVE_DLL_REFERENCES | LOAD_LIBRARY_AS_DATAFILE);
|
2006-11-19 21:06:30 +00:00
|
|
|
if (hModule)
|
|
|
|
{
|
2010-10-06 14:13:00 +00:00
|
|
|
if (0 == LoadString(hModule,
|
2006-11-19 21:06:30 +00:00
|
|
|
1,
|
|
|
|
ScreenSaverItem->szDisplayName,
|
2010-10-06 14:13:00 +00:00
|
|
|
sizeof(ScreenSaverItem->szDisplayName) / sizeof(TCHAR)))
|
|
|
|
{
|
|
|
|
// If the string does not exists, copy the name of the file
|
2014-01-19 19:15:08 +00:00
|
|
|
hr = StringCbCopy(ScreenSaverItem->szDisplayName, sizeof(ScreenSaverItem->szDisplayName), fd.cFileName);
|
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
|
|
|
FreeLibrary(hModule);
|
|
|
|
FindClose(hFind);
|
|
|
|
return;
|
|
|
|
}
|
2010-10-06 14:13:00 +00:00
|
|
|
ScreenSaverItem->szDisplayName[_tcslen(fd.cFileName)-4] = '\0';
|
|
|
|
}
|
|
|
|
FreeLibrary(hModule);
|
2006-11-19 21:06:30 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2014-01-19 19:15:08 +00:00
|
|
|
hr = StringCbCopy(ScreenSaverItem->szDisplayName, sizeof(ScreenSaverItem->szDisplayName), _T("Unknown"));
|
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
|
|
|
FindClose(hFind);
|
|
|
|
return;
|
|
|
|
}
|
2006-11-19 21:06:30 +00:00
|
|
|
}
|
|
|
|
|
2014-01-19 19:15:08 +00:00
|
|
|
hr = StringCbCopy(ScreenSaverItem->szFilename, sizeof(ScreenSaverItem->szFilename), filename);
|
|
|
|
if (FAILED(hr))
|
|
|
|
{
|
|
|
|
FindClose(hFind);
|
|
|
|
return;
|
|
|
|
}
|
2005-04-14 20:23:02 +00:00
|
|
|
|
2007-04-13 04:23:35 +00:00
|
|
|
i = SendMessage(hwndScreenSavers,
|
|
|
|
CB_ADDSTRING,
|
|
|
|
0,
|
|
|
|
(LPARAM)ScreenSaverItem->szDisplayName);
|
2006-11-19 21:06:30 +00:00
|
|
|
|
2007-04-13 04:23:35 +00:00
|
|
|
SendMessage(hwndScreenSavers,
|
|
|
|
CB_SETITEMDATA,
|
|
|
|
i,
|
|
|
|
(LPARAM)ScreenSaverCount);
|
2006-11-19 21:06:30 +00:00
|
|
|
|
2007-04-13 04:23:35 +00:00
|
|
|
ScreenSaverCount++;
|
2005-04-14 20:23:02 +00:00
|
|
|
}
|
2006-11-19 21:06:30 +00:00
|
|
|
|
|
|
|
if (!FindNextFile(hFind, &fd))
|
2010-10-06 14:13:00 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
FindClose(hFind);
|
|
|
|
|
|
|
|
pData->ScreenSaverCount = ScreenSaverCount;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static VOID
|
|
|
|
AddScreenSavers(HWND hwndDlg, PDATA pData)
|
|
|
|
{
|
|
|
|
HWND hwndScreenSavers = GetDlgItem(hwndDlg, IDC_SCREENS_LIST);
|
|
|
|
TCHAR szSearchPath[MAX_PATH];
|
2011-10-12 21:30:50 +00:00
|
|
|
TCHAR szLocalPath[MAX_PATH];
|
2010-10-06 14:13:00 +00:00
|
|
|
INT i;
|
|
|
|
ScreenSaverItem *ScreenSaverItem = NULL;
|
|
|
|
LPTSTR lpBackSlash;
|
|
|
|
|
|
|
|
/* Add the "None" item */
|
|
|
|
ScreenSaverItem = pData->ScreenSaverItems;
|
|
|
|
|
|
|
|
ScreenSaverItem->bIsScreenSaver = FALSE;
|
|
|
|
|
|
|
|
LoadString(hApplet,
|
|
|
|
IDS_NONE,
|
|
|
|
ScreenSaverItem->szDisplayName,
|
|
|
|
sizeof(ScreenSaverItem->szDisplayName) / sizeof(TCHAR));
|
|
|
|
|
|
|
|
i = SendMessage(hwndScreenSavers,
|
|
|
|
CB_ADDSTRING,
|
|
|
|
0,
|
|
|
|
(LPARAM)ScreenSaverItem->szDisplayName);
|
|
|
|
|
|
|
|
SendMessage(hwndScreenSavers,
|
|
|
|
CB_SETITEMDATA,
|
|
|
|
i,
|
|
|
|
(LPARAM)0);
|
|
|
|
|
|
|
|
// Initialize number of items into the list
|
|
|
|
pData->ScreenSaverCount = 1;
|
|
|
|
|
2011-10-12 21:30:50 +00:00
|
|
|
// Add all the screensavers where the applet is stored.
|
|
|
|
GetModuleFileName(hApplet, szLocalPath, MAX_PATH);
|
|
|
|
lpBackSlash = _tcsrchr(szLocalPath, _T('\\'));
|
|
|
|
if (lpBackSlash != NULL)
|
|
|
|
{
|
|
|
|
*lpBackSlash = '\0';
|
|
|
|
SearchScreenSavers(hwndScreenSavers, szLocalPath, pData);
|
|
|
|
}
|
|
|
|
|
2010-10-06 14:13:00 +00:00
|
|
|
// Add all the screensavers in the C:\ReactOS\System32 directory.
|
|
|
|
GetSystemDirectory(szSearchPath, MAX_PATH);
|
2011-10-12 21:30:50 +00:00
|
|
|
if (lpBackSlash != NULL && _tcsicmp(szSearchPath, szLocalPath) != 0)
|
|
|
|
SearchScreenSavers(hwndScreenSavers, szSearchPath, pData);
|
2010-10-06 14:13:00 +00:00
|
|
|
|
|
|
|
// Add all the screensavers in the C:\ReactOS directory.
|
|
|
|
GetWindowsDirectory(szSearchPath, MAX_PATH);
|
2011-10-12 21:30:50 +00:00
|
|
|
if (lpBackSlash != NULL && _tcsicmp(szSearchPath, szLocalPath) != 0)
|
2010-10-06 14:13:00 +00:00
|
|
|
SearchScreenSavers(hwndScreenSavers, szSearchPath, pData);
|
2005-04-14 20:23:02 +00:00
|
|
|
}
|
|
|
|
|
2006-11-26 12:47:56 +00:00
|
|
|
|
|
|
|
static VOID
|
2010-09-19 11:54:33 +00:00
|
|
|
SetScreenSaver(HWND hwndDlg, PDATA pData)
|
2006-07-06 02:29:16 +00:00
|
|
|
{
|
|
|
|
HKEY regKey;
|
2011-05-28 11:39:36 +00:00
|
|
|
BOOL DeleteMode = FALSE;
|
2006-11-19 21:06:30 +00:00
|
|
|
|
2014-05-31 16:58:03 +00:00
|
|
|
DBG_UNREFERENCED_LOCAL_VARIABLE(DeleteMode);
|
|
|
|
|
2007-10-19 23:21:45 +00:00
|
|
|
if (RegOpenKeyEx(HKEY_CURRENT_USER,
|
2007-04-13 04:23:35 +00:00
|
|
|
_T("Control Panel\\Desktop"),
|
2007-10-19 23:21:45 +00:00
|
|
|
0,
|
|
|
|
KEY_ALL_ACCESS,
|
2007-04-13 04:23:35 +00:00
|
|
|
®Key) == ERROR_SUCCESS)
|
|
|
|
{
|
|
|
|
INT Time;
|
|
|
|
BOOL bRet;
|
2013-02-24 08:58:05 +00:00
|
|
|
TCHAR Sec;
|
2007-04-13 04:23:35 +00:00
|
|
|
UINT Ret;
|
|
|
|
|
2011-11-29 14:55:58 +00:00
|
|
|
/* Set the screensaver */
|
2010-09-19 11:54:33 +00:00
|
|
|
if (pData->ScreenSaverItems[pData->Selection].bIsScreenSaver)
|
2007-04-13 04:23:35 +00:00
|
|
|
{
|
2015-04-11 08:17:03 +00:00
|
|
|
SIZE_T Length = _tcslen(pData->ScreenSaverItems[pData->Selection].szFilename) * sizeof(TCHAR);
|
2007-10-19 23:21:45 +00:00
|
|
|
RegSetValueEx(regKey,
|
2007-04-13 04:23:35 +00:00
|
|
|
_T("SCRNSAVE.EXE"),
|
|
|
|
0,
|
|
|
|
REG_SZ,
|
2010-09-19 11:54:33 +00:00
|
|
|
(PBYTE)pData->ScreenSaverItems[pData->Selection].szFilename,
|
2015-04-11 08:17:03 +00:00
|
|
|
(DWORD)Length);
|
2013-02-24 08:58:05 +00:00
|
|
|
|
|
|
|
SystemParametersInfo(SPI_SETSCREENSAVEACTIVE, TRUE, 0, SPIF_UPDATEINIFILE);
|
2007-04-13 04:23:35 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Windows deletes the value if no screensaver is set */
|
|
|
|
RegDeleteValue(regKey, _T("SCRNSAVE.EXE"));
|
2011-05-28 11:39:36 +00:00
|
|
|
DeleteMode = TRUE;
|
2007-04-13 04:23:35 +00:00
|
|
|
|
2013-02-24 08:58:05 +00:00
|
|
|
SystemParametersInfo(SPI_SETSCREENSAVEACTIVE, FALSE, 0, SPIF_UPDATEINIFILE);
|
|
|
|
}
|
2011-05-28 11:39:36 +00:00
|
|
|
|
2011-11-29 14:55:58 +00:00
|
|
|
/* Set the secure value */
|
2007-04-13 04:23:35 +00:00
|
|
|
Ret = SendDlgItemMessage(hwndDlg,
|
|
|
|
IDC_SCREENS_USEPASSCHK,
|
|
|
|
BM_GETCHECK,
|
|
|
|
0,
|
|
|
|
0);
|
|
|
|
Sec = (Ret == BST_CHECKED) ? _T('1') : _T('0');
|
|
|
|
RegSetValueEx(regKey,
|
|
|
|
_T("ScreenSaverIsSecure"),
|
|
|
|
0,
|
|
|
|
REG_SZ,
|
|
|
|
(PBYTE)&Sec,
|
|
|
|
sizeof(TCHAR));
|
|
|
|
|
2013-02-24 08:58:05 +00:00
|
|
|
/* Set the screensaver time delay */
|
|
|
|
Time = GetDlgItemInt(hwndDlg,
|
|
|
|
IDC_SCREENS_TIMEDELAY,
|
|
|
|
&bRet,
|
|
|
|
FALSE);
|
|
|
|
if (Time == 0)
|
|
|
|
Time = 60;
|
|
|
|
else
|
|
|
|
Time *= 60;
|
|
|
|
|
|
|
|
SystemParametersInfoW(SPI_SETSCREENSAVETIMEOUT, Time, 0, SPIF_SENDCHANGE | SPIF_UPDATEINIFILE);
|
|
|
|
|
2007-04-13 04:23:35 +00:00
|
|
|
RegCloseKey(regKey);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2007-10-19 23:21:45 +00:00
|
|
|
static BOOL
|
2010-09-19 11:54:33 +00:00
|
|
|
OnInitDialog(HWND hwndDlg, PDATA pData)
|
2007-04-13 04:23:35 +00:00
|
|
|
{
|
|
|
|
LPTSTR lpCurSs;
|
|
|
|
HWND hwndSSCombo = GetDlgItem(hwndDlg, IDC_SCREENS_LIST);
|
|
|
|
INT Num;
|
2022-10-03 14:32:42 +00:00
|
|
|
WNDCLASS wc = {0};
|
2007-04-13 04:23:35 +00:00
|
|
|
|
2010-09-19 11:54:33 +00:00
|
|
|
pData = HeapAlloc(GetProcessHeap(),
|
2007-10-19 23:21:45 +00:00
|
|
|
HEAP_ZERO_MEMORY,
|
2010-09-19 11:54:33 +00:00
|
|
|
sizeof(DATA));
|
|
|
|
if (!pData)
|
2007-04-13 04:23:35 +00:00
|
|
|
{
|
|
|
|
EndDialog(hwndDlg, -1);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2022-10-03 14:32:42 +00:00
|
|
|
wc.lpfnWndProc = DefWindowProc;
|
|
|
|
wc.hInstance = hApplet;
|
|
|
|
wc.hCursor = NULL;
|
|
|
|
wc.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);
|
|
|
|
wc.lpszClassName = szPreviewWndClass;
|
|
|
|
|
|
|
|
if (RegisterClass(&wc))
|
|
|
|
{
|
|
|
|
HWND hParent = GetDlgItem(hwndDlg, IDC_SCREENS_PREVIEW);
|
|
|
|
HWND hChild;
|
|
|
|
|
2022-10-03 14:34:10 +00:00
|
|
|
if (hParent != NULL)
|
|
|
|
{
|
|
|
|
pData->OldPreviewProc = (WNDPROC)GetWindowLongPtr(hParent, GWLP_WNDPROC);
|
|
|
|
SetWindowLongPtr(hParent, GWLP_WNDPROC, (LONG_PTR)RedrawSubclassProc);
|
|
|
|
SetWindowLongPtr(hParent, GWLP_USERDATA, (LONG_PTR)pData);
|
|
|
|
}
|
|
|
|
|
2022-10-03 14:32:42 +00:00
|
|
|
hChild = CreateWindowEx(0, szPreviewWndClass, NULL,
|
2022-10-03 14:34:10 +00:00
|
|
|
WS_CHILD | WS_CLIPCHILDREN,
|
|
|
|
0, 0, 0, 0, hParent,
|
2022-10-03 14:32:42 +00:00
|
|
|
NULL, hApplet, NULL);
|
|
|
|
if (hChild != NULL)
|
|
|
|
{
|
|
|
|
RECT rc;
|
|
|
|
GetClientRect(hParent, &rc);
|
|
|
|
rc.left += MONITOR_LEFT;
|
|
|
|
rc.top += MONITOR_TOP;
|
|
|
|
MoveWindow(hChild, rc.left, rc.top, MONITOR_WIDTH, MONITOR_HEIGHT, FALSE);
|
|
|
|
}
|
|
|
|
|
|
|
|
pData->ScreenSaverPreviewParent = hChild;
|
|
|
|
}
|
|
|
|
|
2007-04-13 04:23:35 +00:00
|
|
|
SetWindowLongPtr(hwndDlg,
|
|
|
|
DWLP_USER,
|
2010-09-19 11:54:33 +00:00
|
|
|
(LONG_PTR)pData);
|
2007-04-13 04:23:35 +00:00
|
|
|
|
2010-09-19 11:54:33 +00:00
|
|
|
pData->Selection = -1;
|
2007-04-13 04:23:35 +00:00
|
|
|
|
|
|
|
SendDlgItemMessage(hwndDlg,
|
|
|
|
IDC_SCREENS_TIME,
|
|
|
|
UDM_SETRANGE,
|
|
|
|
0,
|
|
|
|
MAKELONG
|
|
|
|
((short) 240, (short) 1));
|
|
|
|
|
|
|
|
AddScreenSavers(hwndDlg,
|
2010-09-19 11:54:33 +00:00
|
|
|
pData);
|
2007-04-13 04:23:35 +00:00
|
|
|
|
|
|
|
CheckRegScreenSaverIsSecure(hwndDlg);
|
|
|
|
|
2011-11-29 14:55:58 +00:00
|
|
|
/* Set the current screensaver in the combo box */
|
2007-04-13 04:23:35 +00:00
|
|
|
lpCurSs = GetCurrentScreenSaverValue(_T("SCRNSAVE.EXE"));
|
|
|
|
if (lpCurSs)
|
|
|
|
{
|
|
|
|
BOOL bFound = FALSE;
|
|
|
|
INT i;
|
|
|
|
|
|
|
|
for (i = 0; i < MAX_SCREENSAVERS; i++)
|
|
|
|
{
|
2010-09-19 11:54:33 +00:00
|
|
|
if (!_tcscmp(lpCurSs, pData->ScreenSaverItems[i].szFilename))
|
2007-04-13 04:23:35 +00:00
|
|
|
{
|
|
|
|
bFound = TRUE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (bFound)
|
|
|
|
{
|
2007-10-19 23:21:45 +00:00
|
|
|
Num = SendMessage(hwndSSCombo,
|
2007-04-13 04:23:35 +00:00
|
|
|
CB_FINDSTRINGEXACT,
|
|
|
|
-1,
|
2010-09-19 11:54:33 +00:00
|
|
|
(LPARAM)pData->ScreenSaverItems[i].szDisplayName);
|
2007-04-13 04:23:35 +00:00
|
|
|
if (Num != CB_ERR)
|
|
|
|
SendMessage(hwndSSCombo,
|
|
|
|
CB_SETCURSEL,
|
|
|
|
Num,
|
|
|
|
0);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
SendMessage(hwndSSCombo,
|
|
|
|
CB_SETCURSEL,
|
|
|
|
0,
|
|
|
|
0);
|
|
|
|
}
|
|
|
|
|
|
|
|
HeapFree(GetProcessHeap(),
|
|
|
|
0,
|
|
|
|
lpCurSs);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2011-11-29 14:55:58 +00:00
|
|
|
/* Set screensaver to (none) */
|
2007-04-13 04:23:35 +00:00
|
|
|
SendMessage(hwndSSCombo,
|
|
|
|
CB_SETCURSEL,
|
|
|
|
0,
|
|
|
|
0);
|
|
|
|
}
|
|
|
|
|
2011-11-29 14:55:58 +00:00
|
|
|
/* Set the current timeout */
|
2007-04-13 04:23:35 +00:00
|
|
|
lpCurSs = GetCurrentScreenSaverValue(_T("ScreenSaveTimeOut"));
|
|
|
|
if (lpCurSs)
|
|
|
|
{
|
|
|
|
UINT Time = _ttoi(lpCurSs);
|
|
|
|
|
|
|
|
Time /= 60;
|
|
|
|
|
|
|
|
SendDlgItemMessage(hwndDlg,
|
|
|
|
IDC_SCREENS_TIME,
|
|
|
|
UDM_SETPOS32,
|
|
|
|
0,
|
|
|
|
Time);
|
|
|
|
|
|
|
|
HeapFree(GetProcessHeap(),
|
|
|
|
0,
|
|
|
|
lpCurSs);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
SelectionChanged(hwndDlg,
|
2010-09-19 11:54:33 +00:00
|
|
|
pData);
|
2007-04-13 04:23:35 +00:00
|
|
|
|
|
|
|
return TRUE;
|
2006-07-06 02:29:16 +00:00
|
|
|
}
|
2006-11-26 12:47:56 +00:00
|
|
|
|
|
|
|
|
|
|
|
INT_PTR CALLBACK
|
|
|
|
ScreenSaverPageProc(HWND hwndDlg,
|
|
|
|
UINT uMsg,
|
|
|
|
WPARAM wParam,
|
|
|
|
LPARAM lParam)
|
|
|
|
{
|
2010-09-19 11:54:33 +00:00
|
|
|
PDATA pData;
|
2006-11-26 12:47:56 +00:00
|
|
|
|
2010-09-19 11:54:33 +00:00
|
|
|
pData = (PDATA)GetWindowLongPtr(hwndDlg, DWLP_USER);
|
2006-11-26 12:47:56 +00:00
|
|
|
|
|
|
|
switch (uMsg)
|
|
|
|
{
|
|
|
|
case WM_INITDIALOG:
|
2007-04-13 04:23:35 +00:00
|
|
|
{
|
2010-09-19 11:54:33 +00:00
|
|
|
OnInitDialog(hwndDlg, pData);
|
2006-11-26 12:47:56 +00:00
|
|
|
break;
|
2007-04-13 04:23:35 +00:00
|
|
|
}
|
2006-11-26 12:47:56 +00:00
|
|
|
|
|
|
|
case WM_DESTROY:
|
2007-04-13 04:23:35 +00:00
|
|
|
{
|
2022-10-03 14:32:42 +00:00
|
|
|
if (pData->ScreenSaverPreviewParent)
|
|
|
|
{
|
2022-10-03 14:34:10 +00:00
|
|
|
SetWindowLongPtr(GetDlgItem(hwndDlg, IDC_SCREENS_PREVIEW),
|
|
|
|
GWLP_WNDPROC,
|
|
|
|
(LONG_PTR)pData->OldPreviewProc);
|
2022-10-03 14:32:42 +00:00
|
|
|
DestroyWindow(pData->ScreenSaverPreviewParent);
|
|
|
|
pData->ScreenSaverPreviewParent = NULL;
|
|
|
|
}
|
|
|
|
UnregisterClass(szPreviewWndClass, hApplet);
|
2010-09-19 11:54:33 +00:00
|
|
|
if (pData->PrevWindowPi.hProcess)
|
2007-04-13 04:23:35 +00:00
|
|
|
{
|
2010-09-19 11:54:33 +00:00
|
|
|
TerminateProcess(pData->PrevWindowPi.hProcess, 0);
|
|
|
|
CloseHandle(pData->PrevWindowPi.hProcess);
|
|
|
|
CloseHandle(pData->PrevWindowPi.hThread);
|
2007-04-13 04:23:35 +00:00
|
|
|
}
|
|
|
|
HeapFree(GetProcessHeap(),
|
|
|
|
0,
|
2010-09-19 11:54:33 +00:00
|
|
|
pData);
|
2006-11-26 12:47:56 +00:00
|
|
|
break;
|
2007-04-13 04:23:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
case WM_ENDSESSION:
|
|
|
|
{
|
|
|
|
SetScreenSaverPreviewBox(hwndDlg,
|
2010-09-19 11:54:33 +00:00
|
|
|
pData);
|
2007-04-13 04:23:35 +00:00
|
|
|
break;
|
|
|
|
}
|
2006-11-26 12:47:56 +00:00
|
|
|
|
2022-10-03 14:32:42 +00:00
|
|
|
case WM_DRAWITEM:
|
|
|
|
{
|
|
|
|
LPDRAWITEMSTRUCT lpDrawItem;
|
|
|
|
lpDrawItem = (LPDRAWITEMSTRUCT)lParam;
|
|
|
|
|
|
|
|
if (lpDrawItem->CtlID == IDC_SCREENS_PREVIEW)
|
|
|
|
ShowScreenSaverPreview(lpDrawItem, pData);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2006-11-26 12:47:56 +00:00
|
|
|
case WM_COMMAND:
|
|
|
|
{
|
|
|
|
DWORD controlId = LOWORD(wParam);
|
|
|
|
DWORD command = HIWORD(wParam);
|
|
|
|
|
|
|
|
switch (controlId)
|
|
|
|
{
|
2007-04-13 04:23:35 +00:00
|
|
|
case IDC_SCREENS_LIST:
|
|
|
|
{
|
|
|
|
if (HIWORD(wParam) == CBN_SELCHANGE)
|
|
|
|
{
|
2010-09-19 11:54:33 +00:00
|
|
|
SelectionChanged(hwndDlg, pData);
|
|
|
|
SetScreenSaverPreviewBox(hwndDlg, pData);
|
2007-04-13 04:23:35 +00:00
|
|
|
PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
2007-10-19 23:21:45 +00:00
|
|
|
|
2007-04-13 04:23:35 +00:00
|
|
|
case IDC_SCREENS_TIMEDELAY:
|
|
|
|
{
|
2019-08-04 09:21:28 +00:00
|
|
|
if (command == EN_CHANGE)
|
|
|
|
PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
|
2007-04-13 04:23:35 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2006-11-26 12:47:56 +00:00
|
|
|
case IDC_SCREENS_POWER_BUTTON: // Start Powercfg.Cpl
|
2007-04-13 04:23:35 +00:00
|
|
|
{
|
2006-11-26 12:47:56 +00:00
|
|
|
if (command == BN_CLICKED)
|
2007-04-13 04:23:35 +00:00
|
|
|
WinExec("rundll32 shell32.dll,Control_RunDLL powercfg.cpl",SW_SHOWNORMAL);
|
2006-11-26 12:47:56 +00:00
|
|
|
break;
|
2007-04-13 04:23:35 +00:00
|
|
|
}
|
2006-11-26 12:47:56 +00:00
|
|
|
|
|
|
|
case IDC_SCREENS_TESTSC: // Screensaver Preview
|
2007-04-13 04:23:35 +00:00
|
|
|
{
|
2016-10-26 21:14:39 +00:00
|
|
|
if (command == BN_CLICKED)
|
2007-04-13 04:23:35 +00:00
|
|
|
{
|
2010-09-19 11:54:33 +00:00
|
|
|
ScreensaverPreview(hwndDlg, pData);
|
|
|
|
SetScreenSaverPreviewBox(hwndDlg, pData);
|
2007-04-13 04:23:35 +00:00
|
|
|
}
|
2006-11-26 12:47:56 +00:00
|
|
|
break;
|
2007-04-13 04:23:35 +00:00
|
|
|
}
|
2006-11-26 12:47:56 +00:00
|
|
|
|
|
|
|
case IDC_SCREENS_SETTINGS: // Screensaver Settings
|
2007-04-13 04:23:35 +00:00
|
|
|
{
|
2006-11-26 12:47:56 +00:00
|
|
|
if (command == BN_CLICKED)
|
2010-09-19 11:54:33 +00:00
|
|
|
ScreensaverConfig(hwndDlg, pData);
|
2006-11-26 12:47:56 +00:00
|
|
|
break;
|
2007-04-13 04:23:35 +00:00
|
|
|
}
|
2006-11-26 12:47:56 +00:00
|
|
|
|
|
|
|
case IDC_SCREENS_USEPASSCHK: // Screensaver Is Secure
|
2007-04-13 04:23:35 +00:00
|
|
|
{
|
2006-11-26 12:47:56 +00:00
|
|
|
if (command == BN_CLICKED)
|
2007-04-13 04:23:35 +00:00
|
|
|
{
|
|
|
|
PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
|
|
|
|
}
|
2006-11-26 12:47:56 +00:00
|
|
|
break;
|
2007-04-13 04:23:35 +00:00
|
|
|
}
|
2006-11-26 12:47:56 +00:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case WM_NOTIFY:
|
|
|
|
{
|
|
|
|
LPNMHDR lpnm = (LPNMHDR)lParam;
|
|
|
|
|
|
|
|
switch(lpnm->code)
|
|
|
|
{
|
|
|
|
case PSN_APPLY:
|
2007-04-13 04:23:35 +00:00
|
|
|
{
|
2010-09-19 11:54:33 +00:00
|
|
|
SetScreenSaver(hwndDlg, pData);
|
2006-11-26 12:47:56 +00:00
|
|
|
return TRUE;
|
2007-04-13 04:23:35 +00:00
|
|
|
}
|
2006-11-26 12:47:56 +00:00
|
|
|
|
2007-04-13 04:23:35 +00:00
|
|
|
case PSN_SETACTIVE:
|
2006-11-26 12:47:56 +00:00
|
|
|
{
|
2013-02-23 18:52:13 +00:00
|
|
|
/* Enable screensaver preview support */
|
2010-09-19 11:54:33 +00:00
|
|
|
SetScreenSaverPreviewBox(hwndDlg, pData);
|
2006-11-26 12:47:56 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2007-04-13 04:23:35 +00:00
|
|
|
case PSN_KILLACTIVE:
|
|
|
|
{
|
2013-02-23 18:52:13 +00:00
|
|
|
/* Kill running preview screensaver */
|
2010-09-19 11:54:33 +00:00
|
|
|
if (pData->PrevWindowPi.hProcess)
|
2007-04-13 04:23:35 +00:00
|
|
|
{
|
2010-09-19 11:54:33 +00:00
|
|
|
TerminateProcess(pData->PrevWindowPi.hProcess, 0);
|
|
|
|
CloseHandle(pData->PrevWindowPi.hProcess);
|
|
|
|
CloseHandle(pData->PrevWindowPi.hThread);
|
|
|
|
pData->PrevWindowPi.hThread = pData->PrevWindowPi.hProcess = NULL;
|
2007-04-13 04:23:35 +00:00
|
|
|
}
|
2006-11-26 12:47:56 +00:00
|
|
|
break;
|
2007-04-13 04:23:35 +00:00
|
|
|
}
|
2006-11-26 12:47:56 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|