From c98c9900e01d2d210ef4fddf10a4a17344332078 Mon Sep 17 00:00:00 2001 From: Ged Murphy Date: Thu, 4 Sep 2008 15:51:11 +0000 Subject: [PATCH] restart the clock when it's been stopped to be altered svn path=/trunk/; revision=35940 --- reactos/dll/cpl/timedate/clock.c | 17 ++++++++++------- reactos/dll/cpl/timedate/dateandtime.c | 8 ++++++-- reactos/dll/cpl/timedate/timedate.h | 3 ++- 3 files changed, 18 insertions(+), 10 deletions(-) diff --git a/reactos/dll/cpl/timedate/clock.c b/reactos/dll/cpl/timedate/clock.c index 59e9e8e8b5b..7c74ac5f1fe 100644 --- a/reactos/dll/cpl/timedate/clock.c +++ b/reactos/dll/cpl/timedate/clock.c @@ -158,7 +158,7 @@ ClockWndProc(HWND hwnd, case WM_TIMER: GetLocalTime(&pClockData->stCurrent); - InvalidateRect(hwnd, NULL, TRUE); + InvalidateRect(hwnd, NULL, FALSE); pClockData->stPrevious = pClockData->stCurrent; break; @@ -233,19 +233,22 @@ ClockWndProc(HWND hwnd, HeapFree(GetProcessHeap(), 0, pClockData); break; - case CLM_SETTIME: - /* Stop the timer if it is still running */ + case CLM_STOPCLOCK: if (pClockData->bTimer) { KillTimer(hwnd, ID_TIMER); pClockData->bTimer = FALSE; } + break; - /* Set the current time */ - CopyMemory(&pClockData->stPrevious, (LPSYSTEMTIME)lParam, sizeof(SYSTEMTIME)); + case CLM_STARTCLOCK: + if (!pClockData->bTimer) + { + InvalidateRect(hwnd, NULL, FALSE); - /* Redraw the clock */ - InvalidateRect(hwnd, NULL, TRUE); + SetTimer(hwnd, ID_TIMER, 1000, NULL); + pClockData->bTimer = TRUE; + } break; default: diff --git a/reactos/dll/cpl/timedate/dateandtime.c b/reactos/dll/cpl/timedate/dateandtime.c index 493f340afc0..750e895bce7 100644 --- a/reactos/dll/cpl/timedate/dateandtime.c +++ b/reactos/dll/cpl/timedate/dateandtime.c @@ -347,8 +347,8 @@ DateTimePageProc(HWND hwndDlg, KillTimer(hwndDlg, ID_TIMER); /* Tell the clock to stop ticking */ - SendDlgItemMessageW(hwndDlg, IDC_CLOCKWND, CLM_SETTIME, - 0, (LPARAM)&((LPNMDATETIMECHANGE)lpnm)->st); + SendDlgItemMessageW(hwndDlg, IDC_CLOCKWND, CLM_STOPCLOCK, + 0, 0); /* Enable the 'Apply' button */ PropSheet_Changed(GetParent(hwndDlg), hwndDlg); @@ -381,6 +381,10 @@ DateTimePageProc(HWND hwndDlg, case PSN_APPLY: SetLocalSystemTime(hwndDlg); SetTimer(hwndDlg, ID_TIMER, 1000, NULL); + + /* Tell the clock to start ticking */ + SendDlgItemMessageW(hwndDlg, IDC_CLOCKWND, CLM_STARTCLOCK, + 0, 0); return TRUE; } break; diff --git a/reactos/dll/cpl/timedate/timedate.h b/reactos/dll/cpl/timedate/timedate.h index 4f2fce67b7b..54915563b90 100644 --- a/reactos/dll/cpl/timedate/timedate.h +++ b/reactos/dll/cpl/timedate/timedate.h @@ -51,7 +51,8 @@ VOID DisplayWin32Error(DWORD dwErrorCode); /* clock.c */ -#define CLM_SETTIME (WM_USER + 1) +#define CLM_STOPCLOCK (WM_USER + 1) +#define CLM_STARTCLOCK (WM_USER + 2) BOOL RegisterClockControl(VOID); VOID UnregisterClockControl(VOID);