ReactOS 0.4.15-dev-7113-g9ea2222
screensaver.c File Reference
#include "desk.h"
Include dependency graph for screensaver.c:

Go to the source code of this file.

Classes

struct  SCREEN_SAVER_ITEM
 
struct  _DATA
 

Macros

#define MAX_SCREENSAVERS   100
 

Typedefs

typedef struct _DATA DATA
 
typedef struct _DATAPDATA
 

Functions

static LPTSTR GetCurrentScreenSaverValue (LPTSTR lpValue)
 
static VOID SelectionChanged (HWND hwndDlg, PDATA pData)
 
LRESULT CALLBACK RedrawSubclassProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
 
static VOID ShowScreenSaverPreview (IN LPDRAWITEMSTRUCT draw, IN PDATA pData)
 
static VOID SetScreenSaverPreviewBox (HWND hwndDlg, PDATA pData)
 
static BOOL WaitForSettingsDialog (HWND hwndDlg, HANDLE hProcess)
 
static VOID ScreenSaverConfig (HWND hwndDlg, PDATA pData)
 
static VOID ScreenSaverPreview (HWND hwndDlg, PDATA pData)
 
static VOID CheckRegScreenSaverIsSecure (HWND hwndDlg)
 
static BOOL AddScreenSaverItem (_In_ HWND hwndScreenSavers, _In_ PDATA pData, _In_ SCREEN_SAVER_ITEM *ScreenSaverItem)
 
static BOOL AddScreenSaver (_In_ HWND hwndScreenSavers, _In_ PDATA pData, _In_ LPCTSTR pszFilePath, _In_ LPCTSTR pszFileName)
 
static VOID SearchScreenSavers (_In_ HWND hwndScreenSavers, _In_ PDATA pData, _In_ LPCTSTR pszSearchPath)
 
static VOID EnumScreenSavers (_In_ HWND hwndScreenSavers, _In_ PDATA pData)
 
static VOID SetScreenSaver (HWND hwndDlg, PDATA pData)
 
static BOOL OnInitDialog (HWND hwndDlg, PDATA pData)
 
