Author: gedmurphy
Date: Thu Sep 4 10:13:07 2008
New Revision: 35937
URL:
http://svn.reactos.org/svn/reactos?rev=35937&view=rev
Log:
Please test your code before you ruin mine.
It's annoying fixing other peoples mess in your own code.
See issue #3701 for more details.
Modified:
trunk/reactos/dll/cpl/timedate/clock.c
Modified: trunk/reactos/dll/cpl/timedate/clock.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/cpl/timedate/clock.c?r…
==============================================================================
--- trunk/reactos/dll/cpl/timedate/clock.c [iso-8859-1] (original)
+++ trunk/reactos/dll/cpl/timedate/clock.c [iso-8859-1] Thu Sep 4 10:13:07 2008
@@ -26,16 +26,6 @@
#define TWOPI (2 * 3.14159)
static const WCHAR szClockWndClass[] = L"ClockWndClass";
-
-
-static VOID
-SetIsotropic(HDC hdc, PCLOCKDATA pClockData)
-{
- /* set isotropic mode */
- SetMapMode(hdc, MM_ISOTROPIC);
- /* position axis in centre of window */
- SetViewportOrgEx(hdc, pClockData->cxClient / 2, pClockData->cyClient / 2,
NULL);
-}
static VOID
@@ -141,8 +131,7 @@
LPARAM lParam)
{
PCLOCKDATA pClockData;
- HDC hdc, dcMem;
- HBITMAP bmMem, bmOld;
+ HDC hdc, hdcMem;
PAINTSTRUCT ps;
pClockData = (PCLOCKDATA)GetWindowLongPtrW(hwnd, GWLP_USERDATA);
@@ -169,38 +158,68 @@
case WM_TIMER:
GetLocalTime(&pClockData->stCurrent);
- //InvalidateRect(hwnd, NULL, TRUE);
- InvalidateRect(hwnd, NULL, FALSE);
+ InvalidateRect(hwnd, NULL, TRUE);
pClockData->stPrevious = pClockData->stCurrent;
break;
case WM_PAINT:
hdc = BeginPaint(hwnd, &ps);
- /* Use an offscreen dc to avoid flicker */
-
- dcMem = CreateCompatibleDC(hdc);
- bmMem = CreateCompatibleBitmap(hdc, ps.rcPaint.right - ps.rcPaint.left,
ps.rcPaint.bottom - ps.rcPaint.top);
-
- bmOld = SelectObject(dcMem, bmMem);
- SetViewportOrgEx(dcMem, -ps.rcPaint.left, -ps.rcPaint.top, NULL);
- FillRect(dcMem, &ps.rcPaint, GetSysColorBrush(COLOR_BTNFACE));
-
- SetIsotropic(dcMem, pClockData);
- DrawClock(dcMem, pClockData);
- DrawHands(dcMem, &pClockData->stPrevious, TRUE);
-
- /* Blit the changes to the screen */
- BitBlt(hdc,
- ps.rcPaint.left, ps.rcPaint.top,
- ps.rcPaint.right - ps.rcPaint.left, ps.rcPaint.bottom - ps.rcPaint.top,
- dcMem,
- ps.rcPaint.left, ps.rcPaint.top,
- SRCCOPY);
-
- SelectObject(dcMem, bmOld);
- DeleteObject(bmMem);
- DeleteObject(dcMem);
+ hdcMem = CreateCompatibleDC(hdc);
+ if (hdcMem)
+ {
+ HBITMAP hBmp, hBmpOld;
+
+ hBmp = CreateCompatibleBitmap(hdc,
+ pClockData->cxClient,
+ pClockData->cyClient);
+ if (hBmp)
+ {
+ HBRUSH hWinBrush, hWinBrushOld;
+ INT oldMap;
+ POINT oldOrg;
+
+ hBmpOld = SelectObject(hdcMem, hBmp);
+
+ hWinBrush = GetSysColorBrush(COLOR_BTNFACE);
+ hWinBrushOld = SelectObject(hdcMem, hWinBrush);
+ PatBlt(hdcMem,
+ 0,
+ 0,
+ pClockData->cxClient,
+ pClockData->cyClient,
+ PATCOPY);
+
+ oldMap = SetMapMode(hdcMem, MM_ISOTROPIC);
+ SetViewportOrgEx(hdcMem,
+ pClockData->cxClient / 2,
+ pClockData->cyClient / 2,
+ &oldOrg);
+
+ DrawClock(hdcMem, pClockData);
+ DrawHands(hdcMem, &pClockData->stPrevious, TRUE);
+
+ SetMapMode(hdcMem, oldMap);
+ SetViewportOrgEx(hdcMem, oldOrg.x, oldOrg.y, NULL);
+
+ BitBlt(hdc,
+ 0,
+ 0,
+ pClockData->cxClient,
+ pClockData->cyClient,
+ hdcMem,
+ 0,
+ 0,
+ SRCCOPY);
+
+ SelectObject(hdcMem, hWinBrushOld);
+ SelectObject(hdcMem, hBmpOld);
+ DeleteObject(hBmp);
+ }
+
+ DeleteDC(hdcMem);
+ }
+
EndPaint(hwnd, &ps);
break;
@@ -226,7 +245,7 @@
CopyMemory(&pClockData->stPrevious, (LPSYSTEMTIME)lParam,
sizeof(SYSTEMTIME));
/* Redraw the clock */
- InvalidateRect(hwnd, NULL, FALSE);
+ InvalidateRect(hwnd, NULL, TRUE);
break;
default: