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 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.
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 */
88 // Obtain window coordinates.
89 GetClientRect (hWnd
, &rect
);
91 hdc
= BeginPaint(hWnd
, &ps
);
92 hdcMem
= CreateCompatibleDC(hdc
);
93 hbmOld
= SelectObject(hdcMem
, bitmap
);
95 GetObject(bitmap
, sizeof(bm
), &bm
);
97 if (rect
.right
< bm
.bmWidth
||
98 rect
.bottom
< bm
.bmHeight
)
102 RANDOM (0, rect
.right
- (bm
.bmWidth
/5)),
103 RANDOM (0, rect
.bottom
- (bm
.bmHeight
/5)),
117 RANDOM (0, rect
.right
- bm
.bmWidth
),
118 RANDOM (0, rect
.bottom
- bm
.bmHeight
),
127 SelectObject(hdcMem
, hbmOld
);
135 InvalidateRect(hWnd
, NULL
, 1);
140 KillTimer (hWnd
, APP_TIMER
);
141 DeleteObject(bitmap
);
147 // Pass Windows Messages to the default screensaver window procedure
148 return DefScreenSaverProc(hWnd
, message
, wParam
, lParam
);
154 BOOL WINAPI
ScreenSaverConfigureDialog(HWND hDlg
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
)
159 // This function is only called one time before opening the configuration dialog.
160 // Use it to show a message that no configuration is necesssary and return FALSE to indicate that no configuration dialog shall be opened.
161 BOOL WINAPI
RegisterDialogClasses(HANDLE hInst
)
163 TCHAR szMessage
[256];
166 LoadString(hInst
, IDS_TEXT
, szMessage
, sizeof(szMessage
) / sizeof(TCHAR
));
167 LoadString(hInst
, IDS_DESCRIPTION
, szTitle
, sizeof(szTitle
) / sizeof(TCHAR
));
169 MessageBox(NULL
, szMessage
, szTitle
, MB_OK
| MB_ICONEXCLAMATION
);