INT_PTR CALLBACK ScreenSaverPageProc (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
 

Variables

static const TCHAR szPreviewWndClass [] = TEXT("SSDemoParent")
 

Macro Definition Documentation

◆ MAX_SCREENSAVERS

#define MAX_SCREENSAVERS   100

Definition at line 13 of file screensaver.c.

Typedef Documentation

◆ DATA

typedef struct _DATA DATA

◆ PDATA

typedef struct _DATA * PDATA

Function Documentation

◆ AddScreenSaver()

static BOOL AddScreenSaver ( _In_ HWND  hwndScreenSavers,
_In_ PDATA  pData,
_In_ LPCTSTR  pszFilePath,
_In_ LPCTSTR  pszFileName 
)
static

Definition at line 442 of file screensaver.c.

447{
448 SCREEN_SAVER_ITEM* ScreenSaverItem;
450 HRESULT hr;
451
452 if (pData->ScreenSaverCount >= MAX_SCREENSAVERS)
453 return FALSE;
454
455 ScreenSaverItem = pData->ScreenSaverItems + pData->ScreenSaverCount;
456
457 ScreenSaverItem->bIsScreenSaver = TRUE;
458
459 hModule = LoadLibraryEx(pszFilePath,
460 NULL,
462 if (hModule)
463 {
465 1,
466 ScreenSaverItem->szDisplayName,
467 _countof(ScreenSaverItem->szDisplayName)) == 0)
468 {
469 /* If the string does not exist, copy the file name */
470 hr = StringCbCopy(ScreenSaverItem->szDisplayName,
471 sizeof(ScreenSaverItem->szDisplayName),
473 if (FAILED(hr))
474 {
476 return FALSE;
477 }
478 /* Remove the .scr extension */
479 ScreenSaverItem->szDisplayName[_tcslen(pszFileName)-4] = _T('\0');
480 }
482 }
483 else
484 {
485 hr = StringCbCopy(ScreenSaverItem->szDisplayName,
486 sizeof(ScreenSaverItem->szDisplayName),
487 _T("Unknown"));
488 if (FAILED(hr))
489 return FALSE;
490 }
491
492 hr = StringCbCopy(ScreenSaverItem->szFilename,
493 sizeof(ScreenSaverItem->szFilename),
494 pszFilePath);
495 if (FAILED(hr))
496 return FALSE;
497
498 return AddScreenSaverItem(hwndScreenSavers, pData, ScreenSaverItem);
499}
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
static BOOL AddScreenSaverItem(_In_ HWND hwndScreenSavers, _In_ PDATA pData, _In_ SCREEN_SAVER_ITEM *ScreenSaverItem)
Definition: screensaver.c:415
#define MAX_SCREENSAVERS
Definition: screensaver.c:13
HMODULE hModule
Definition: animate.c:44
#define FreeLibrary(x)
Definition: compat.h:748
#define FAILED(hr)
Definition: intsafe.h:51
HRESULT hr
Definition: shlfolder.c:183
#define _countof(array)
Definition: sndvol32.h:68
#define StringCbCopy
Definition: strsafe.h:155
TCHAR szDisplayName[256]
Definition: screensaver.c:21
TCHAR szFilename[MAX_PATH]
Definition: screensaver.c:20
TW_UINT32 TW_UINT16 TW_UINT16 TW_MEMREF pData
Definition: twain.h:1830
WORD WORD PSZ PSZ pszFileName
Definition: vdmdbg.h:44
#define _T(x)
Definition: vfdio.h:22
#define LoadLibraryEx
Definition: winbase.h:3798
#define LOAD_LIBRARY_AS_DATAFILE
Definition: winbase.h:342
#define DONT_RESOLVE_DLL_REFERENCES
Definition: winbase.h:341
#define LoadString
Definition: winuser.h:5818
#define _tcslen
Definition: xmlstorage.h:198

Referenced by OnInitDialog(), and SearchScreenSavers().

◆ AddScreenSaverItem()

static BOOL AddScreenSaverItem ( _In_ HWND  hwndScreenSavers,
_In_ PDATA  pData,
_In_ SCREEN_SAVER_ITEM ScreenSaverItem 
)
static

Definition at line 415 of file screensaver.c.

419{
420 UINT i;
421
422 if (pData->ScreenSaverCount >= MAX_SCREENSAVERS)
423 return FALSE;
424
425 i = SendMessage(hwndScreenSavers,
427 0,
428 (LPARAM)ScreenSaverItem->szDisplayName);
429 if ((i == CB_ERR) || (i == CB_ERRSPACE))
430 return FALSE;
431
432 SendMessage(hwndScreenSavers,
434 i,
435 (LPARAM)pData->ScreenSaverCount);
436
437 pData->ScreenSaverCount++;
438 return TRUE;
439}
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
unsigned int UINT
Definition: ndis.h:50
LONG_PTR LPARAM
Definition: windef.h:208
#define CB_SETITEMDATA
Definition: winuser.h:1965
#define CB_ERRSPACE
Definition: winuser.h:2435
#define CB_ERR
Definition: winuser.h:2434
#define CB_ADDSTRING
Definition: winuser.h:1935
#define SendMessage
Definition: winuser.h:5842

Referenced by AddScreenSaver(), and EnumScreenSavers().

◆ CheckRegScreenSaverIsSecure()

static VOID CheckRegScreenSaverIsSecure ( HWND  hwndDlg)
static

Definition at line 370 of file screensaver.c.

371{
372 HKEY hKey;
373 TCHAR szBuffer[2];
374 DWORD bufferSize = sizeof(szBuffer);
375 DWORD varType = REG_SZ;
376 LONG result;
377
379 _T("Control Panel\\Desktop"),
380 0,
382 &hKey) == ERROR_SUCCESS)
383 {
385 _T("ScreenSaverIsSecure"),
386 0,
387 &varType,
388 (LPBYTE)szBuffer,
389 &bufferSize);
391
392 if (result == ERROR_SUCCESS)
393 {
394 if (_ttoi(szBuffer) == 1)
395 {
396 SendDlgItemMessage(hwndDlg,
400 0);
401 return;
402 }
403 }
404
405 SendDlgItemMessage(hwndDlg,
409 0);
410 }
411}
#define RegCloseKey(hKey)
Definition: registry.h:49
#define ERROR_SUCCESS
Definition: deptool.c:10
#define IDC_SCREENS_USEPASSCHK
Definition: resource.h:44
unsigned long DWORD
Definition: ntddk_ex.h:95
FxAutoRegKey hKey
size_t bufferSize
GLuint64EXT * result
Definition: glext.h:11304
#define REG_SZ
Definition: layer.c:22
#define KEY_ALL_ACCESS
Definition: nt_native.h:1041
long LONG
Definition: pedump.c:60
unsigned char * LPBYTE
Definition: typedefs.h:53
UINT_PTR WPARAM
Definition: windef.h:207
#define HKEY_CURRENT_USER
Definition: winreg.h:11
#define RegOpenKeyEx
Definition: winreg.h:520
#define RegQueryValueEx
Definition: winreg.h:524
#define BST_UNCHECKED
Definition: winuser.h:199
#define BM_SETCHECK
Definition: winuser.h:1920
#define SendDlgItemMessage
Definition: winuser.h:5841
#define BST_CHECKED
Definition: winuser.h:197
char TCHAR
Definition: xmlstorage.h:189
#define _ttoi
Definition: xmlstorage.h:195

Referenced by OnInitDialog().

◆ EnumScreenSavers()

static VOID EnumScreenSavers ( _In_ HWND  hwndScreenSavers,
_In_ PDATA  pData 
)
static

Definition at line 544 of file screensaver.c.

547{
548 SCREEN_SAVER_ITEM* ScreenSaverItem;
549 PTCHAR pBackSlash;
550 TCHAR szSearchPath[MAX_PATH];
551 TCHAR szLocalPath[MAX_PATH];
552
553 /* Initialize the number of list items */
554 pData->ScreenSaverCount = 0;
555
556 /* Add the "(None)" item */
557 ScreenSaverItem = pData->ScreenSaverItems;
558
559 ScreenSaverItem->bIsScreenSaver = FALSE;
560
562 IDS_NONE,
563 ScreenSaverItem->szDisplayName,
564 _countof(ScreenSaverItem->szDisplayName));
565
566 AddScreenSaverItem(hwndScreenSavers, pData, ScreenSaverItem);
567
568 /* Add all the screensavers where the applet is stored */
569 GetModuleFileName(hApplet, szLocalPath, _countof(szLocalPath));
570 pBackSlash = _tcsrchr(szLocalPath, _T('\\'));
571 if (pBackSlash != NULL)
572 {
573 *pBackSlash = _T('\0');
574 SearchScreenSavers(hwndScreenSavers, pData, szLocalPath);
575 }
576
577 /* Add all the screensavers in the C:\ReactOS\System32 directory */
578 GetSystemDirectory(szSearchPath, _countof(szSearchPath));
579 if (pBackSlash != NULL && _tcsicmp(szSearchPath, szLocalPath) != 0)
580 SearchScreenSavers(hwndScreenSavers, pData, szSearchPath);
581
582 /* Add all the screensavers in the C:\ReactOS directory */
583 GetWindowsDirectory(szSearchPath, _countof(szSearchPath));
584 if (pBackSlash != NULL && _tcsicmp(szSearchPath, szLocalPath) != 0)
585 SearchScreenSavers(hwndScreenSavers, pData, szSearchPath);
586}
#define IDS_NONE
Definition: resource.h:133
HINSTANCE hApplet
Definition: access.c:17
static VOID SearchScreenSavers(_In_ HWND hwndScreenSavers, _In_ PDATA pData, _In_ LPCTSTR pszSearchPath)
Definition: screensaver.c:502
#define MAX_PATH
Definition: compat.h:34
#define _tcsrchr
Definition: utility.h:116
char * PTCHAR
Definition: ntbasedef.h:476
#define GetWindowsDirectory
Definition: winbase.h:3792
#define GetSystemDirectory
Definition: winbase.h:3777
#define GetModuleFileName
Definition: winbase.h:3766
#define _tcsicmp
Definition: xmlstorage.h:205

