ReactOS 0.4.15-dev-8419-g7f0e8a3
circles.c
Go to the documentation of this file.
1/*
2 * Copyright 2008 Marc Piulachs (marc.piulachs@codexchange.net)
3 *
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.
8 *
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.
13 *
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
17 */
18
19#include <windows.h>
20#include <scrnsave.h>
21#include <tchar.h>
22#include "resource.h"
23
24#define RANDOM_COLOR (rand () % 256)
25
26#define APPNAME _T("Circles")
27#define APP_TIMER 1
28#define APP_TIMER_INTERVAL 100
29#define MAX_CIRCLES 50
30
32int width, x, y;
33
35{
36 HDC hdc;
37 RECT rect;
38 HBRUSH hbrush, hbrushOld;
39
40 switch (iMsg)
41 {
42 case WM_CREATE:
44 break;
45
46 case WM_DESTROY:
49 return 0;
50
51 case WM_TIMER:
52 hdc = GetDC (hwnd);
55 hbrushOld = SelectObject (hdc, hbrush);
56
57 x = rand () % rect.right;
58 y = rand () % rect.bottom;
59
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;
64
65 /* Draw circle on screen */
66 Ellipse (
67 hdc,
68 x,
69 y,
70 x + width,
71 y + width);
72
73 //Track the number of painted circles on scren
76 {
78 circlesCount = 0;
79 }
80
81 SelectObject (hdc, hbrushOld);
84
85 return 0;
86 }
87
88 return DefScreenSaverProc (hwnd, iMsg, wparam, lparam);
89}
90
91
93{
94 return FALSE;
95}
96
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.
100{
101 TCHAR szMessage[256];
102 TCHAR szTitle[25];
103
104 LoadString(hInst, IDS_TEXT, szMessage, sizeof(szMessage) / sizeof(TCHAR));
105 LoadString(hInst, IDS_DESCRIPTION, szTitle, sizeof(szTitle) / sizeof(TCHAR));
106
108
109 return FALSE;
110}
static HBRUSH hbrush
@ lparam
Definition: SystemMenu.c:31
@ wparam
Definition: SystemMenu.c:30
#define IDS_DESCRIPTION
Definition: resource.h:4
#define IDS_TEXT
Definition: resource.h:3
int y
Definition: circles.c:32
int circlesCount
Definition: circles.c:31
int width
Definition: circles.c:32
#define APP_TIMER_INTERVAL
Definition: circles.c:28
#define RANDOM_COLOR
Definition: circles.c:24
int x
Definition: circles.c:32
#define MAX_CIRCLES
Definition: circles.c:29
#define APP_TIMER
Definition: circles.c:27
BOOL WINAPI ScreenSaverConfigureDialog(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: circles.c:92
LRESULT WINAPI ScreenSaverProc(HWND hwnd, UINT iMsg, WPARAM wparam, LPARAM lparam)
Definition: circles.c:34
BOOL WINAPI RegisterDialogClasses(HANDLE hInst)
Definition: circles.c:99
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
#define RGB(r, g, b)
Definition: precomp.h:71
HINSTANCE hInst
Definition: dxdiag.c:13
unsigned int BOOL
Definition: ntddk_ex.h:94
pKey DeleteObject()
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
GLint GLint GLsizei width
Definition: gl.h:1546
_Check_return_ int __cdecl rand(void)
Definition: rand.c:10
TCHAR szTitle[MAX_LOADSTRING]
Definition: magnifier.c:35
HDC hdc
Definition: main.c:9
static HDC
Definition: imagelist.c:92
unsigned int UINT
Definition: ndis.h:50
LRESULT WINAPI DefScreenSaverProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
Definition: scrnsave.c:92
& rect
Definition: startmenu.cpp:1413
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023
LONG_PTR LPARAM
Definition: windef.h:208
LONG_PTR LRESULT
Definition: windef.h:209
UINT_PTR WPARAM
Definition: windef.h:207
#define WINAPI
Definition: msvc.h:6
BOOL WINAPI Ellipse(_In_ HDC, _In_ int, _In_ int, _In_ int, _In_ int)
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1546
HBRUSH WINAPI CreateSolidBrush(_In_ COLORREF)
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
#define WM_CREATE
Definition: winuser.h:1608
__analysis_noreturn void WINAPI PostQuitMessage(_In_ int)
UINT_PTR WINAPI SetTimer(_In_opt_ HWND, _In_ UINT_PTR, _In_ UINT, _In_opt_ TIMERPROC)
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
#define WM_TIMER
Definition: winuser.h:1742
HDC WINAPI GetDC(_In_opt_ HWND)
#define MB_ICONEXCLAMATION
Definition: winuser.h:785
#define MB_OK
Definition: winuser.h:790
#define LoadString
Definition: winuser.h:5828
#define MessageBox
Definition: winuser.h:5831
#define WM_DESTROY
Definition: winuser.h:1609
BOOL WINAPI InvalidateRect(_In_opt_ HWND, _In_opt_ LPCRECT, _In_ BOOL)
BOOL WINAPI KillTimer(_In_opt_ HWND, _In_ UINT_PTR)
char TCHAR
Definition: xmlstorage.h:189