Fix indentation :)

svn path=/trunk/; revision=33351
This commit is contained in:
Colin Finck 2008-05-07 20:19:43 +00:00
parent 98d47d1fc4
commit e2c529ca16

View file

@ -23,79 +23,70 @@
#define RANDOM_COLOR (rand () % 256) #define RANDOM_COLOR (rand () % 256)
#define APPNAME _T("Circles") #define APPNAME _T("Circles")
#define APP_TIMER 1 #define APP_TIMER 1
#define APP_TIMER_INTERVAL 100 #define APP_TIMER_INTERVAL 100
#define MAX_CIRCLES 50 #define MAX_CIRCLES 50
int circlesCount; int circlesCount;
int width, x, y; int width, x, y;
LRESULT WINAPI ScreenSaverProc (HWND hwnd, UINT iMsg, WPARAM wparam, LRESULT WINAPI ScreenSaverProc (HWND hwnd, UINT iMsg, WPARAM wparam, LPARAM lparam)
LPARAM lparam)
{ {
HDC hdc; HDC hdc;
RECT rect; RECT rect;
HBRUSH hbrush, hbrushOld; HBRUSH hbrush, hbrushOld;
switch (iMsg) switch (iMsg)
{ {
case WM_CREATE: case WM_CREATE:
{ SetTimer (hwnd, APP_TIMER, APP_TIMER_INTERVAL, NULL);
SetTimer ( break;
hwnd,
APP_TIMER,
APP_TIMER_INTERVAL,
NULL);
}
break;
case WM_DESTROY:
{
KillTimer (hwnd, APP_TIMER);
PostQuitMessage (0);
return 0;
}
break;
case WM_TIMER:
{
hdc = GetDC (hwnd);
GetClientRect (hwnd, &rect);
hbrush = CreateSolidBrush (RGB (RANDOM_COLOR, RANDOM_COLOR, RANDOM_COLOR));
hbrushOld = SelectObject (hdc, hbrush);
x = rand () % rect.right; case WM_DESTROY:
y = rand () % rect.bottom; KillTimer (hwnd, APP_TIMER);
PostQuitMessage (0);
return 0;
/* the circle will be 10% of total screen */ case WM_TIMER:
width = rect.right / 10; hdc = GetDC (hwnd);
if (rect.bottom / 10 < width) GetClientRect (hwnd, &rect);
width = rect.bottom / 10; hbrush = CreateSolidBrush (RGB (RANDOM_COLOR, RANDOM_COLOR, RANDOM_COLOR));
hbrushOld = SelectObject (hdc, hbrush);
/* Draw circle on screen */ x = rand () % rect.right;
Ellipse ( y = rand () % rect.bottom;
hdc,
x,
y,
x + width,
y + width);
//Track the number of painted circles on scren /* the circle will be 10% of total screen */
circlesCount++; width = rect.right / 10;
if (circlesCount == MAX_CIRCLES) if (rect.bottom / 10 < width)
{ width = rect.bottom / 10;
InvalidateRect (hwnd, NULL, TRUE);
circlesCount = 0;
}
SelectObject (hdc, hbrushOld); /* Draw circle on screen */
DeleteObject (hbrush); Ellipse (
ReleaseDC (hwnd, hdc); hdc,
x,
y,
x + width,
y + width);
return 0; //Track the number of painted circles on scren
} circlesCount++;
} if (circlesCount == MAX_CIRCLES)
{
InvalidateRect (hwnd, NULL, TRUE);
circlesCount = 0;
}
return DefScreenSaverProc (hwnd, iMsg, wparam, lparam); SelectObject (hdc, hbrushOld);
DeleteObject (hbrush);
ReleaseDC (hwnd, hdc);
return 0;
}
}
return DefScreenSaverProc (hwnd, iMsg, wparam, lparam);
} }