Referenced by OnInitDialog().

◆ GetCurrentScreenSaverValue()

static LPTSTR GetCurrentScreenSaverValue ( LPTSTR  lpValue)
static

Definition at line 37 of file screensaver.c.

38{
39 HKEY hKey;
40 LPTSTR lpBuf = NULL;
42 LONG Ret;
43
45 _T("Control Panel\\Desktop"),
46 0,
48 &hKey);
49 if (Ret != ERROR_SUCCESS)
50 return NULL;
51
53 lpValue,
54 0,
55 &Type,
56 NULL,
57 &BufSize);
58 if (Ret == ERROR_SUCCESS)
59 {
60 lpBuf = HeapAlloc(GetProcessHeap(), 0, BufSize);
61 if (lpBuf)
62 {
64 lpValue,
65 0,
66 &Type,
67 (LPBYTE)lpBuf,
68 &BufSize);
69 if (Ret != ERROR_SUCCESS)
70 {
71 HeapFree(GetProcessHeap(), 0, lpBuf);
72 lpBuf = NULL;
73 }
74 }
75 }
76
78
79 return lpBuf;
80}
#define BufSize
Definition: FsRtlTunnel.c:28
Type
Definition: Type.h:7
#define GetProcessHeap()
Definition: compat.h:736
#define HeapAlloc
Definition: compat.h:733
#define HeapFree(x, y, z)
Definition: compat.h:735
#define KEY_READ
Definition: nt_native.h:1023
CHAR * LPTSTR
Definition: xmlstorage.h:192

Referenced by OnInitDialog().

◆ OnInitDialog()

static BOOL OnInitDialog ( HWND  hwndDlg,
PDATA  pData 
)
static

Definition at line 661 of file screensaver.c.

