#define TWOPI (2 * 3.14159)\r
\r
static const TCHAR szClockWndClass[] = TEXT("ClockWndClass");\r
+static HBRUSH hGreyBrush = NULL;\r
+static HPEN hGreyPen = NULL;\r
\r
-\r
-VOID SetIsotropic(HDC hdc, INT cxClient, INT cyClient)\r
+static VOID \r
+SetIsotropic(HDC hdc, INT cxClient, INT cyClient)\r
{\r
/* set isotropic mode */\r
SetMapMode(hdc, MM_ISOTROPIC);\r
SetViewportOrgEx(hdc, cxClient / 2, cyClient / 2, NULL);\r
}\r
\r
-VOID RotatePoint(POINT pt[], INT iNum, INT iAngle)\r
+static VOID \r
+RotatePoint(POINT pt[], INT iNum, INT iAngle)\r
{\r
INT i;\r
POINT ptTemp;\r
}\r
}\r
\r
-VOID DrawClock(HDC hdc)\r
+static VOID \r
+DrawClock(HDC hdc)\r
{\r
INT iAngle;\r
POINT pt[3];\r
- HBRUSH hBrush, hBrushOld;\r
- HPEN hPen = NULL, hPenOld = NULL;\r
+ HBRUSH hBrushOld;\r
+ HPEN hPenOld = NULL;\r
+\r
+ /* grey brush to fill the dots */ \r
+ hBrushOld = SelectObject(hdc, hGreyBrush);\r
\r
- /* grey brush to fill the dots */\r
- hBrush = CreateSolidBrush(RGB(128, 128, 128));\r
- hBrushOld = SelectObject(hdc, hBrush);\r
+ hPenOld = GetCurrentObject(hdc, OBJ_PEN);\r
\r
for(iAngle = 0; iAngle < 360; iAngle += 6)\r
{\r
* i.e. 1-4 or 5, 6-9 or 10, 11-14 or 15 */\r
if (iAngle % 5)\r
{\r
- pt[2].x = pt[2].y = 7;\r
- hPen = CreatePen(PS_SOLID, 1, RGB(128, 128, 128));\r
- hPenOld = SelectObject(hdc, hPen);\r
-\r
+ pt[2].x = pt[2].y = 7; \r
+ SelectObject(hdc, hGreyPen);\r
}\r
else\r
{\r
Ellipse(hdc, pt[0].x, pt[0].y, pt[1].x, pt[1].y);\r
\r
}\r
-\r
- SelectObject(hdc, hPenOld);\r
+ \r
SelectObject(hdc, hBrushOld);\r
- DeleteObject(hBrush);\r
- DeleteObject(hPen);\r
+ SelectObject(hdc, hPenOld);\r
}\r
\r
-VOID DrawHands(HDC hdc, SYSTEMTIME * pst, BOOL fChange)\r
+static VOID \r
+DrawHands(HDC hdc, SYSTEMTIME * pst, BOOL fChange)\r
{\r
static POINT pt[3][5] = { {{0, -30}, {20, 0}, {0, 100}, {-20, 0}, {0, -30}},\r
{{0, -40}, {10, 0}, {0, 160}, {-10, 0}, {0, -40}},\r
WPARAM wParam,\r
LPARAM lParam)\r
{\r
+ \r
static INT cxClient, cyClient;\r
static SYSTEMTIME stPrevious;\r
HDC hdc;\r
switch (uMsg)\r
{\r
case WM_CREATE:\r
+ hGreyPen = CreatePen(PS_SOLID, 1, RGB(128, 128, 128));\r
+ hGreyBrush = CreateSolidBrush(RGB(128, 128, 128));\r
SetTimer(hwnd, ID_TIMER, 1000, NULL);\r
GetLocalTime(&st);\r
stPrevious = st;\r
break;\r
\r
case WM_DESTROY:\r
+ DeleteObject(hGreyPen);\r
+ DeleteObject(hGreyBrush);\r
KillTimer(hwnd, ID_TIMER);\r
break;\r
\r