diff --git a/basicctrls_windows.c b/basicctrls_windows.c index 0c5659f..60cc0c8 100644 --- a/basicctrls_windows.c +++ b/basicctrls_windows.c @@ -210,3 +210,29 @@ HWND newUpDown(HWND prevUpDown, void *data) xpanic("error subclassing Spinbox up-down control to give it its own event handler", GetLastError()); return hwnd; } + +static LRESULT CALLBACK spinboxEditSubProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam, UINT_PTR id, DWORD_PTR data) +{ + switch (uMsg) { + case msgCOMMAND: + if (HIWORD(wParam) == EN_CHANGE) { + spinboxEditChanged((void *) data); + return 0; + } + return (*fv_DefSubclassProc)(hwnd, uMsg, wParam, lParam); + case WM_NCDESTROY: + if ((*fv_RemoveWindowSubclass)(hwnd, spinboxEditSubProc, id) == FALSE) + xpanic("error removing Spinbox edit control subclass (which was for its own event handler)", GetLastError()); + return (*fv_DefSubclassProc)(hwnd, uMsg, wParam, lParam); + default: + return (*fv_DefSubclassProc)(hwnd, uMsg, wParam, lParam); + } + xmissedmsg("Spinbox edit control", "spinboxEditSubProc()", uMsg); + return 0; // unreached +} + +void setSpinboxEditSubclass(HWND hwnd, void *data) +{ + if ((*fv_SetWindowSubclass)(hwnd, spinboxEditSubProc, 0, (DWORD_PTR) data) == FALSE) + xpanic("error subclassing Spinbox edit control to give it its own event handler", GetLastError()); +} \ No newline at end of file diff --git a/spinbox_windows.go b/spinbox_windows.go index b42c75d..7f92cb7 100644 --- a/spinbox_windows.go +++ b/spinbox_windows.go @@ -35,6 +35,7 @@ func newSpinbox(min int, max int) Spinbox { s.max = max s.value = s.min s.remakeUpDown() + C.setSpinboxEditSubclass(s.hwndEdit, unsafe.Pointer(s)) return s } @@ -73,6 +74,13 @@ func spinboxUpDownClicked(data unsafe.Pointer, nud *C.NMUPDOWN) { s.changed.fire() } +//export spinboxEditChanged +func spinboxEditChanged(data unsafe.Pointer) { + s := (*spinbox)(unsafe.Pointer(data)) + // TODO + s.changed.fire() +} + func (s *spinbox) setParent(p *controlParent) { C.controlSetParent(s.hwndEdit, p.hwnd) C.controlSetParent(s.hwndUpDown, p.hwnd) diff --git a/winapi_windows.h b/winapi_windows.h index dec981f..7ea6ed3 100644 --- a/winapi_windows.h +++ b/winapi_windows.h @@ -76,6 +76,7 @@ extern void textfieldSetAndShowInvalidBalloonTip(HWND, WCHAR *); extern void textfieldHideInvalidBalloonTip(HWND); extern void setGroupSubclass(HWND, void *); extern HWND newUpDown(HWND, void *); +extern void setSpinboxEditSubclass(HWND, void *); // init_windows.c extern HINSTANCE hInstance;