662{
663 HWND hwndSSCombo = GetDlgItem(hwndDlg, IDC_SCREENS_LIST);
664 LPTSTR pSsValue;
665 INT iCurSs;
666 WNDCLASS wc = {0};
667
669 if (!pData)
670 {
671 EndDialog(hwndDlg, -1);
672 return FALSE;
673 }
674
676 wc.hInstance = hApplet;
677 wc.hCursor = NULL;
680
681 if (RegisterClass(&wc))
682 {
683 HWND hParent = GetDlgItem(hwndDlg, IDC_SCREENS_PREVIEW);
684 HWND hChild;
685
686 if (hParent != NULL)
687 {
688 pData->OldPreviewProc = (WNDPROC)GetWindowLongPtr(hParent, GWLP_WNDPROC);
691 }
692
695 0, 0, 0, 0, hParent,
696 NULL, hApplet, NULL);
697 if (hChild != NULL)
698 {
699 RECT rc;
700 GetClientRect(hParent, &rc);
701 rc.left += MONITOR_LEFT;
702 rc.top += MONITOR_TOP;
704 }
705
706 pData->ScreenSaverPreviewParent = hChild;
707 }
708
710
711 pData->Selection = -1;
712
713 SendDlgItemMessage(hwndDlg,
716 0,
717 MAKELONG(240, 1));
718
719 EnumScreenSavers(hwndSSCombo, pData);
720
722
723 /* Set the current screensaver in the combo box */
724 iCurSs = 0; // Default to "(None)"
725 pSsValue = GetCurrentScreenSaverValue(_T("SCRNSAVE.EXE"));
726 if (pSsValue)
727 {
728 BOOL bFound = FALSE;
729 INT i;
730
731 /* Find whether the current screensaver is in the list */
732 for (i = 0; i < pData->ScreenSaverCount; i++)
733 {
734 if (!_tcsicmp(pSsValue, pData->ScreenSaverItems[i].szFilename))
735 {
736 bFound = TRUE;
737 break;
738 }
739 }
740
741 if (!bFound)
742 {
743 /* The current screensaver is not in the list: add it */
744 // i = pData->ScreenSaverCount;
745 bFound = AddScreenSaver(hwndSSCombo, pData, pSsValue, _T("SCRNSAVE.EXE"));
746 if (bFound)
747 i = pData->ScreenSaverCount - 1;
748 }
749
750 HeapFree(GetProcessHeap(), 0, pSsValue);
751
752 if (bFound)
753 {
754 /* The current screensaver should be in the list: select it */
755 iCurSs = SendMessage(hwndSSCombo,
757 -1,
758 (LPARAM)pData->ScreenSaverItems[i].szDisplayName);
759 if (iCurSs == CB_ERR)
760 iCurSs = 0; // Default to "(None)"
761 }
762 }
763 SendMessage(hwndSSCombo, CB_SETCURSEL, iCurSs, 0);
764
765 /* Set the current timeout */
766 pSsValue = GetCurrentScreenSaverValue(_T("ScreenSaveTimeOut"));
767 if (pSsValue)
768 {
769 UINT Time = _ttoi(pSsValue) / 60;
770
771 HeapFree(GetProcessHeap(), 0, pSsValue);
772
773 SendDlgItemMessage(hwndDlg,
776 0,
777 Time);
778 }
779
780 SelectionChanged(hwndDlg, pData);
781
782 return TRUE;
783}
#define MONITOR_HEIGHT
Definition: desk.h:77
#define MONITOR_LEFT
Definition: desk.h:71
#define MONITOR_TOP
Definition: desk.h:72
#define MONITOR_WIDTH
Definition: desk.h:76
#define IDC_SCREENS_PREVIEW
Definition: resource.h:39
#define IDC_SCREENS_TIME
Definition: resource.h:46
#define IDC_SCREENS_LIST
Definition: resource.h:40
static LPTSTR GetCurrentScreenSaverValue(LPTSTR lpValue)
Definition: screensaver.c:37
static VOID SelectionChanged(HWND hwndDlg, PDATA pData)
Definition: screensaver.c:84
static VOID EnumScreenSavers(_In_ HWND hwndScreenSavers, _In_ PDATA pData)
Definition: screensaver.c:544
static const TCHAR szPreviewWndClass[]
Definition: screensaver.c:15
static VOID CheckRegScreenSaverIsSecure(HWND hwndDlg)
Definition: screensaver.c:370
LRESULT CALLBACK RedrawSubclassProc(HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: screensaver.c:110
static BOOL AddScreenSaver(_In_ HWND hwndScreenSavers, _In_ PDATA pData, _In_ LPCTSTR pszFilePath, _In_ LPCTSTR pszFileName)
Definition: screensaver.c:442
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
unsigned int BOOL
Definition: ntddk_ex.h:94
static HTREEITEM hChild
Definition: treeview.c:381
static PLARGE_INTEGER Time
Definition: time.c:105
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
#define WS_CHILD
Definition: pedump.c:617
#define WS_CLIPCHILDREN
Definition: pedump.c:619
#define UDM_SETRANGE
Definition: commctrl.h:2141
#define UDM_SETPOS32
Definition: commctrl.h:2155
#define DefWindowProc
Definition: ros2win.h:31
HBRUSH hbrBackground
Definition: winuser.h:3169
HINSTANCE hInstance
Definition: winuser.h:3166
HCURSOR hCursor
Definition: winuser.h:3168
LPCSTR lpszClassName
Definition: winuser.h:3171
WNDPROC lpfnWndProc
Definition: winuser.h:3163
LONG top
Definition: windef.h:307
LONG left
Definition: windef.h:306
#define GetWindowLongPtr
Definition: treelist.c:73
#define SetWindowLongPtr
Definition: treelist.c:70
#define GWLP_WNDPROC
Definition: treelist.c:66
#define GWLP_USERDATA
Definition: treelist.c:63
int32_t INT
Definition: typedefs.h:58
#define MAKELONG(a, b)
Definition: typedefs.h:249
HGDIOBJ WINAPI GetStockObject(_In_ int)
#define BLACK_BRUSH
Definition: wingdi.h:896
#define CreateWindowEx
Definition: winuser.h:5754
#define DWLP_USER
Definition: winuser.h:871
#define CB_SETCURSEL
Definition: winuser.h:1960
#define CB_FINDSTRINGEXACT
Definition: winuser.h:1939
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
#define RegisterClass
Definition: winuser.h:5835
LRESULT(CALLBACK * WNDPROC)(HWND, UINT, WPARAM, LPARAM)
Definition: winuser.h:2905
BOOL WINAPI MoveWindow(_In_ HWND, _In_ int, _In_ int, _In_ int, _In_ int, _In_ BOOL)
BOOL WINAPI EndDialog(_In_ HWND, _In_ INT_PTR)

Referenced by ScreenSaverPageProc().

◆ RedrawSubclassProc()

LRESULT CALLBACK RedrawSubclassProc ( HWND  hwndDlg,
UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam 
)

Definition at line 110 of file screensaver.c.

114{
115 HWND hwnd;
116 PDATA pData;
117 LRESULT Ret = FALSE;
118
120 if (!pData)
121 return Ret;
122
123 Ret = CallWindowProc(pData->OldPreviewProc, hwndDlg, uMsg, wParam, lParam);
124
125 if (uMsg == WM_PAINT)
126 {
127 hwnd = pData->ScreenSaverPreviewParent;
128 if (hwnd)
130 }
131
132 return Ret;
133}
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139
struct _DATA * PDATA
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023
LONG_PTR LRESULT
Definition: windef.h:209
#define WM_PAINT
Definition: winuser.h:1619
BOOL WINAPI RedrawWindow(_In_opt_ HWND, _In_opt_ LPCRECT, _In_opt_ HRGN, _In_ UINT)
#define CallWindowProc
Definition: winuser.h:5734
#define RDW_ERASE
Definition: winuser.h:1210
#define RDW_ALLCHILDREN
Definition: winuser.h:1220
#define RDW_INVALIDATE
Definition: winuser.h:1213

Referenced by OnInitDialog().

◆ ScreenSaverConfig()

static VOID ScreenSaverConfig ( HWND  hwndDlg,
PDATA  pData 
)
static

Definition at line 271 of file screensaver.c.

272{
273 HRESULT hr;
274 STARTUPINFO si;
276 TCHAR szCmdline[2048];
277
278 if (pData->Selection < 1)
279 return;
280
281 hr = StringCbPrintf(szCmdline, sizeof(szCmdline),
282 TEXT("%s /c:%Iu"),
283 pData->ScreenSaverItems[pData->Selection].szFilename,
284 (ULONG_PTR)hwndDlg);
285 if (FAILED(hr))
286 return;
287
288 ZeroMemory(&si, sizeof(si));
289 si.cb = sizeof(si);
290 ZeroMemory(&pi, sizeof(pi));
292 szCmdline,
293 NULL,
294 NULL,
295 FALSE,
296 0,
297 NULL,
298 NULL,
299 &si,
300 &pi))
301 {
302 /* Kill off the previous preview process */
303 if (pData->PrevWindowPi.hProcess)
304 {
305 TerminateProcess(pData->PrevWindowPi.hProcess, 0);
306 CloseHandle(pData->PrevWindowPi.hProcess);
307 CloseHandle(pData->PrevWindowPi.hThread);
308 pData->PrevWindowPi.hThread = pData->PrevWindowPi.hProcess = NULL;
309 }
310
311 if (WaitForSettingsDialog(hwndDlg, pi.hProcess))
313
314 CloseHandle(pi.hProcess);
315 CloseHandle(pi.hThread);
316 }
317}
static VOID SetScreenSaverPreviewBox(HWND hwndDlg, PDATA pData)
Definition: screensaver.c:178
static BOOL WaitForSettingsDialog(HWND hwndDlg, HANDLE hProcess)
Definition: screensaver.c:227
#define CloseHandle
Definition: compat.h:739
BOOL WINAPI TerminateProcess(IN HANDLE hProcess, IN UINT uExitCode)
Definition: proc.c:1532
#define TEXT(s)
Definition: k32.h:26
static refpint_t pi[]
Definition: server.c:96
#define StringCbPrintf
Definition: strsafe.h:544
DWORD cb
Definition: winbase.h:831
uint32_t ULONG_PTR
Definition: typedefs.h:65
#define CreateProcess
Definition: winbase.h:3693
#define ZeroMemory
Definition: winbase.h:1712

