ReactOS  0.4.14-dev-342-gdc047f9
screensave.c File Reference
#include <windows.h>
#include <windowsx.h>
#include <tchar.h>
#include "globals.h"
#include "message.h"
#include "matrix.h"
#include "resource.h"
Include dependency graph for screensave.c:

Go to the source code of this file.

Functions

 HMONITOR (WINAPI *pfnEnumDisplayMonitors)(HDC
 
 BOOL (WINAPI *pfnGetMonitorInfo)(HMONITOR
 
BOOL CALLBACK MonitorEnumProc (HMONITOR hMonitor, HDC hdcMonitor, RECT *rcMonitor, LPARAM Param)
 
BOOL ScreenSaver (HWND hwndParent)
 
VOID ParseCommandLine (LPWSTR szCmdLine, UCHAR *chOption, HWND *hwndParent)
 
int CALLBACK wWinMain (HINSTANCE hInst, HINSTANCE hPrev, LPWSTR lpCmdLine, int iCmdShow)
 

Variables

 LPCRECT
 
 MONITORENUMPROC
 
 LPARAM
 
 LPMONITORINFO
 

Function Documentation

◆ BOOL()

BOOL ( WINAPI pfnGetMonitorInfo)

◆ HMONITOR()

HMONITOR ( WINAPI pfnEnumDisplayMonitors)

◆ MonitorEnumProc()

BOOL CALLBACK MonitorEnumProc ( HMONITOR  hMonitor,
HDC  hdcMonitor,
RECT rcMonitor,
LPARAM  Param 
)

Definition at line 33 of file screensave.c.

34 {
35  HWND hwnd;
36 
37  // Create a screensaver on this monitor!
38  hwnd = CreateScreenSaveWnd((HWND)Param, rcMonitor);
39 
40  // For some reason windows always places this window at 0,0...
41  // position it ourselves
42  SetWindowPos(hwnd, 0, rcMonitor->left, rcMonitor->top, 0, 0,
44 
45  return TRUE;
46 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
#define TRUE
Definition: types.h:120
LONG top
Definition: windef.h:292
LONG left
Definition: windef.h:291
#define SWP_NOZORDER
Definition: winuser.h:1232
#define SWP_NOACTIVATE
Definition: winuser.h:1227
HWND CreateScreenSaveWnd(HWND hwndParent, RECT *rect)
Definition: matrix.c:390
#define SWP_NOSIZE
Definition: winuser.h:1230
#define SWP_SHOWWINDOW
Definition: winuser.h:1233
BOOL WINAPI SetWindowPos(_In_ HWND, _In_opt_ HWND, _In_ int, _In_ int, _In_ int, _In_ int, _In_ UINT)

Referenced by CDesktopBrowser::_Resize(), and ScreenSaver().

◆ ParseCommandLine()

VOID ParseCommandLine ( LPWSTR  szCmdLine,
UCHAR chOption,
HWND hwndParent 
)

Definition at line 103 of file screensave.c.

104 {
105  UCHAR ch = *szCmdLine++;
106 
107  if(ch == '-' || ch == '/')
108  ch = *szCmdLine++;
109 
110  if(ch >= 'A' && ch <= 'Z')
111  ch += 'a' - 'A'; //convert to lower case
112 
113  *chOption = ch;
114  ch = *szCmdLine++;
115 
116  if(ch == ':')
117  ch = *szCmdLine++;
118 
119  while(ch == ' ' || ch == '\t')
120  ch = *szCmdLine++;
121 
122  if(isdigit(ch))
123  {
124  ULONG_PTR i = _wtoi(szCmdLine - 1);
125  *hwndParent = (HWND)i;
126  }
127  else
128  *hwndParent = NULL;
129 }
_Check_return_ _CRTIMP int __cdecl _wtoi(_In_z_ const wchar_t *_Str)
HANDLE HWND
Definition: compat.h:13
uint32_t ULONG_PTR
Definition: typedefs.h:63
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
smooth NULL
Definition: ftsmooth.c:416
static HWND hwndParent
Definition: cryptui.c:300
#define isdigit(c)
Definition: acclib.h:68
unsigned char UCHAR
Definition: xmlstorage.h:181

Referenced by wWinMain().

◆ ScreenSaver()

BOOL ScreenSaver ( HWND  hwndParent)

Definition at line 51 of file screensave.c.

52 {
53  HMODULE hUser32;
54  UINT nPreviousState;
55  MSG msg;
56 
58 
59  SystemParametersInfo(SPI_SETSCREENSAVERRUNNING, TRUE, &nPreviousState, 0);
60 
61  // Dynamically locate API call from USER32 - not present in all versions
62  hUser32 = GetModuleHandle(_T("USER32.DLL"));
63  pfnEnumDisplayMonitors = (PVOID)GetProcAddress(hUser32, "EnumDisplayMonitors");
64 
65  // If we're running Win2k+ then the API is available...so call it!
66  if(pfnEnumDisplayMonitors && hwndParent == 0)
67  {
68  pfnEnumDisplayMonitors(NULL, NULL, MonitorEnumProc, 0);
69  }
70  // Otherwise simulate by calling enum-proc manually
71  else
72  {
73  RECT rect;
74 
75  rect.left = 0;
77  rect.top = 0;
79 
81  }
82 
83  // run message loop to handle all screen-saver windows
84  while(GetMessage(&msg, NULL,0,0))
85  {
88  }
89 
90  SystemParametersInfo(SPI_SETSCREENSAVERRUNNING, FALSE, &nPreviousState, 0);
91 
92  return TRUE;
93 }
#define DispatchMessage
Definition: winuser.h:5666
BOOL WINAPI TranslateMessage(_In_ const MSG *)
#define TRUE
Definition: types.h:120
TW_UINT32 TW_UINT16 TW_UINT16 MSG
Definition: twain.h:1827
#define SystemParametersInfo
Definition: winuser.h:5759
& rect
Definition: startmenu.cpp:1413
BOOL CALLBACK MonitorEnumProc(HMONITOR hMonitor, HDC hdcMonitor, RECT *rcMonitor, LPARAM Param)
Definition: screensave.c:33
#define SM_CXSCREEN
Definition: winuser.h:949
smooth NULL
Definition: ftsmooth.c:416
static HWND hwndParent
Definition: cryptui.c:300
LONG_PTR LPARAM
Definition: windef.h:208
void * PVOID
Definition: retypes.h:9
#define SM_CYSCREEN
Definition: winuser.h:950
#define _T(x)
Definition: vfdio.h:22
int WINAPI GetSystemMetrics(_In_ int)
void InitScreenSaveClass(BOOL fPreview)
Definition: matrix.c:421
#define GetModuleHandle
Definition: winbase.h:3651
unsigned int UINT
Definition: ndis.h:50
#define GetMessage
Definition: winuser.h:5691
#define msg(x)
Definition: auth_time.c:54
#define GetProcAddress(x, y)
Definition: compat.h:418

Referenced by wWinMain().

◆ wWinMain()

int CALLBACK wWinMain ( HINSTANCE  hInstance,
HINSTANCE  hPrevInstance,
LPWSTR  lpCmdLine,
int  nShowCmd 
)

This file has no copyright assigned and is placed in the Public Domain. This file is part of the w64 mingw-runtime package. No warranty is given; refer to the file DISCLAIMER.PD within this package.

Definition at line 134 of file screensave.c.

135 {
137  UCHAR chOption;
138 
139  // Make sure that only 1 instance runs at a time -
140  // Win98 seems to want us to restart every 5 seconds!!
142  {
143  return 0;
144  }
145 
146  LoadSettings();
147 
148  ParseCommandLine(lpCmdLine, &chOption, &hwndParent);
149 
150  switch(chOption)
151  {
152  case 's': return ScreenSaver(NULL); // screen save
153  case 'p': return ScreenSaver(hwndParent); // preview in small window
154  case 'a': return ChangePassword(hwndParent); // ask for password
155  case 'c': return Configure(hwndParent); // configuration dialog
156  default: return Configure(hwndParent); // configuration dialog
157  }
158 
159  return 0;
160 }
VOID ParseCommandLine(LPWSTR szCmdLine, UCHAR *chOption, HWND *hwndParent)
Definition: screensave.c:103
BOOL ChangePassword(HWND hwnd)
Definition: password.c:48
BOOL ScreenSaver(HWND hwndParent)
Definition: screensave.c:51
void LoadSettings(void)
Definition: settings.c:53
smooth NULL
Definition: ftsmooth.c:416
static HWND hwndParent
Definition: cryptui.c:300
static LRESULT Configure(const CodecInfo *pi, HWND hWnd)
Definition: msrle32.c:1192
#define FindWindowEx
Definition: winuser.h:5679
unsigned char UCHAR
Definition: xmlstorage.h:181
#define APPNAME
Definition: 3dtext.c:40

Variable Documentation

◆ LPARAM

Definition at line 26 of file screensave.c.

◆ LPCRECT

Definition at line 26 of file screensave.c.

◆ LPMONITORINFO

Definition at line 27 of file screensave.c.

◆ MONITORENUMPROC

MONITORENUMPROC

Definition at line 26 of file screensave.c.