ReactOS  0.4.12-dev-43-g63b00d8
logon.c File Reference
#include <stdarg.h>
#include <windef.h>
#include <winbase.h>
#include <wingdi.h>
#include <winuser.h>
#include <scrnsave.h>
#include <stdlib.h>
#include <tchar.h>
#include "resource.h"
Include dependency graph for logon.c:

Go to the source code of this file.

Macros

#define RANDOM(min, max)   ((rand() % (int)(((max)+1) - (min))) + (min))
 
#define APPNAME   _T("Logon")
 
#define APP_TIMER   1
 
#define APP_TIMER_INTERVAL   2000
 

Functions

HBITMAP GetScreenSaverBitmap (VOID)
 
LRESULT CALLBACK ScreenSaverProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
 
BOOL WINAPI ScreenSaverConfigureDialog (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
 
BOOL WINAPI RegisterDialogClasses (HANDLE hInst)
 

Macro Definition Documentation

◆ APP_TIMER

#define APP_TIMER   1

Definition at line 35 of file logon.c.

Referenced by ScreenSaverProc().

◆ APP_TIMER_INTERVAL

#define APP_TIMER_INTERVAL   2000

Definition at line 36 of file logon.c.

Referenced by ScreenSaverProc().

◆ APPNAME

#define APPNAME   _T("Logon")

Definition at line 34 of file logon.c.

◆ RANDOM

#define RANDOM (   min,
  max 
)    ((rand() % (int)(((max)+1) - (min))) + (min))

Definition at line 32 of file logon.c.

Referenced by ScreenSaverProc().

Function Documentation

◆ GetScreenSaverBitmap()

HBITMAP GetScreenSaverBitmap ( VOID  )

Definition at line 39 of file logon.c.

Referenced by ScreenSaverProc().

40 {
42 
43  ZeroMemory(&osvi, sizeof(OSVERSIONINFOEX));
44  osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX);
45  GetVersionEx ((OSVERSIONINFO *) &osvi);
46 
47  switch(osvi.wProductType)
48  {
49  case VER_NT_WORKSTATION:
51  break;
52  default:
54  break;
55  }
56 }
#define VER_NT_WORKSTATION
#define MAKEINTRESOURCE
Definition: winuser.h:591
#define IDB_WORKSTATION
Definition: resource.h:4
OSVERSIONINFO osvi
Definition: ver.c:28
#define ZeroMemory
Definition: winbase.h:1635
smooth NULL
Definition: ftsmooth.c:416
ULONG dwOSVersionInfoSize
Definition: rtltypes.h:251
#define IDB_SERVER
Definition: resource.h:5
#define GetModuleHandle
Definition: winbase.h:3641
#define LR_CREATEDIBSECTION
Definition: winuser.h:1088
#define GetVersionEx
Definition: winbase.h:3666
#define IMAGE_BITMAP
Definition: winuser.h:211
OSVERSIONINFOEXA OSVERSIONINFOEX
Definition: rtltypes.h:286
UCHAR wProductType
Definition: rtltypes.h:260
#define LoadImage
Definition: winuser.h:5681

◆ RegisterDialogClasses()

BOOL WINAPI RegisterDialogClasses ( HANDLE  hInst)

Definition at line 170 of file logon.c.

171 {
172  TCHAR szMessage[256];
173  TCHAR szTitle[25];
174 
175  LoadString(hInst, IDS_TEXT, szMessage, sizeof(szMessage) / sizeof(TCHAR));
176  LoadString(hInst, IDS_DESCRIPTION, szTitle, sizeof(szTitle) / sizeof(TCHAR));
177 
178  MessageBox(NULL, szMessage, szTitle, MB_OK | MB_ICONEXCLAMATION);
179 
180  return FALSE;
181 }
#define IDS_DESCRIPTION
Definition: resource.h:92
#define MB_ICONEXCLAMATION
Definition: winuser.h:779
smooth NULL
Definition: ftsmooth.c:416
char TCHAR
Definition: xmlstorage.h:189
TCHAR szTitle[MAX_LOADSTRING]
Definition: magnifier.c:36
#define MessageBox
Definition: winuser.h:5688
#define MB_OK
Definition: winuser.h:784
#define IDS_TEXT
Definition: resource.h:3
#define LoadString
Definition: winuser.h:5685

◆ ScreenSaverConfigureDialog()

BOOL WINAPI ScreenSaverConfigureDialog ( HWND  hDlg,
UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam 
)

Definition at line 161 of file logon.c.

162 {
163  return FALSE;
164 }

◆ ScreenSaverProc()

LRESULT CALLBACK ScreenSaverProc ( HWND  hWnd,
UINT  message,
WPARAM  wParam,
LPARAM  lParam 
)

Definition at line 60 of file logon.c.