Referenced by ScreenSaverPageProc().

◆ ScreenSaverPageProc()

INT_PTR CALLBACK ScreenSaverPageProc ( HWND  hwndDlg,
UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam 
)

Definition at line 787 of file screensaver.c.

791{
792 PDATA pData;
793
795
796 switch (uMsg)
797 {
798 case WM_INITDIALOG:
799 {
800 OnInitDialog(hwndDlg, pData);
801 break;
802 }
803
804 case WM_DESTROY:
805 {
806 if (pData->ScreenSaverPreviewParent)
807 {
810 (LONG_PTR)pData->OldPreviewProc);
811 DestroyWindow(pData->ScreenSaverPreviewParent);
812 pData->ScreenSaverPreviewParent = NULL;
813 }
815 if (pData->PrevWindowPi.hProcess)
816 {
817 TerminateProcess(pData->PrevWindowPi.hProcess, 0);
818 CloseHandle(pData->PrevWindowPi.hProcess);
819 CloseHandle(pData->PrevWindowPi.hThread);
820 }
822 break;
823 }
824
825 case WM_ENDSESSION:
826 {
828 break;
829 }
830
831 case WM_DRAWITEM:
832 {
833 LPDRAWITEMSTRUCT lpDrawItem;
834 lpDrawItem = (LPDRAWITEMSTRUCT)lParam;
835
836 if (lpDrawItem->CtlID == IDC_SCREENS_PREVIEW)
837 ShowScreenSaverPreview(lpDrawItem, pData);
838 break;
839 }
840
841 case WM_COMMAND:
842 {
843 DWORD controlId = LOWORD(wParam);
845
846 switch (controlId)
847 {
848 case IDC_SCREENS_LIST:
849 {
851 {
852 SelectionChanged(hwndDlg, pData);
854 PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
855 }
856 break;
857 }
858
860 {
861 if (command == EN_CHANGE)
862 PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
863 break;
864 }
865
866 case IDC_SCREENS_POWER_BUTTON: // Start Powercfg.Cpl
867 {
868 if (command == BN_CLICKED)
869 WinExec("rundll32 shell32.dll,Control_RunDLL powercfg.cpl",SW_SHOWNORMAL);
870 break;
871 }
872
873 case IDC_SCREENS_TESTSC: // Screensaver Preview
874 {
875 if (command == BN_CLICKED)
876 {
877 ScreenSaverPreview(hwndDlg, pData);
879 }
880 break;
881 }
882
883 case IDC_SCREENS_SETTINGS: // Screensaver Settings
884 {
885 if (command == BN_CLICKED)
886 ScreenSaverConfig(hwndDlg, pData);
887 break;
888 }
889
890 case IDC_SCREENS_USEPASSCHK: // Screensaver Is Secure
891 {
892 if (command == BN_CLICKED)
893 PropSheet_Changed(GetParent(hwndDlg), hwndDlg);
894 break;
895 }
896 }
897 break;
898 }
899
900 case WM_NOTIFY:
901 {
902 LPNMHDR lpnm = (LPNMHDR)lParam;
903
904 switch(lpnm->code)
905 {
906 case PSN_APPLY:
907 {
908 SetScreenSaver(hwndDlg, pData);
909 return TRUE;
910 }
911
912 case PSN_SETACTIVE:
913 {
914 /* Enable screensaver preview support */
916 break;
917 }
918
919 case PSN_KILLACTIVE:
920 {
921 /* Kill running preview screensaver */
922 if (pData->PrevWindowPi.hProcess)
923 {
924 TerminateProcess(pData->PrevWindowPi.hProcess, 0);
925 CloseHandle(pData->PrevWindowPi.hProcess);
926 CloseHandle(pData->PrevWindowPi.hThread);
927 pData->PrevWindowPi.hThread = pData->PrevWindowPi.hProcess = NULL;
928 }
929 break;
930 }
931 }
932 }
933 break;
934 }
935
936 return FALSE;
937}
#define IDC_SCREENS_TIMEDELAY
Definition: resource.h:45
#define IDC_SCREENS_POWER_BUTTON
Definition: resource.h:41
#define IDC_SCREENS_TESTSC
Definition: resource.h:43
#define IDC_SCREENS_SETTINGS
Definition: resource.h:42
static VOID ShowScreenSaverPreview(IN LPDRAWITEMSTRUCT draw, IN PDATA pData)
Definition: screensaver.c:137
static VOID ScreenSaverPreview(HWND hwndDlg, PDATA pData)
Definition: screensaver.c:323
static VOID SetScreenSaver(HWND hwndDlg, PDATA pData)
Definition: screensaver.c:590
static BOOL OnInitDialog(HWND hwndDlg, PDATA pData)
Definition: screensaver.c:661
static VOID ScreenSaverConfig(HWND hwndDlg, PDATA pData)
Definition: screensaver.c:271
UINT WINAPI DECLSPEC_HOTPATCH WinExec(LPCSTR lpCmdLine, UINT uCmdShow)
Definition: proc.c:4773
#define LOWORD(l)
Definition: pedump.c:82
#define PropSheet_Changed(d, w)
Definition: prsht.h:344
#define PSN_KILLACTIVE
Definition: prsht.h:116
#define PSN_APPLY
Definition: prsht.h:117
#define PSN_SETACTIVE
Definition: prsht.h:115
#define WM_NOTIFY
Definition: richedit.h:61
UINT code
Definition: winuser.h:3158
#define HIWORD(l)
Definition: typedefs.h:247
#define SW_SHOWNORMAL
Definition: winuser.h:769
struct tagDRAWITEMSTRUCT * LPDRAWITEMSTRUCT
#define WM_COMMAND
Definition: winuser.h:1739
#define UnregisterClass
Definition: winuser.h:5860
#define WM_INITDIALOG
Definition: winuser.h:1738
#define WM_DRAWITEM
Definition: winuser.h:1644
#define CBN_SELCHANGE
Definition: winuser.h:1978
struct tagNMHDR * LPNMHDR
HWND WINAPI GetParent(_In_ HWND)
#define BN_CLICKED
Definition: winuser.h:1924
#define WM_DESTROY
Definition: winuser.h:1608
#define WM_ENDSESSION
Definition: winuser.h:1626
BOOL WINAPI DestroyWindow(_In_ HWND)
#define EN_CHANGE
Definition: winuser.h:2021

