mirror of
https://github.com/reactos/reactos.git
synced 2025-08-04 08:05:43 +00:00
[FORMATTING]
- 2 spaces --> 4 spaces - some other changes to make the code style consistent with most ROS code - Change in the .rbuild file to treat warnings as errors (the lib currently doesn't spit out any warnings, so it shouldn't do in the future) svn path=/trunk/; revision=32398
This commit is contained in:
parent
9cd6c52bd6
commit
de244cca92
2 changed files with 303 additions and 274 deletions
|
@ -1,12 +1,13 @@
|
||||||
/*
|
/*
|
||||||
Screen saver library by Anders Norlander <anorland@hem2.passagen.se>
|
Screen saver library by Anders Norlander <anorland@hem2.passagen.se>
|
||||||
|
|
||||||
This library is (hopefully) compatible with Microsoft's
|
This library is (hopefully) compatible with Microsoft's
|
||||||
screen saver library.
|
screen saver library.
|
||||||
|
|
||||||
This is public domain software.
|
This is public domain software.
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <scrnsave.h>
|
#include <scrnsave.h>
|
||||||
#include <regstr.h>
|
#include <regstr.h>
|
||||||
|
@ -15,16 +16,16 @@
|
||||||
#define CLASS_SCRNSAVE TEXT("WindowsScreenSaverClass")
|
#define CLASS_SCRNSAVE TEXT("WindowsScreenSaverClass")
|
||||||
|
|
||||||
/* globals */
|
/* globals */
|
||||||
HWND hMainWindow = NULL;
|
HWND hMainWindow = NULL;
|
||||||
BOOL fChildPreview = FALSE;
|
BOOL fChildPreview = FALSE;
|
||||||
HINSTANCE hMainInstance;
|
HINSTANCE hMainInstance;
|
||||||
TCHAR szName[TITLEBARNAMELEN];
|
TCHAR szName[TITLEBARNAMELEN];
|
||||||
TCHAR szAppName[APPNAMEBUFFERLEN];
|
TCHAR szAppName[APPNAMEBUFFERLEN];
|
||||||
TCHAR szIniFile[MAXFILELEN];
|
TCHAR szIniFile[MAXFILELEN];
|
||||||
TCHAR szScreenSaver[22];
|
TCHAR szScreenSaver[22];
|
||||||
TCHAR szHelpFile[MAXFILELEN];
|
TCHAR szHelpFile[MAXFILELEN];
|
||||||
TCHAR szNoHelpMemory[BUFFLEN];
|
TCHAR szNoHelpMemory[BUFFLEN];
|
||||||
UINT MyHelpMessage;
|
UINT MyHelpMessage;
|
||||||
|
|
||||||
/* local house keeping */
|
/* local house keeping */
|
||||||
static HINSTANCE hPwdLib = NULL;
|
static HINSTANCE hPwdLib = NULL;
|
||||||
|
@ -54,355 +55,383 @@ static void LaunchConfig(void);
|
||||||
|
|
||||||
static int ISSPACE(char c)
|
static int ISSPACE(char c)
|
||||||
{
|
{
|
||||||
return (c == ' ' || c == '\t');
|
return (c == ' ' || c == '\t');
|
||||||
}
|
}
|
||||||
|
|
||||||
#define ISNUM(c) ((c) >= '0' && c <= '9')
|
#define ISNUM(c) ((c) >= '0' && c <= '9')
|
||||||
|
|
||||||
static unsigned long
|
static unsigned long
|
||||||
_toul(const char *s)
|
_toul(const char *s)
|
||||||
{
|
{
|
||||||
unsigned long res;
|
unsigned long res;
|
||||||
unsigned long n;
|
unsigned long n;
|
||||||
const char *p;
|
const char *p;
|
||||||
for (p = s; *p; p++)
|
|
||||||
if (!ISNUM(*p)) break;
|
for (p = s; *p; p++)
|
||||||
p--;
|
if (!ISNUM(*p))
|
||||||
res = 0;
|
break;
|
||||||
for (n = 1; p >= s; p--, n *= 10)
|
|
||||||
res += (*p - '0') * n;
|
p--;
|
||||||
return res;
|
res = 0;
|
||||||
|
|
||||||
|
for (n = 1; p >= s; p--, n *= 10)
|
||||||
|
res += (*p - '0') * n;
|
||||||
|
|
||||||
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* screen saver entry point */
|
/* screen saver entry point */
|
||||||
int APIENTRY WinMain(HINSTANCE hInst, HINSTANCE hPrevInst,
|
int APIENTRY WinMain(HINSTANCE hInst, HINSTANCE hPrevInst,
|
||||||
LPSTR CmdLine, int nCmdShow)
|
LPSTR CmdLine, int nCmdShow)
|
||||||
{
|
{
|
||||||
LPSTR p;
|
LPSTR p;
|
||||||
OSVERSIONINFO vi;
|
OSVERSIONINFO vi;
|
||||||
|
|
||||||
/* initialize */
|
/* initialize */
|
||||||
hMainInstance = hInst;
|
hMainInstance = hInst;
|
||||||
|
|
||||||
vi.dwOSVersionInfoSize = sizeof(vi);
|
vi.dwOSVersionInfoSize = sizeof(vi);
|
||||||
GetVersionEx(&vi);
|
GetVersionEx(&vi);
|
||||||
/* check if we are going to check for passwords */
|
/* check if we are going to check for passwords */
|
||||||
if (vi.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS)
|
if (vi.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS)
|
||||||
{
|
{
|
||||||
HKEY hKey;
|
HKEY hKey;
|
||||||
/* we are using windows 95 */
|
/* we are using windows 95 */
|
||||||
w95 = TRUE;
|
w95 = TRUE;
|
||||||
if (RegOpenKey(HKEY_CURRENT_USER, REGSTR_PATH_SCREENSAVE ,&hKey) ==
|
if (RegOpenKey(HKEY_CURRENT_USER, REGSTR_PATH_SCREENSAVE ,&hKey) ==
|
||||||
ERROR_SUCCESS)
|
ERROR_SUCCESS)
|
||||||
{
|
{
|
||||||
DWORD check_pwd;
|
DWORD check_pwd;
|
||||||
DWORD size = sizeof(DWORD);
|
DWORD size = sizeof(DWORD);
|
||||||
DWORD type;
|
DWORD type;
|
||||||
LONG res;
|
LONG res;
|
||||||
res = RegQueryValueEx(hKey, REGSTR_VALUE_USESCRPASSWORD,
|
|
||||||
NULL, &type, (PBYTE) &check_pwd, &size);
|
res = RegQueryValueEx(hKey, REGSTR_VALUE_USESCRPASSWORD,
|
||||||
if (check_pwd && res == ERROR_SUCCESS)
|
NULL, &type, (PBYTE) &check_pwd, &size);
|
||||||
|
|
||||||
|
if (check_pwd && res == ERROR_SUCCESS)
|
||||||
{
|
{
|
||||||
hPwdLib = LoadLibrary(TEXT("PASSWORD.CPL"));
|
hPwdLib = LoadLibrary(TEXT("PASSWORD.CPL"));
|
||||||
if (hPwdLib)
|
if (hPwdLib)
|
||||||
VerifyScreenSavePwd = GetProcAddress(hPwdLib, szVerifyPassword);
|
VerifyScreenSavePwd = GetProcAddress(hPwdLib, szVerifyPassword);
|
||||||
}
|
}
|
||||||
RegCloseKey(hKey);
|
|
||||||
|
RegCloseKey(hKey);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* parse arguments */
|
/* parse arguments */
|
||||||
for (p = CmdLine; *p; p++)
|
for (p = CmdLine; *p; p++)
|
||||||
{
|
{
|
||||||
switch (*p)
|
switch (*p)
|
||||||
{
|
{
|
||||||
case 'S':
|
case 'S':
|
||||||
case 's':
|
case 's':
|
||||||
/* start screen saver */
|
/* start screen saver */
|
||||||
return LaunchScreenSaver(NULL);
|
return LaunchScreenSaver(NULL);
|
||||||
|
|
||||||
case 'P':
|
case 'P':
|
||||||
case 'p':
|
case 'p':
|
||||||
{
|
{
|
||||||
/* start screen saver in preview window */
|
/* start screen saver in preview window */
|
||||||
HWND hParent;
|
HWND hParent;
|
||||||
fChildPreview = TRUE;
|
fChildPreview = TRUE;
|
||||||
while (ISSPACE(*++p));
|
|
||||||
hParent = (HWND) _toul(p);
|
|
||||||
if (hParent && IsWindow(hParent))
|
|
||||||
return LaunchScreenSaver(hParent);
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
case 'C':
|
while (ISSPACE(*++p));
|
||||||
case 'c':
|
hParent = (HWND) _toul(p);
|
||||||
/* display configure dialog */
|
|
||||||
LaunchConfig();
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
case 'A':
|
if (hParent && IsWindow(hParent))
|
||||||
case 'a':
|
return LaunchScreenSaver(hParent);
|
||||||
{
|
}
|
||||||
/* change screen saver password */
|
return 0;
|
||||||
HWND hParent;
|
|
||||||
while (ISSPACE(*++p));
|
|
||||||
hParent = (HWND) _toul(p);
|
|
||||||
if (!hParent || !IsWindow(hParent))
|
|
||||||
hParent = GetForegroundWindow();
|
|
||||||
ScreenSaverChangePassword(hParent);
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
case '-':
|
case 'C':
|
||||||
case '/':
|
case 'c':
|
||||||
case ' ':
|
/* display configure dialog */
|
||||||
default:
|
LaunchConfig();
|
||||||
break;
|
return 0;
|
||||||
|
|
||||||
|
case 'A':
|
||||||
|
case 'a':
|
||||||
|
{
|
||||||
|
/* change screen saver password */
|
||||||
|
HWND hParent;
|
||||||
|
while (ISSPACE(*++p));
|
||||||
|
hParent = (HWND) _toul(p);
|
||||||
|
|
||||||
|
if (!hParent || !IsWindow(hParent))
|
||||||
|
hParent = GetForegroundWindow();
|
||||||
|
|
||||||
|
ScreenSaverChangePassword(hParent);
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
case '-':
|
||||||
|
case '/':
|
||||||
|
case ' ':
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
LaunchConfig();
|
|
||||||
return 0;
|
LaunchConfig();
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void LaunchConfig(void)
|
static void LaunchConfig(void)
|
||||||
{
|
{
|
||||||
/* FIXME: should this be called */
|
/* FIXME: should this be called */
|
||||||
RegisterDialogClasses(hMainInstance);
|
RegisterDialogClasses(hMainInstance);
|
||||||
/* display configure dialog */
|
|
||||||
DialogBox(hMainInstance, MAKEINTRESOURCE(DLG_SCRNSAVECONFIGURE),
|
|
||||||
GetForegroundWindow(), (DLGPROC) ScreenSaverConfigureDialog);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
/* display configure dialog */
|
||||||
|
DialogBox(hMainInstance, MAKEINTRESOURCE(DLG_SCRNSAVECONFIGURE),
|
||||||
|
GetForegroundWindow(), (DLGPROC) ScreenSaverConfigureDialog);
|
||||||
|
}
|
||||||
|
|
||||||
static int LaunchScreenSaver(HWND hParent)
|
static int LaunchScreenSaver(HWND hParent)
|
||||||
{
|
{
|
||||||
BOOL foo;
|
BOOL foo;
|
||||||
UINT style;
|
UINT style;
|
||||||
RECT rc;
|
RECT rc;
|
||||||
MSG msg;
|
MSG msg;
|
||||||
|
|
||||||
/* don't allow other tasks to get into the foreground */
|
/* don't allow other tasks to get into the foreground */
|
||||||
if (w95 && !fChildPreview)
|
if (w95 && !fChildPreview)
|
||||||
SystemParametersInfo(SPI_SCREENSAVERRUNNING, TRUE, &foo, 0);
|
SystemParametersInfo(SPI_SCREENSAVERRUNNING, TRUE, &foo, 0);
|
||||||
|
|
||||||
msg.wParam = 0;
|
msg.wParam = 0;
|
||||||
|
|
||||||
/* register classes, both user defined and classes used by screen saver
|
/* register classes, both user defined and classes used by screen saver
|
||||||
library */
|
library */
|
||||||
if (!RegisterClasses())
|
if (!RegisterClasses())
|
||||||
{
|
{
|
||||||
MessageBox(NULL, TEXT("RegisterClasses() failed"), NULL, MB_ICONHAND);
|
MessageBox(NULL, TEXT("RegisterClasses() failed"), NULL, MB_ICONHAND);
|
||||||
goto restore;
|
goto restore;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* a slightly different approach needs to be used when displaying
|
/* a slightly different approach needs to be used when displaying
|
||||||
in a preview window */
|
in a preview window */
|
||||||
if (hParent)
|
if (hParent)
|
||||||
{
|
{
|
||||||
style = WS_CHILD;
|
style = WS_CHILD;
|
||||||
GetClientRect(hParent, &rc);
|
GetClientRect(hParent, &rc);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
style = WS_POPUP;
|
style = WS_POPUP;
|
||||||
rc.right = GetSystemMetrics(SM_CXSCREEN);
|
rc.right = GetSystemMetrics(SM_CXSCREEN);
|
||||||
rc.bottom = GetSystemMetrics(SM_CYSCREEN);
|
rc.bottom = GetSystemMetrics(SM_CYSCREEN);
|
||||||
style |= WS_VISIBLE;
|
style |= WS_VISIBLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* create main screen saver window */
|
/* create main screen saver window */
|
||||||
hMainWindow = CreateWindowEx(hParent ? 0 : WS_EX_TOPMOST, CLASS_SCRNSAVE,
|
hMainWindow = CreateWindowEx(hParent ? 0 : WS_EX_TOPMOST, CLASS_SCRNSAVE,
|
||||||
TEXT("SCREENSAVER"), style,
|
TEXT("SCREENSAVER"), style,
|
||||||
0, 0, rc.right, rc.bottom, hParent, NULL,
|
0, 0, rc.right, rc.bottom, hParent, NULL,
|
||||||
hMainInstance, NULL);
|
hMainInstance, NULL);
|
||||||
|
|
||||||
/* display window and start pumping messages */
|
/* display window and start pumping messages */
|
||||||
if (hMainWindow)
|
if (hMainWindow)
|
||||||
{
|
{
|
||||||
UpdateWindow(hMainWindow);
|
UpdateWindow(hMainWindow);
|
||||||
ShowWindow(hMainWindow, SW_SHOW);
|
ShowWindow(hMainWindow, SW_SHOW);
|
||||||
|
|
||||||
while (GetMessage(&msg, NULL, 0, 0) == TRUE)
|
while (GetMessage(&msg, NULL, 0, 0) == TRUE)
|
||||||
{
|
{
|
||||||
TranslateMessage(&msg);
|
TranslateMessage(&msg);
|
||||||
DispatchMessage(&msg);
|
DispatchMessage(&msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
restore:
|
restore:
|
||||||
/* restore system */
|
/* restore system */
|
||||||
if (w95 && !fChildPreview)
|
if (w95 && !fChildPreview)
|
||||||
SystemParametersInfo(SPI_SCREENSAVERRUNNING, FALSE, &foo, 0);
|
SystemParametersInfo(SPI_SCREENSAVERRUNNING, FALSE, &foo, 0);
|
||||||
FreeLibrary(hPwdLib);
|
|
||||||
return msg.wParam;
|
FreeLibrary(hPwdLib);
|
||||||
|
return msg.wParam;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* this function takes care of *must* do tasks, like terminating
|
/* this function takes care of *must* do tasks, like terminating
|
||||||
screen saver */
|
screen saver */
|
||||||
static LRESULT WINAPI SysScreenSaverProc(HWND hWnd, UINT msg,
|
static LRESULT WINAPI SysScreenSaverProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||||
WPARAM wParam, LPARAM lParam)
|
|
||||||
{
|
{
|
||||||
switch (msg)
|
switch (msg)
|
||||||
{
|
{
|
||||||
case WM_CREATE:
|
case WM_CREATE:
|
||||||
if (!fChildPreview)
|
if (!fChildPreview)
|
||||||
SetCursor(NULL);
|
SetCursor(NULL);
|
||||||
/* mouse is not supposed to move from this position */
|
/* mouse is not supposed to move from this position */
|
||||||
GetCursorPos(&pt_orig);
|
GetCursorPos(&pt_orig);
|
||||||
break;
|
break;
|
||||||
case WM_DESTROY:
|
|
||||||
PostQuitMessage(0);
|
case WM_DESTROY:
|
||||||
break;
|
PostQuitMessage(0);
|
||||||
case WM_TIMER:
|
break;
|
||||||
if (closing)
|
|
||||||
return 0;
|
case WM_TIMER:
|
||||||
break;
|
if (closing)
|
||||||
case WM_PAINT:
|
return 0;
|
||||||
if (closing)
|
break;
|
||||||
return DefWindowProc(hWnd, msg, wParam, lParam);
|
|
||||||
break;
|
case WM_PAINT:
|
||||||
case WM_SYSCOMMAND:
|
if (closing)
|
||||||
if (!fChildPreview)
|
return DefWindowProc(hWnd, msg, wParam, lParam);
|
||||||
switch (wParam)
|
break;
|
||||||
{
|
|
||||||
case SC_CLOSE:
|
case WM_SYSCOMMAND:
|
||||||
case SC_SCREENSAVE:
|
if (!fChildPreview)
|
||||||
case SC_NEXTWINDOW:
|
{
|
||||||
case SC_PREVWINDOW:
|
switch (wParam)
|
||||||
return FALSE;
|
{
|
||||||
}
|
case SC_CLOSE:
|
||||||
break;
|
case SC_SCREENSAVE:
|
||||||
case WM_MOUSEMOVE:
|
case SC_NEXTWINDOW:
|
||||||
case WM_LBUTTONDOWN:
|
case SC_PREVWINDOW:
|
||||||
case WM_RBUTTONDOWN:
|
return FALSE;
|
||||||
case WM_MBUTTONDOWN:
|
}
|
||||||
case WM_KEYDOWN:
|
}
|
||||||
case WM_SYSKEYDOWN:
|
break;
|
||||||
case WM_NCACTIVATE:
|
|
||||||
case WM_ACTIVATE:
|
case WM_MOUSEMOVE:
|
||||||
case WM_ACTIVATEAPP:
|
case WM_LBUTTONDOWN:
|
||||||
if (closing)
|
case WM_RBUTTONDOWN:
|
||||||
return DefWindowProc(hWnd, msg, wParam, lParam);
|
case WM_MBUTTONDOWN:
|
||||||
break;
|
case WM_KEYDOWN:
|
||||||
|
case WM_SYSKEYDOWN:
|
||||||
|
case WM_NCACTIVATE:
|
||||||
|
case WM_ACTIVATE:
|
||||||
|
case WM_ACTIVATEAPP:
|
||||||
|
if (closing)
|
||||||
|
return DefWindowProc(hWnd, msg, wParam, lParam);
|
||||||
|
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
return ScreenSaverProc(hWnd, msg, wParam, lParam);
|
|
||||||
|
return ScreenSaverProc(hWnd, msg, wParam, lParam);
|
||||||
}
|
}
|
||||||
|
|
||||||
LONG WINAPI DefScreenSaverProc(HWND hWnd, UINT msg,
|
LONG WINAPI DefScreenSaverProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||||
WPARAM wParam, LPARAM lParam)
|
|
||||||
{
|
{
|
||||||
/* don't do any special processing when in preview mode */
|
/* don't do any special processing when in preview mode */
|
||||||
if (fChildPreview || closing)
|
if (fChildPreview || closing)
|
||||||
return DefWindowProc(hWnd, msg, wParam, lParam);
|
return DefWindowProc(hWnd, msg, wParam, lParam);
|
||||||
|
|
||||||
switch (msg)
|
switch (msg)
|
||||||
{
|
{
|
||||||
case WM_CLOSE:
|
case WM_CLOSE:
|
||||||
TerminateScreenSaver(hWnd);
|
TerminateScreenSaver(hWnd);
|
||||||
/* do NOT pass this to DefWindowProc; it will terminate even if
|
/* do NOT pass this to DefWindowProc; it will terminate even if
|
||||||
an invalid password was given.
|
an invalid password was given.
|
||||||
*/
|
*/
|
||||||
return 0;
|
return 0;
|
||||||
case SCRM_VERIFYPW:
|
|
||||||
/* verify password or return TRUE if password checking is turned off */
|
case SCRM_VERIFYPW:
|
||||||
if (VerifyScreenSavePwd)
|
/* verify password or return TRUE if password checking is turned off */
|
||||||
return VerifyScreenSavePwd(hWnd);
|
if (VerifyScreenSavePwd)
|
||||||
else
|
return VerifyScreenSavePwd(hWnd);
|
||||||
return TRUE;
|
else
|
||||||
case WM_SETCURSOR:
|
return TRUE;
|
||||||
if (checking_pwd)
|
|
||||||
break;
|
case WM_SETCURSOR:
|
||||||
SetCursor(NULL);
|
if (checking_pwd)
|
||||||
return TRUE;
|
break;
|
||||||
case WM_NCACTIVATE:
|
SetCursor(NULL);
|
||||||
case WM_ACTIVATE:
|
return TRUE;
|
||||||
case WM_ACTIVATEAPP:
|
|
||||||
if (wParam != FALSE)
|
case WM_NCACTIVATE:
|
||||||
break;
|
case WM_ACTIVATE:
|
||||||
case WM_MOUSEMOVE:
|
case WM_ACTIVATEAPP:
|
||||||
{
|
if (wParam != FALSE)
|
||||||
POINT pt;
|
break;
|
||||||
GetCursorPos(&pt);
|
|
||||||
if (pt.x == pt_orig.x && pt.y == pt_orig.y)
|
case WM_MOUSEMOVE:
|
||||||
break;
|
{
|
||||||
}
|
POINT pt;
|
||||||
case WM_LBUTTONDOWN:
|
GetCursorPos(&pt);
|
||||||
case WM_RBUTTONDOWN:
|
if (pt.x == pt_orig.x && pt.y == pt_orig.y)
|
||||||
case WM_MBUTTONDOWN:
|
break;
|
||||||
case WM_KEYDOWN:
|
}
|
||||||
case WM_SYSKEYDOWN:
|
|
||||||
/* try to terminate screen saver */
|
case WM_LBUTTONDOWN:
|
||||||
if (!checking_pwd)
|
case WM_RBUTTONDOWN:
|
||||||
PostMessage(hWnd, WM_CLOSE, 0, 0);
|
case WM_MBUTTONDOWN:
|
||||||
break;
|
case WM_KEYDOWN:
|
||||||
|
case WM_SYSKEYDOWN:
|
||||||
|
/* try to terminate screen saver */
|
||||||
|
if (!checking_pwd)
|
||||||
|
PostMessage(hWnd, WM_CLOSE, 0, 0);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
return DefWindowProc(hWnd, msg, wParam, lParam);
|
|
||||||
|
return DefWindowProc(hWnd, msg, wParam, lParam);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void TerminateScreenSaver(HWND hWnd)
|
static void TerminateScreenSaver(HWND hWnd)
|
||||||
{
|
{
|
||||||
/* don't allow recursion */
|
/* don't allow recursion */
|
||||||
if (checking_pwd || closing)
|
if (checking_pwd || closing)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
/* verify password */
|
/* verify password */
|
||||||
if (VerifyScreenSavePwd)
|
if (VerifyScreenSavePwd)
|
||||||
{
|
{
|
||||||
checking_pwd = TRUE;
|
checking_pwd = TRUE;
|
||||||
closing = SendMessage(hWnd, SCRM_VERIFYPW, 0, 0);
|
closing = SendMessage(hWnd, SCRM_VERIFYPW, 0, 0);
|
||||||
checking_pwd = FALSE;
|
checking_pwd = FALSE;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
closing = TRUE;
|
closing = TRUE;
|
||||||
|
|
||||||
/* are we closing? */
|
/* are we closing? */
|
||||||
if (closing)
|
if (closing)
|
||||||
{
|
{
|
||||||
DestroyWindow(hWnd);
|
DestroyWindow(hWnd);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
GetCursorPos(&pt_orig); /* if not: get new mouse position */
|
GetCursorPos(&pt_orig); /* if not: get new mouse position */
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Register screen saver window class and call user
|
Register screen saver window class and call user
|
||||||
supplied hook.
|
supplied hook.
|
||||||
*/
|
*/
|
||||||
static BOOL RegisterClasses(void)
|
static BOOL RegisterClasses(void)
|
||||||
{
|
{
|
||||||
WNDCLASS cls;
|
WNDCLASS cls;
|
||||||
ZeroMemory(&cls, sizeof(cls));
|
ZeroMemory(&cls, sizeof(cls));
|
||||||
cls.hCursor = NULL;
|
cls.hCursor = NULL;
|
||||||
cls.hIcon = LoadIcon(hMainInstance, MAKEINTATOM(ID_APP));
|
cls.hIcon = LoadIcon(hMainInstance, MAKEINTATOM(ID_APP));
|
||||||
cls.lpszMenuName = NULL;
|
cls.lpszMenuName = NULL;
|
||||||
cls.lpszClassName = CLASS_SCRNSAVE;
|
cls.lpszClassName = CLASS_SCRNSAVE;
|
||||||
cls.hbrBackground = NULL; //(HBRUSH)GetStockObject(BLACK_BRUSH);
|
cls.hbrBackground = NULL; //(HBRUSH)GetStockObject(BLACK_BRUSH);
|
||||||
cls.hInstance = hMainInstance;
|
cls.hInstance = hMainInstance;
|
||||||
cls.style = CS_VREDRAW | CS_HREDRAW | CS_SAVEBITS | CS_PARENTDC;
|
cls.style = CS_VREDRAW | CS_HREDRAW | CS_SAVEBITS | CS_PARENTDC;
|
||||||
cls.lpfnWndProc = (WNDPROC) SysScreenSaverProc;
|
cls.lpfnWndProc = (WNDPROC) SysScreenSaverProc;
|
||||||
cls.cbWndExtra = 0;
|
cls.cbWndExtra = 0;
|
||||||
cls.cbClsExtra = 0;
|
cls.cbClsExtra = 0;
|
||||||
|
|
||||||
if (!RegisterClass(&cls))
|
if (!RegisterClass(&cls))
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
|
||||||
return RegisterDialogClasses(hMainInstance);
|
return RegisterDialogClasses(hMainInstance);
|
||||||
}
|
}
|
||||||
|
|
||||||
void WINAPI ScreenSaverChangePassword(HWND hParent)
|
void WINAPI ScreenSaverChangePassword(HWND hParent)
|
||||||
{
|
{
|
||||||
/* load Master Password Router (MPR) */
|
/* load Master Password Router (MPR) */
|
||||||
HINSTANCE hMpr = LoadLibrary(TEXT("MPR.DLL"));
|
HINSTANCE hMpr = LoadLibrary(TEXT("MPR.DLL"));
|
||||||
|
|
||||||
if (hMpr)
|
if (hMpr)
|
||||||
{
|
{
|
||||||
CHPWDPROC ChangePassword;
|
CHPWDPROC ChangePassword;
|
||||||
ChangePassword = (CHPWDPROC) GetProcAddress(hMpr, szPwdChangePassword);
|
ChangePassword = (CHPWDPROC) GetProcAddress(hMpr, szPwdChangePassword);
|
||||||
|
|
||||||
/* change password for screen saver provider */
|
/* change password for screen saver provider */
|
||||||
if (ChangePassword)
|
if (ChangePassword)
|
||||||
ChangePassword(TEXT("SCRSAVE"), hParent, 0, NULL);
|
ChangePassword(TEXT("SCRSAVE"), hParent, 0, NULL);
|
||||||
|
|
||||||
FreeLibrary(hMpr);
|
FreeLibrary(hMpr);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
<?xml version="1.0"?>
|
<?xml version="1.0"?>
|
||||||
<!DOCTYPE group SYSTEM "../../../tools/rbuild/project.dtd">
|
<!DOCTYPE group SYSTEM "../../../tools/rbuild/project.dtd">
|
||||||
<group>
|
<group>
|
||||||
<module name="scrnsave" type="staticlibrary" allowwarnings="true">
|
<module name="scrnsave" type="staticlibrary">
|
||||||
<file>scrnsave.c</file>
|
<file>scrnsave.c</file>
|
||||||
</module>
|
</module>
|
||||||
</group>
|
</group>
|
Loading…
Add table
Add a link
Reference in a new issue