mirror of
https://github.com/reactos/reactos.git
synced 2025-02-24 01:15:09 +00:00
- avoid clock flicker in timedate.cpl
- TODO: limit repaint area to clock only (to avoid flicker of time adjusting control as well) svn path=/trunk/; revision=34325
This commit is contained in:
parent
d94dde07f8
commit
114955b298
1 changed files with 30 additions and 6 deletions
|
@ -141,7 +141,8 @@ ClockWndProc(HWND hwnd,
|
||||||
LPARAM lParam)
|
LPARAM lParam)
|
||||||
{
|
{
|
||||||
PCLOCKDATA pClockData;
|
PCLOCKDATA pClockData;
|
||||||
HDC hdc;
|
HDC hdc, dcMem;
|
||||||
|
HBITMAP bmMem, bmOld;
|
||||||
PAINTSTRUCT ps;
|
PAINTSTRUCT ps;
|
||||||
|
|
||||||
pClockData = (PCLOCKDATA)GetWindowLongPtrW(hwnd, GWLP_USERDATA);
|
pClockData = (PCLOCKDATA)GetWindowLongPtrW(hwnd, GWLP_USERDATA);
|
||||||
|
@ -168,15 +169,38 @@ ClockWndProc(HWND hwnd,
|
||||||
|
|
||||||
case WM_TIMER:
|
case WM_TIMER:
|
||||||
GetLocalTime(&pClockData->stCurrent);
|
GetLocalTime(&pClockData->stCurrent);
|
||||||
InvalidateRect(hwnd, NULL, TRUE);
|
//InvalidateRect(hwnd, NULL, TRUE);
|
||||||
|
InvalidateRect(hwnd, NULL, FALSE);
|
||||||
pClockData->stPrevious = pClockData->stCurrent;
|
pClockData->stPrevious = pClockData->stCurrent;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case WM_PAINT:
|
case WM_PAINT:
|
||||||
hdc = BeginPaint(hwnd, &ps);
|
hdc = BeginPaint(hwnd, &ps);
|
||||||
SetIsotropic(hdc, pClockData);
|
|
||||||
DrawClock(hdc, pClockData);
|
/* Use an offscreen dc to avoid flicker */
|
||||||
DrawHands(hdc, &pClockData->stPrevious, TRUE);
|
|
||||||
|
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);
|
||||||
EndPaint(hwnd, &ps);
|
EndPaint(hwnd, &ps);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -202,7 +226,7 @@ ClockWndProc(HWND hwnd,
|
||||||
CopyMemory(&pClockData->stPrevious, (LPSYSTEMTIME)lParam, sizeof(SYSTEMTIME));
|
CopyMemory(&pClockData->stPrevious, (LPSYSTEMTIME)lParam, sizeof(SYSTEMTIME));
|
||||||
|
|
||||||
/* Redraw the clock */
|
/* Redraw the clock */
|
||||||
InvalidateRect(hwnd, NULL, TRUE);
|
InvalidateRect(hwnd, NULL, FALSE);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|
Loading…
Reference in a new issue