◆ ScreenSaverPreview()

static VOID ScreenSaverPreview ( HWND  hwndDlg,
PDATA  pData 
)
static

Definition at line 323 of file screensaver.c.

324{
325 HRESULT hr;
326 STARTUPINFO si;
328 TCHAR szCmdline[2048];
329
330 if (pData->Selection < 1)
331 return;
332
333 /* Kill off the previous preview process */
334 if (pData->PrevWindowPi.hProcess)
335 {
336 TerminateProcess(pData->PrevWindowPi.hProcess, 0);
337 CloseHandle(pData->PrevWindowPi.hProcess);
338 CloseHandle(pData->PrevWindowPi.hThread);
339 pData->PrevWindowPi.hThread = pData->PrevWindowPi.hProcess = NULL;
340 }
341
342 hr = StringCbPrintf(szCmdline, sizeof(szCmdline),
343 TEXT("%s /s"),
344 pData->ScreenSaverItems[pData->Selection].szFilename);
345 if (FAILED(hr))
346 return;
347
348 ZeroMemory(&si, sizeof(si));
349 si.cb = sizeof(si);
350 ZeroMemory(&pi, sizeof(pi));
352 szCmdline,
353 NULL,
354 NULL,
355 FALSE,
356 0,
357 NULL,
358 NULL,
359 &si,
360 &pi))
361 {
363 CloseHandle(pi.hProcess);
364 CloseHandle(pi.hThread);
365 }
366}
#define INFINITE
Definition: serial.h:102
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82

Referenced by ScreenSaverPageProc().

◆ SearchScreenSavers()

static VOID SearchScreenSavers ( _In_ HWND  hwndScreenSavers,
_In_ PDATA  pData,
_In_ LPCTSTR  pszSearchPath 
)
static

Definition at line 502 of file screensaver.c.

506{
507 HRESULT hr;
509 HANDLE hFind;
511
513 TEXT("%s\\*.scr"), pszSearchPath);
514 if (FAILED(hr))
515 return;
516
517 hFind = FindFirstFile(szFilePath, &fd);
518 if (hFind == INVALID_HANDLE_VALUE)
519 return;
520
521 do
522 {
523 /* Don't add any hidden screensavers */
524 if (fd.dwFileAttributes & FILE_ATTRIBUTE_HIDDEN)
525 continue;
526
527 if (pData->ScreenSaverCount >= MAX_SCREENSAVERS)
528 break;
529
531 TEXT("%s\\%s"), pszSearchPath, fd.cFileName);
532 if (FAILED(hr))
533 break;
534
535 if (!AddScreenSaver(hwndScreenSavers, pData, szFilePath, fd.cFileName))
536 break;
537
538 } while (FindNextFile(hFind, &fd));
539
540 FindClose(hFind);
541}
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
BOOL WINAPI FindClose(HANDLE hFindFile)
Definition: find.c:502
#define FILE_ATTRIBUTE_HIDDEN
Definition: nt_native.h:703
static WCHAR szFilePath[]
Definition: qotd.c:14
static int fd
Definition: io.c:51
#define FindNextFile
Definition: winbase.h:3723
#define FindFirstFile
Definition: winbase.h:3717

