diff --git a/redo/ui_windows.h b/redo/ui_windows.h index 262577e4..a3ef18d8 100644 --- a/redo/ui_windows.h +++ b/redo/ui_windows.h @@ -26,7 +26,6 @@ struct uiWindowsMakeControlParams { // ui redirects the message back and calls these functions. // Store the result in *lResult and return any non-FALSE value (such as TRUE) to return the given result; return FALSE to pass the notification up to your window procedure. // Note that these are only issued if they come from the uiControl itself; notifications from children of the uiControl (such as a header control) will be received normally. - BOOL (*onWM_COMMAND)(uiControl *c, WORD code, LRESULT *lResult); BOOL (*onWM_NOTIFY)(uiControl *c, NMHDR *nm, LRESULT *lResult); BOOL (*onWM_HSCROLL)(uiControl *c, WORD code, LRESULT *lResult); diff --git a/redo/windows/button.c b/redo/windows/button.c index 2cdc4532..8b57714f 100644 --- a/redo/windows/button.c +++ b/redo/windows/button.c @@ -33,6 +33,7 @@ static void onDestroy(void *data) { struct button *b = (struct button *) data; + uiWindowsUnregisterWM_COMMANDHandler(b->hwnd); uiFree(b); } @@ -100,7 +101,6 @@ uiButton *uiNewButton(const char *text) p.hInstance = hInstance; p.lpParam = NULL; p.useStandardControlFont = TRUE; - p.onWM_COMMAND = onWM_COMMAND; p.onWM_NOTIFY = onWM_NOTIFY; p.onWM_HSCROLL = onWM_HSCROLL; p.onDestroy = onDestroy; @@ -109,6 +109,7 @@ uiButton *uiNewButton(const char *text) uiFree(wtext); b->hwnd = (HWND) uiControlHandle(uiControl(b)); + uiWindowsRegisterWM_COMMANDHandler(b->hwnd, onWM_COMMAND, uiControl(b)); b->onClicked = defaultOnClicked; diff --git a/redo/windows/checkbox.c b/redo/windows/checkbox.c index 74f0986e..edc70c01 100644 --- a/redo/windows/checkbox.c +++ b/redo/windows/checkbox.c @@ -41,6 +41,7 @@ static void onDestroy(void *data) { struct checkbox *c = (struct checkbox *) data; + uiWindowsUnregisterWM_COMMANDHandler(c->hwnd); uiFree(c); } @@ -115,7 +116,6 @@ uiCheckbox *uiNewCheckbox(const char *text) p.hInstance = hInstance; p.lpParam = NULL; p.useStandardControlFont = TRUE; - p.onWM_COMMAND = onWM_COMMAND; p.onWM_NOTIFY = onWM_NOTIFY; p.onWM_HSCROLL = onWM_HSCROLL; p.onDestroy = onDestroy; @@ -124,6 +124,7 @@ uiCheckbox *uiNewCheckbox(const char *text) uiFree(wtext); c->hwnd = (HWND) uiControlHandle(uiControl(c)); + uiWindowsRegisterWM_COMMANDHandler(c->hwnd, onWM_COMMAND, uiControl(c)); c->onToggled = defaultOnToggled; diff --git a/redo/windows/combobox.c b/redo/windows/combobox.c index 8ba47453..f1b7e905 100644 --- a/redo/windows/combobox.c +++ b/redo/windows/combobox.c @@ -6,11 +6,6 @@ struct combobox { HWND hwnd; }; -static BOOL onWM_COMMAND(uiControl *c, WORD code, LRESULT *lResult) -{ - return FALSE; -} - static BOOL onWM_NOTIFY(uiControl *c, NMHDR *nm, LRESULT *lResult) { return FALSE; @@ -68,7 +63,6 @@ uiCombobox *uiNewCombobox(void) p.hInstance = hInstance; p.lpParam = NULL; p.useStandardControlFont = TRUE; - p.onWM_COMMAND = onWM_COMMAND; p.onWM_NOTIFY = onWM_NOTIFY; p.onWM_HSCROLL = onWM_HSCROLL; p.onDestroy = onDestroy; diff --git a/redo/windows/container.c b/redo/windows/container.c index 60a589c1..b443627c 100644 --- a/redo/windows/container.c +++ b/redo/windows/container.c @@ -58,11 +58,6 @@ void uninitContainer(void) logLastError("error unregistering container window class in uninitContainer()"); } -static BOOL onWM_COMMAND(uiControl *c, WORD code, LRESULT *lResult) -{ - return FALSE; -} - static BOOL onWM_NOTIFY(uiControl *c, NMHDR *nm, LRESULT *lResult) { return FALSE; @@ -89,7 +84,6 @@ void uiMakeContainer(uiControl *c) p.hInstance = hInstance; p.lpParam = NULL; p.useStandardControlFont = TRUE; - p.onWM_COMMAND = onWM_COMMAND; p.onWM_NOTIFY = onWM_NOTIFY; p.onWM_HSCROLL = onWM_HSCROLL; p.onDestroy = onDestroy; diff --git a/redo/windows/control.c b/redo/windows/control.c index 188e16d6..aa9341ac 100644 --- a/redo/windows/control.c +++ b/redo/windows/control.c @@ -13,7 +13,6 @@ void osSingleDestroy(void *internal) struct singleHWND *s = (struct singleHWND *) internal; (*(s->onDestroy))(s->onDestroyData); - uiWindowsUnregisterWM_COMMANDHandler(s->hwnd); uiWindowsUnregisterWM_NOTIFYHandler(s->hwnd); uiWindowsUnregisterWM_HSCROLLHandler(s->hwnd); if (DestroyWindow(s->hwnd) == 0) @@ -120,7 +119,6 @@ void uiWindowsMakeControl(uiControl *c, uiWindowsMakeControlParams *p) if (s->hwnd == NULL) logLastError("error creating control in uiWindowsMakeControl()"); - uiWindowsRegisterWM_COMMANDHandler(s->hwnd, p->onWM_COMMAND, uiControl(c)); uiWindowsRegisterWM_NOTIFYHandler(s->hwnd, p->onWM_NOTIFY, uiControl(c)); uiWindowsRegisterWM_HSCROLLHandler(s->hwnd, p->onWM_HSCROLL, uiControl(c)); diff --git a/redo/windows/entry.c b/redo/windows/entry.c index ae4c2571..68d7e7b2 100644 --- a/redo/windows/entry.c +++ b/redo/windows/entry.c @@ -36,6 +36,7 @@ static void onDestroy(void *data) { struct entry *e = (struct entry *) data; + uiWindowsUnregisterWM_COMMANDHandler(e->hwnd); uiFree(e); } @@ -111,7 +112,6 @@ uiEntry *uiNewEntry(void) p.hInstance = hInstance; p.lpParam = NULL; p.useStandardControlFont = TRUE; - p.onWM_COMMAND = onWM_COMMAND; p.onWM_NOTIFY = onWM_NOTIFY; p.onWM_HSCROLL = onWM_HSCROLL; p.onDestroy = onDestroy; @@ -119,6 +119,7 @@ uiEntry *uiNewEntry(void) uiWindowsMakeControl(uiControl(e), &p); e->hwnd = (HWND) uiControlHandle(uiControl(e)); + uiWindowsRegisterWM_COMMANDHandler(e->hwnd, onWM_COMMAND, uiControl(e)); e->onChanged = defaultOnChanged; diff --git a/redo/windows/group.c b/redo/windows/group.c index 4017cc70..fa5093fb 100644 --- a/redo/windows/group.c +++ b/redo/windows/group.c @@ -6,11 +6,6 @@ struct group { HWND hwnd; }; -static BOOL onWM_COMMAND(uiControl *c, WORD code, LRESULT *lResult) -{ - return FALSE; -} - static BOOL onWM_NOTIFY(uiControl *c, NMHDR *nm, LRESULT *lResult) { return FALSE; @@ -55,7 +50,6 @@ uiGroup *uiNewGroup(const char *text) p.hInstance = hInstance; p.lpParam = NULL; p.useStandardControlFont = TRUE; - p.onWM_COMMAND = onWM_COMMAND; p.onWM_NOTIFY = onWM_NOTIFY; p.onWM_HSCROLL = onWM_HSCROLL; p.onDestroy = onDestroy; diff --git a/redo/windows/label.c b/redo/windows/label.c index c9230048..9db700cf 100644 --- a/redo/windows/label.c +++ b/redo/windows/label.c @@ -6,11 +6,6 @@ struct label { HWND hwnd; }; -static BOOL onWM_COMMAND(uiControl *c, WORD code, LRESULT *lResult) -{ - return FALSE; -} - static BOOL onWM_NOTIFY(uiControl *c, NMHDR *nm, LRESULT *lResult) { return FALSE; @@ -68,7 +63,6 @@ uiLabel *uiNewLabel(const char *text) p.hInstance = hInstance; p.lpParam = NULL; p.useStandardControlFont = TRUE; - p.onWM_COMMAND = onWM_COMMAND; p.onWM_NOTIFY = onWM_NOTIFY; p.onWM_HSCROLL = onWM_HSCROLL; p.onDestroy = onDestroy; diff --git a/redo/windows/progressbar.c b/redo/windows/progressbar.c index 09b6dd1d..50a7f2e1 100644 --- a/redo/windows/progressbar.c +++ b/redo/windows/progressbar.c @@ -6,11 +6,6 @@ struct progressbar { HWND hwnd; }; -static BOOL onWM_COMMAND(uiControl *c, WORD code, LRESULT *lResult) -{ - return FALSE; -} - static BOOL onWM_NOTIFY(uiControl *c, NMHDR *nm, LRESULT *lResult) { return FALSE; @@ -63,7 +58,6 @@ uiProgressBar *uiNewProgressBar(void) p.hInstance = hInstance; p.lpParam = NULL; p.useStandardControlFont = FALSE; - p.onWM_COMMAND = onWM_COMMAND; p.onWM_NOTIFY = onWM_NOTIFY; p.onWM_HSCROLL = onWM_HSCROLL; p.onDestroy = onDestroy; diff --git a/redo/windows/separator.c b/redo/windows/separator.c index ea9b04c4..6c14d751 100644 --- a/redo/windows/separator.c +++ b/redo/windows/separator.c @@ -10,11 +10,6 @@ struct separator { HWND hwnd; }; -static BOOL onWM_COMMAND(uiControl *c, WORD code, LRESULT *lResult) -{ - return FALSE; -} - static BOOL onWM_NOTIFY(uiControl *c, NMHDR *nm, LRESULT *lResult) { return FALSE; @@ -57,7 +52,6 @@ uiSeparator *uiNewHorizontalSeparator(void) p.hInstance = hInstance; p.lpParam = NULL; p.useStandardControlFont = TRUE; - p.onWM_COMMAND = onWM_COMMAND; p.onWM_NOTIFY = onWM_NOTIFY; p.onWM_HSCROLL = onWM_HSCROLL; p.onDestroy = onDestroy; diff --git a/redo/windows/slider.c b/redo/windows/slider.c index f3389961..ded35e7a 100644 --- a/redo/windows/slider.c +++ b/redo/windows/slider.c @@ -13,11 +13,6 @@ struct slider { void *onChangedData; }; -static BOOL onWM_COMMAND(uiControl *c, WORD code, LRESULT *lResult) -{ - return FALSE; -} - static BOOL onWM_NOTIFY(uiControl *c, NMHDR *nm, LRESULT *lResult) { return FALSE; @@ -94,7 +89,6 @@ uiSlider *uiNewSlider(intmax_t min, intmax_t max) p.hInstance = hInstance; p.lpParam = NULL; p.useStandardControlFont = TRUE; - p.onWM_COMMAND = onWM_COMMAND; p.onWM_NOTIFY = onWM_NOTIFY; p.onWM_HSCROLL = onWM_HSCROLL; p.onDestroy = onDestroy; diff --git a/redo/windows/spinbox.c b/redo/windows/spinbox.c index 2ee38a3d..5de356c0 100644 --- a/redo/windows/spinbox.c +++ b/redo/windows/spinbox.c @@ -61,6 +61,7 @@ static void onDestroy(void *data) { struct spinbox *s = (struct spinbox *) data; + uiWindowsUnregisterWM_COMMANDHandler(s->hwnd); uiFree(s); } @@ -169,7 +170,6 @@ uiSpinbox *uiNewSpinbox(intmax_t min, intmax_t max) p.hInstance = hInstance; p.lpParam = NULL; p.useStandardControlFont = TRUE; - p.onWM_COMMAND = onWM_COMMAND; p.onWM_NOTIFY = onWM_NOTIFY; p.onWM_HSCROLL = onWM_HSCROLL; p.onDestroy = onDestroy; @@ -177,6 +177,7 @@ uiSpinbox *uiNewSpinbox(intmax_t min, intmax_t max) uiWindowsMakeControl(uiControl(s), &p); s->hwnd = (HWND) uiControlHandle(uiControl(s)); + uiWindowsRegisterWM_COMMANDHandler(s->hwnd, onWM_COMMAND, uiControl(s)); recreateUpDown(s); s->inhibitChanged = TRUE; diff --git a/redo/windows/tab.c b/redo/windows/tab.c index 30cce370..999dddce 100644 --- a/redo/windows/tab.c +++ b/redo/windows/tab.c @@ -41,11 +41,6 @@ static void showHidePage(struct tab *t, LRESULT which, int hide) // control implementation -static BOOL onWM_COMMAND(uiControl *c, WORD code, LRESULT *lResult) -{ - return FALSE; -} - static BOOL onWM_NOTIFY(uiControl *c, NMHDR *nm, LRESULT *lResult) { struct tab *t = (struct tab *) c; @@ -218,7 +213,6 @@ uiTab *uiNewTab(void) p.hInstance = hInstance; p.lpParam = NULL; p.useStandardControlFont = TRUE; - p.onWM_COMMAND = onWM_COMMAND; p.onWM_NOTIFY = onWM_NOTIFY; p.onWM_HSCROLL = onWM_HSCROLL; p.onDestroy = onDestroy;