2 * Copyright 2003 J Brown
3 * Copyright 2006 Eric Kohl
4 * Copyright 2007 Marc Piulachs (marc.piulachs@codexchange.net)
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.
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.
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
26 #define RANDOM( min, max ) ((rand() % (int)(((max)+1) - (min))) + (min))
28 #define APPNAME _T("Logon")
30 #define APP_TIMER_INTERVAL 2000
32 HBITMAP
GetScreenSaverBitmap (void)
36 ZeroMemory(&osvi
, sizeof(OSVERSIONINFOEX
));
37 osvi
.dwOSVersionInfoSize
= sizeof(OSVERSIONINFOEX
);
38 GetVersionEx ((OSVERSIONINFO
*) &osvi
);
40 switch(osvi
.wProductType
)
42 case VER_NT_WORKSTATION
:
43 return LoadImage(GetModuleHandle(NULL
), MAKEINTRESOURCE(IDB_WORKSTATION
), IMAGE_BITMAP
, 0, 0, LR_CREATEDIBSECTION
);
46 return LoadImage(GetModuleHandle(NULL
), MAKEINTRESOURCE(IDB_SERVER
), IMAGE_BITMAP
, 0, 0, LR_CREATEDIBSECTION
);
52 ScreenSaverProc(HWND hWnd
, UINT message
, WPARAM wParam
, LPARAM lParam
)
55 static HBITMAP bitmap
;
61 bitmap
= GetScreenSaverBitmap ();
67 _T("Fatal Error: Could not load bitmap"),
69 MB_OK
| MB_ICONEXCLAMATION
);
82 BITMAP bm
; /* Bitmap structure as seen in bmWidth & bmHeight */
85 // Obtain window coordinates.
86 GetClientRect (hWnd
, &rect
);
88 HDC hdc
= BeginPaint(hWnd
, &ps
);
89 HDC hdcMem
= CreateCompatibleDC(hdc
);
90 HBITMAP hbmOld
= SelectObject(hdcMem
, bitmap
);
92 GetObject(bitmap
, sizeof(bm
), &bm
);
94 if (rect
.right
< bm
.bmWidth
||
95 rect
.bottom
< bm
.bmHeight
)
99 RANDOM (0, rect
.right
- (bm
.bmWidth
/5)),
100 RANDOM (0, rect
.bottom
- (bm
.bmHeight
/5)),
114 RANDOM (0, rect
.right
- bm
.bmWidth
),
115 RANDOM (0, rect
.bottom
- bm
.bmHeight
),
124 SelectObject(hdcMem
, hbmOld
);
132 InvalidateRect(hWnd
, NULL
, 1);
137 KillTimer (hWnd
, APP_TIMER
);
138 DeleteObject(bitmap
);
144 // Pass Windows Messages to the default screensaver window procedure
145 return DefScreenSaverProc(hWnd
, message
, wParam
, lParam
);
151 BOOL WINAPI
ScreenSaverConfigureDialog(HWND hDlg
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
)
156 // This function is only called one time before opening the configuration dialog.
157 // Use it to show a message that no configuration is necesssary and return FALSE to indicate that no configuration dialog shall be opened.
158 BOOL WINAPI
RegisterDialogClasses(HANDLE hInst
)
160 TCHAR szMessage
[256];
163 LoadString(hInst
, IDS_TEXT
, szMessage
, sizeof(szMessage
) / sizeof(TCHAR
));
164 LoadString(hInst
, IDS_DESCRIPTION
, szTitle
, sizeof(szTitle
) / sizeof(TCHAR
));
166 MessageBox(NULL
, szMessage
, szTitle
, MB_OK
| MB_ICONEXCLAMATION
);