2 * Copyright 2008 Marc Piulachs (marc.piulachs@codexchange.net)
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program; if not, write to the Free Software
16 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
24 #define RANDOM_COLOR (rand () % 256)
26 #define APPNAME _T("Circles")
28 #define APP_TIMER_INTERVAL 100
29 #define MAX_CIRCLES 50
34 LRESULT WINAPI
ScreenSaverProc (HWND hwnd
, UINT iMsg
, WPARAM wparam
, LPARAM lparam
)
38 HBRUSH hbrush
, hbrushOld
;
43 SetTimer (hwnd
, APP_TIMER
, APP_TIMER_INTERVAL
, NULL
);
47 KillTimer (hwnd
, APP_TIMER
);
53 GetClientRect (hwnd
, &rect
);
54 hbrush
= CreateSolidBrush (RGB (RANDOM_COLOR
, RANDOM_COLOR
, RANDOM_COLOR
));
55 hbrushOld
= SelectObject (hdc
, hbrush
);
57 x
= rand () % rect
.right
;
58 y
= rand () % rect
.bottom
;
60 /* the circle will be 10% of total screen */
61 width
= rect
.right
/ 10;
62 if (rect
.bottom
/ 10 < width
)
63 width
= rect
.bottom
/ 10;
65 /* Draw circle on screen */
73 //Track the number of painted circles on scren
75 if (circlesCount
== MAX_CIRCLES
)
77 InvalidateRect (hwnd
, NULL
, TRUE
);
81 SelectObject (hdc
, hbrushOld
);
82 DeleteObject (hbrush
);
83 ReleaseDC (hwnd
, hdc
);
88 return DefScreenSaverProc (hwnd
, iMsg
, wparam
, lparam
);
92 BOOL WINAPI
ScreenSaverConfigureDialog(HWND hDlg
, UINT uMsg
, WPARAM wParam
, LPARAM lParam
)
97 // This function is only called one time before opening the configuration dialog.
98 // Use it to show a message that no configuration is necesssary and return FALSE to indicate that no configuration dialog shall be opened.
99 BOOL WINAPI
RegisterDialogClasses(HANDLE hInst
)
101 TCHAR szMessage
[256];
104 LoadString(hInst
, IDS_TEXT
, szMessage
, sizeof(szMessage
) / sizeof(TCHAR
));
105 LoadString(hInst
, IDS_DESCRIPTION
, szTitle
, sizeof(szTitle
) / sizeof(TCHAR
));
107 MessageBox(NULL
, szMessage
, szTitle
, MB_OK
| MB_ICONEXCLAMATION
);