ReactOS  0.4.12-dev-14-gd0c8636
logon.c
Go to the documentation of this file.
1 /*
2  * Copyright 2003 J Brown
3  * Copyright 2006 Eric Kohl
4  * Copyright 2007 Marc Piulachs (marc.piulachs@codexchange.net)
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License along
17  * with this program; if not, write to the Free Software Foundation, Inc.,
18  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19  */
20 
21 #include <stdarg.h>
22 #include <windef.h>
23 #include <winbase.h>
24 #include <wingdi.h>
25 #include <winuser.h>
26 #include <scrnsave.h>
27 #include <stdlib.h>
28 #include <tchar.h>
29 
30 #include "resource.h"
31 
32 #define RANDOM( min, max ) ((rand() % (int)(((max)+1) - (min))) + (min))
33 
34 #define APPNAME _T("Logon")
35 #define APP_TIMER 1
36 #define APP_TIMER_INTERVAL 2000
37 
38 HBITMAP
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 }
57 
58 LRESULT
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 }
158 
159 BOOL
160 WINAPI
162 {
163  return FALSE;
164 }
165 
166 // This function is only called one time before opening the configuration dialog.
167 // Use it to show a message that no configuration is necessary and return FALSE to indicate that no configuration dialog shall be opened.
168 BOOL
169 WINAPI
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 VER_NT_WORKSTATION
#define HDC
Definition: msvc.h:22
#define MAKEINTRESOURCE
Definition: winuser.h:591
BOOL WINAPI ScreenSaverConfigureDialog(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: logon.c:161
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
#define IDB_WORKSTATION
Definition: resource.h:4
OSVERSIONINFO osvi
Definition: ver.c:28
#define IDS_DESCRIPTION
Definition: resource.h:92
#define CALLBACK
Definition: compat.h:27
HWND hWnd
Definition: settings.c:17
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1497
#define ZeroMemory
Definition: winbase.h:1635
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
BOOL WINAPI RegisterDialogClasses(HANDLE hInst)
Definition: logon.c:170
UINT_PTR WPARAM
Definition: windef.h:207
#define MB_ICONEXCLAMATION
Definition: winuser.h:779
LONG_PTR LPARAM
Definition: windef.h:208
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
char TCHAR
Definition: xmlstorage.h:189
#define _T(x)
Definition: vfdio.h:22
unsigned int BOOL
Definition: ntddk_ex.h:94
ULONG dwOSVersionInfoSize
Definition: rtltypes.h:251
#define WM_TIMER
Definition: winuser.h:1718
unsigned int UINT
Definition: ndis.h:50
BOOL WINAPI InvalidateRect(_In_opt_ HWND, _In_opt_ LPCRECT, _In_ BOOL)
#define GetObject
Definition: wingdi.h:4445
TCHAR szTitle[MAX_LOADSTRING]
Definition: magnifier.c:36
#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
#define IDB_SERVER
Definition: resource.h:5
#define WINAPI
Definition: msvc.h:20
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
HINSTANCE hInst
Definition: dxdiag.c:13
#define GetModuleHandle
Definition: winbase.h:3641
BOOL WINAPI DeleteDC(_In_ HDC)
Definition: bl.h:1331
#define LR_CREATEDIBSECTION
Definition: winuser.h:1088
#define GetVersionEx
Definition: winbase.h:3666
#define APP_TIMER
Definition: logon.c:35
#define MB_OK
Definition: winuser.h:784
#define IMAGE_BITMAP
Definition: winuser.h:211
OSVERSIONINFOEXA OSVERSIONINFOEX
Definition: rtltypes.h:286
#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
#define LoadImage
Definition: winuser.h:5681
static HBITMAP bitmap
Definition: clipboard.c:1344
#define IDS_TEXT
Definition: resource.h:3
LRESULT CALLBACK ScreenSaverProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
Definition: logon.c:60
LONG_PTR LRESULT
Definition: windef.h:209
LPARAM lParam
Definition: combotst.c:139
__analysis_noreturn void WINAPI PostQuitMessage(_In_ int)
#define SRCCOPY
Definition: wingdi.h:331
#define LoadString
Definition: winuser.h:5685
HDC hdcMem
Definition: welcome.c:104