Referenced by EnumScreenSavers().

◆ SelectionChanged()

static VOID SelectionChanged ( HWND  hwndDlg,
PDATA  pData 
)
static

Definition at line 84 of file screensaver.c.

85{
86 HWND hwndCombo;
88 INT i;
89
90 hwndCombo = GetDlgItem(hwndDlg, IDC_SCREENS_LIST);
91
92 i = (INT)SendMessage(hwndCombo, CB_GETCURSEL, 0, 0);
93 i = (INT)SendMessage(hwndCombo, CB_GETITEMDATA, i, 0);
94
95 pData->Selection = i;
96
97 bEnable = (i != 0);
98
106}
#define IDC_MINTEXT
Definition: resource.h:48
#define IDC_WAITTEXT
Definition: resource.h:47
#define INT
Definition: polytest.cpp:20
_In_ BOOL bEnable
Definition: winddi.h:3426
#define CB_GETITEMDATA
Definition: winuser.h:1949
BOOL WINAPI EnableWindow(_In_ HWND, _In_ BOOL)
#define CB_GETCURSEL
Definition: winuser.h:1942

Referenced by OnInitDialog(), and ScreenSaverPageProc().

◆ SetScreenSaver()

static VOID SetScreenSaver ( HWND  hwndDlg,
PDATA  pData 
)
static

Definition at line 590 of file screensaver.c.

591{
592 HKEY regKey;
593 BOOL DeleteMode = FALSE;
594
596
598 _T("Control Panel\\Desktop"),
599 0,
601 &regKey) == ERROR_SUCCESS)
602 {
603 INT Time;
604 BOOL bRet;
605 TCHAR Sec;
606 UINT Ret;
607
608 /* Set the screensaver */
609 if (pData->ScreenSaverItems[pData->Selection].bIsScreenSaver)
610 {
611 SIZE_T Length = (_tcslen(pData->ScreenSaverItems[pData->Selection].szFilename) + 1) * sizeof(TCHAR);
612 RegSetValueEx(regKey,
613 _T("SCRNSAVE.EXE"),
614 0,
615 REG_SZ,
616 (PBYTE)pData->ScreenSaverItems[pData->Selection].szFilename,
617 (DWORD)Length);
618
620 }
621 else
622 {
623 /* Windows deletes the value if no screensaver is set */
624 RegDeleteValue(regKey, _T("SCRNSAVE.EXE"));
625 DeleteMode = TRUE;
626
628 }
629
630 /* Set the secure value */
631 Ret = SendDlgItemMessage(hwndDlg,
634 0,
635 0);
636 Sec = (Ret == BST_CHECKED) ? _T('1') : _T('0');
637 RegSetValueEx(regKey,
638 _T("ScreenSaverIsSecure"),
639 0,
640 REG_SZ,
641 (PBYTE)&Sec,
642 sizeof(TCHAR));
643
644 /* Set the screensaver time delay */
645 Time = GetDlgItemInt(hwndDlg,
647 &bRet,
648 FALSE);
649 if (Time == 0)
650 Time = 1;
651 Time *= 60; // Convert to seconds
652
654
655 RegCloseKey(regKey);
656 }
657}
#define DBG_UNREFERENCED_LOCAL_VARIABLE(L)
Definition: ntbasedef.h:319
_In_ ULONG _In_ ULONG _In_ ULONG Length
Definition: ntddpcm.h:102
BYTE * PBYTE
Definition: pedump.c:66
UINT Sec[]
Definition: powershemes.c:41
ULONG_PTR SIZE_T
Definition: typedefs.h:80
#define RegSetValueEx
Definition: winreg.h:533
#define RegDeleteValue
Definition: winreg.h:508
#define SPI_SETSCREENSAVEACTIVE
Definition: winuser.h:1365
#define SPIF_SENDCHANGE
Definition: winuser.h:1571
#define SPIF_UPDATEINIFILE
Definition: winuser.h:1570
BOOL WINAPI SystemParametersInfoW(_In_ UINT uiAction, _In_ UINT uiParam, _Inout_opt_ PVOID pvParam, _In_ UINT fWinIni)
UINT WINAPI GetDlgItemInt(_In_ HWND, _In_ int, _Out_opt_ PBOOL, _In_ BOOL)
#define SystemParametersInfo
Definition: winuser.h:5857
#define SPI_SETSCREENSAVETIMEOUT
Definition: winuser.h:1363
#define BM_GETCHECK
Definition: winuser.h:1917

Referenced by ScreenSaverPageProc().

◆ SetScreenSaverPreviewBox()

static VOID SetScreenSaverPreviewBox ( HWND  hwndDlg,
PDATA  pData 
)
static

Definition at line 178 of file screensaver.c.

