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.

This commit is contained in:
Pietro Gagliardi 2015-06-04 10:47:24 -04:00
parent 47f856263c
commit 225248ecb8
3 changed files with 19 additions and 3 deletions

View File

@ -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;

View File

@ -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);
}

View File

@ -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