61 {
62  static RECT rect;
63  static HBITMAP bitmap;
64 
65  switch (message)
66  {
67  case WM_CREATE:
68  {
69  bitmap = GetScreenSaverBitmap ();
70  if (bitmap == NULL)
71  {
72  MessageBox(hWnd,
73  _T("Fatal Error: Could not load bitmap"),
74  _T("Error"),
76  }
77 
78  SetTimer(hWnd,
79  APP_TIMER,
81  NULL);
82 
83  break;
84  }
85  case WM_PAINT:
86  {
87  BITMAP bm; /* Bitmap structure as seen in bmWidth & bmHeight */
88  PAINTSTRUCT ps;
89  HDC hdc;
90  HDC hdcMem;
91  HBITMAP hbmOld;
92 
93  // Obtain window coordinates.
94  GetClientRect (hWnd, &rect);
95 
96  hdc = BeginPaint(hWnd, &ps);
97  hdcMem = CreateCompatibleDC(hdc);
98  hbmOld = SelectObject(hdcMem, bitmap);
99 
100  GetObject(bitmap, sizeof(bm), &bm);
101 
102  if (rect.right < bm.bmWidth ||
103  rect.bottom < bm.bmHeight)
104  {
105  StretchBlt(
106  hdc,
107  RANDOM (0, rect.right - (bm.bmWidth /5)),
108  RANDOM (0, rect.bottom - (bm.bmHeight /5)),
109  bm.bmWidth /5,
110  bm.bmHeight /5,
111  hdcMem,
112  0,
113  0,
114  bm.bmWidth,
115  bm.bmHeight,
116  SRCCOPY);
117  }
118  else
119  {
120  BitBlt(
121  hdc,
122  RANDOM (0, rect.right - bm.bmWidth),
123  RANDOM (0, rect.bottom - bm.bmHeight),
124  bm.bmWidth,
125  bm.bmHeight,
126  hdcMem,
127  0,
128  0,
129  SRCCOPY);
130  }
131 
132  SelectObject(hdcMem, hbmOld);
133  DeleteDC(hdcMem);
134 
135  EndPaint(hWnd, &ps);
136  break;
137  }
138  case WM_TIMER:
139  {
140  InvalidateRect(hWnd, NULL, 1);
141  break;
142  }
143  case WM_DESTROY:
144  {
145  KillTimer(hWnd, APP_TIMER);
146  DeleteObject(bitmap);
147  PostQuitMessage(0);
148  break;
149  }
150 
151  default:
152  // Pass Windows Messages to the default screensaver window procedure
153  return DefScreenSaverProc(hWnd, message, wParam, lParam);
154  }
155 
156  return 0;
157 }
#define HDC
Definition: msvc.h:22
Definition: tftpd.h:59
HBITMAP GetScreenSaverBitmap(VOID)
Definition: logon.c:39
#define RANDOM(min, max)
Definition: logon.c:32
#define HBITMAP
Definition: msvc.h:28
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1497
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
HDC WINAPI CreateCompatibleDC(_In_opt_ HDC hdc)
BOOL WINAPI EndPaint(_In_ HWND, _In_ const PAINTSTRUCT *)
LONG right
Definition: windef.h:298
static VOID NTAPI BitBlt(IN ULONG Left, IN ULONG Top, IN ULONG Width, IN ULONG Height, IN PUCHAR Buffer, IN ULONG BitsPerPixel, IN ULONG Delta)
Definition: vga.c:416
BOOL WINAPI StretchBlt(_In_ HDC, _In_ int, _In_ int, _In_ int, _In_ int, _In_opt_ HDC, _In_ int, _In_ int, _In_ int, _In_ int, _In_ DWORD)
& rect
Definition: startmenu.cpp:1413
WPARAM wParam
Definition: combotst.c:138
#define MB_ICONEXCLAMATION
Definition: winuser.h:779
HDC WINAPI BeginPaint(_In_ HWND, _Out_ LPPAINTSTRUCT)
HDC hdc
Definition: msvc.h:53
smooth NULL
Definition: ftsmooth.c:416
UINT_PTR WINAPI SetTimer(_In_opt_ HWND, _In_ UINT_PTR, _In_ UINT, _In_opt_ TIMERPROC)
#define WM_DESTROY
Definition: winuser.h:1591
#define _T(x)
Definition: vfdio.h:22
#define WM_TIMER
Definition: winuser.h:1718
BOOL WINAPI InvalidateRect(_In_opt_ HWND, _In_opt_ LPCRECT, _In_ BOOL)
#define GetObject
Definition: wingdi.h:4445
#define WM_PAINT
Definition: winuser.h:1602
#define APP_TIMER_INTERVAL
Definition: logon.c:36
BOOL WINAPI KillTimer(_In_opt_ HWND, _In_ UINT_PTR)
#define MessageBox
Definition: winuser.h:5688
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
BOOL WINAPI DeleteDC(_In_ HDC)
Definition: bl.h:1331
#define APP_TIMER
Definition: logon.c:35
#define MB_OK
Definition: winuser.h:784
#define WM_CREATE
Definition: winuser.h:1590
LRESULT WINAPI DefScreenSaverProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
Definition: scrnsave.c:95
LONG bottom
Definition: windef.h:299
static HBITMAP bitmap
Definition: clipboard.c:1344
LPARAM lParam
Definition: combotst.c:139
__analysis_noreturn void WINAPI PostQuitMessage(_In_ int)
#define SRCCOPY
Definition: wingdi.h:331
HDC hdcMem
Definition: welcome.c:104