179{
180 HWND hPreview = pData->ScreenSaverPreviewParent;
181 HRESULT hr;
182 STARTUPINFO si;
183 TCHAR szCmdline[2048];
184
185 /* Kill off the previous preview process */
186 if (pData->PrevWindowPi.hProcess)
187 {
188 TerminateProcess(pData->PrevWindowPi.hProcess, 0);
189 CloseHandle(pData->PrevWindowPi.hProcess);
190 CloseHandle(pData->PrevWindowPi.hThread);
191 pData->PrevWindowPi.hThread = pData->PrevWindowPi.hProcess = NULL;
192 }
193 ShowWindow(pData->ScreenSaverPreviewParent, SW_HIDE);
194
195 if (pData->Selection < 1)
196 return;
197
198 hr = StringCbPrintf(szCmdline, sizeof(szCmdline),
199 TEXT("%s /p %Iu"),
200 pData->ScreenSaverItems[pData->Selection].szFilename,
201 (ULONG_PTR)hPreview);
202 if (FAILED(hr))
203 return;
204
205 ZeroMemory(&si, sizeof(si));
206 si.cb = sizeof(si);
207 ZeroMemory(&pData->PrevWindowPi, sizeof(pData->PrevWindowPi));
208
209 ShowWindow(pData->ScreenSaverPreviewParent, SW_SHOW);
210
211 if (!CreateProcess(NULL,
212 szCmdline,
213 NULL,
214 NULL,
215 FALSE,
216 0,
217 NULL,
218 NULL,
219 &si,
220 &pData->PrevWindowPi))
221 {
222 pData->PrevWindowPi.hThread = pData->PrevWindowPi.hProcess = NULL;
223 }
224}
#define SW_HIDE
Definition: winuser.h:767
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
#define SW_SHOW
Definition: winuser.h:774

Referenced by ScreenSaverConfig(), and ScreenSaverPageProc().

◆ ShowScreenSaverPreview()

static VOID ShowScreenSaverPreview ( IN LPDRAWITEMSTRUCT  draw,
IN PDATA  pData 
)
static

Definition at line 137 of file screensaver.c.

138{
139 HBRUSH hBrush;
140 HDC hDC;
141 HGDIOBJ hOldObj;
142 RECT rcItem = {
147 };
148
149 hDC = CreateCompatibleDC(draw->hDC);
151
152 if (!IsWindowVisible(pData->ScreenSaverPreviewParent))
153 {
154 /* FIXME: Draw static bitmap inside monitor. */
156 FillRect(hDC, &rcItem, hBrush);
157 DeleteObject(hBrush);
158 }
159
160 GdiTransparentBlt(draw->hDC,
161 draw->rcItem.left, draw->rcItem.top,
162 draw->rcItem.right - draw->rcItem.left + 1,
163 draw->rcItem.bottom - draw->rcItem.top + 1,
164 hDC,
165 0, 0,
168
169 SelectObject(hDC, hOldObj);
170 DeleteDC(hDC);
171}
static HDC hDC
Definition: 3dtext.c:33
GLOBAL_DATA g_GlobalData
Definition: background.c:70
#define MONITOR_BOTTOM
Definition: desk.h:74
#define MONITOR_ALPHA
Definition: desk.h:79
#define MONITOR_RIGHT
Definition: desk.h:73
pKey DeleteObject()
static HDC
Definition: imagelist.c:92
LONG bmMonHeight
Definition: desk.h:164
LONG bmMonWidth
Definition: desk.h:163
COLORREF desktop_color
Definition: desk.h:159
HBITMAP hMonitorBitmap
Definition: desk.h:162
BOOL WINAPI GdiTransparentBlt(HDC hdcDst, int xDst, int yDst, int wDst, int hDst, HDC hdcSrc, int xSrc, int ySrc, int wSrc, int hSrc, UINT crTransparent)
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1539
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
int WINAPI FillRect(HDC, LPCRECT, HBRUSH)
HBRUSH WINAPI CreateSolidBrush(_In_ COLORREF)
BOOL WINAPI DeleteDC(_In_ HDC)
BOOL WINAPI IsWindowVisible(_In_ HWND)

Referenced by ScreenSaverPageProc().

◆ WaitForSettingsDialog()

static BOOL WaitForSettingsDialog ( HWND  hwndDlg,
HANDLE  hProcess 
)
static

Definition at line 227 of file screensaver.c.

229{
230 DWORD dwResult;
231 MSG msg;
232
233 while (TRUE)
234 {
235 dwResult = MsgWaitForMultipleObjects(1,
236 &hProcess,
237 FALSE,
238 INFINITE,
240 if (dwResult == WAIT_OBJECT_0 + 1)
241 {
242 if (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
243 {
244 if (msg.message == WM_QUIT)
245 {
246 return FALSE;
247 }
248 if (IsDialogMessage(hwndDlg, &msg))
249 {
252 }
253 }
254 }
255 else if (dwResult == WAIT_OBJECT_0)
256 {
257 return TRUE;
258 }
259 else
260 {
261 return FALSE;
262 }
263 }
264}
#define msg(x)
Definition: auth_time.c:54
_In_ BOOL _In_ HANDLE hProcess
Definition: mapping.h:71
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1829
#define WAIT_OBJECT_0
Definition: winbase.h:406
#define WM_QUIT
Definition: winuser.h:1622
BOOL WINAPI TranslateMessage(_In_ const MSG *)
#define IsDialogMessage
Definition: winuser.h:5808
#define QS_ALLINPUT
Definition: winuser.h:902
DWORD WINAPI MsgWaitForMultipleObjects(_In_ DWORD nCount, _In_reads_opt_(nCount) CONST HANDLE *pHandles, _In_ BOOL fWaitAll, _In_ DWORD dwMilliseconds, _In_ DWORD dwWakeMask)
#define PM_REMOVE
Definition: winuser.h:1195
#define PeekMessage
Definition: winuser.h:5829
#define DispatchMessage
Definition: winuser.h:5764

Referenced by ScreenSaverConfig().

Variable Documentation

◆ szPreviewWndClass

const TCHAR szPreviewWndClass[] = TEXT("SSDemoParent")
static

Definition at line 15 of file screensaver.c.

Referenced by OnInitDialog(), and ScreenSaverPageProc().