From 225248ecb8872bc88cd3051b8afd5d8bd1622705 Mon Sep 17 00:00:00 2001 From: Pietro Gagliardi Date: Thu, 4 Jun 2015 10:47:24 -0400 Subject: [PATCH] Implemented WM_WININICHANGE forwarding for the date/time picker. Right now, it only has an effect for the built-in styles. The same change for the date/time picker itself will come next. --- redo/windows/datetimepicker.c | 16 ++++++++++++++++ redo/windows/events.c | 4 ++-- redo/windows/uipriv_windows.h | 2 +- 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/redo/windows/datetimepicker.c b/redo/windows/datetimepicker.c index 6996a710..9616ec8d 100644 --- a/redo/windows/datetimepicker.c +++ b/redo/windows/datetimepicker.c @@ -4,6 +4,7 @@ struct datetimepicker { uiDateTimePicker d; HWND hwnd; + void (*baseCommitDestroy)(uiControl *); }; uiDefineControlType(uiDateTimePicker, uiTypeDateTimePicker, struct datetimepicker) @@ -47,6 +48,14 @@ static void setDateTimeFormat(HWND hwnd) // control implementation +static void datetimepickerCommitDestroy(uiControl *c) +{ + struct datetimepicker *d = (struct datetimepicker *) c; + + uiWindowsUnregisterReceiveWM_WININICHANGE(d->hwnd); + (*(d->baseCommitDestroy))(uiControl(d)); +} + static uintptr_t datetimepickerHandle(uiControl *c) { struct datetimepicker *d = (struct datetimepicker *) c; @@ -78,6 +87,13 @@ uiDateTimePicker *finishNewDateTimePicker(DWORD style) hInstance, NULL, TRUE); + // automatically update date/time format when user changes locale settings + // for the standard styles, this is in the date-time picker itself + // for our date/time mode, we do it in a subclass assigned in uiNewDateTimePicker() + uiWindowsRegisterReceiveWM_WININICHANGE(d->hwnd); + + d->baseCommitDestroy = uiControl(d)->CommitDestroy; + uiControl(d)->CommitDestroy = datetimepickerCommitDestroy; uiControl(d)->Handle = datetimepickerHandle; uiControl(d)->PreferredSize = datetimepickerPreferredSize; diff --git a/redo/windows/events.c b/redo/windows/events.c index f5f6bf51..76099435 100644 --- a/redo/windows/events.c +++ b/redo/windows/events.c @@ -104,13 +104,13 @@ void uiWindowsRegisterReceiveWM_WININICHANGE(HWND hwnd) HASH_ADD_PTR(wininichanges, hwnd, ch); } -void uiWindowsUnregisterReceiveWM_WINICHANGE(HWND hwnd) +void uiWindowsUnregisterReceiveWM_WININICHANGE(HWND hwnd) { struct wininichange *ch; HASH_FIND_PTR(wininichanges, &hwnd, ch); if (ch == NULL) - complain("window handle %p not registered to receive WM_WININICHANGEs in uiWindowsUnregisterReceiveWM_WINICHANGE()", hwnd); + complain("window handle %p not registered to receive WM_WININICHANGEs in uiWindowsUnregisterReceiveWM_WININICHANGE()", hwnd); HASH_DEL(wininichanges, ch); uiFree(ch); } diff --git a/redo/windows/uipriv_windows.h b/redo/windows/uipriv_windows.h index 855297f0..b04797fc 100644 --- a/redo/windows/uipriv_windows.h +++ b/redo/windows/uipriv_windows.h @@ -104,7 +104,7 @@ extern BOOL runWM_COMMAND(WPARAM, LPARAM, LRESULT *); extern BOOL runWM_NOTIFY(WPARAM, LPARAM, LRESULT *); extern BOOL runWM_HSCROLL(WPARAM, LPARAM, LRESULT *); extern void uiWindowsRegisterReceiveWM_WININICHANGE(HWND); -extern void uiWindowsUnregisterReceiveWM_WINICHANGE(HWND); +extern void uiWindowsUnregisterReceiveWM_WININICHANGE(HWND); extern void issueWM_WININICHANGE(WPARAM, LPARAM); // dialoghelper.c