Started the work for Spinbox.OnChanged() on Windows with the edit control.

This commit is contained in:
Pietro Gagliardi 2014-11-02 20:49:39 -05:00
parent 280723763c
commit 8f04623115
3 changed files with 35 additions and 0 deletions

View File

@ -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()); xpanic("error subclassing Spinbox up-down control to give it its own event handler", GetLastError());
return hwnd; 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());
}

View File

@ -35,6 +35,7 @@ func newSpinbox(min int, max int) Spinbox {
s.max = max s.max = max
s.value = s.min s.value = s.min
s.remakeUpDown() s.remakeUpDown()
C.setSpinboxEditSubclass(s.hwndEdit, unsafe.Pointer(s))
return s return s
} }
@ -73,6 +74,13 @@ func spinboxUpDownClicked(data unsafe.Pointer, nud *C.NMUPDOWN) {
s.changed.fire() 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) { func (s *spinbox) setParent(p *controlParent) {
C.controlSetParent(s.hwndEdit, p.hwnd) C.controlSetParent(s.hwndEdit, p.hwnd)
C.controlSetParent(s.hwndUpDown, p.hwnd) C.controlSetParent(s.hwndUpDown, p.hwnd)

View File

@ -76,6 +76,7 @@ extern void textfieldSetAndShowInvalidBalloonTip(HWND, WCHAR *);
extern void textfieldHideInvalidBalloonTip(HWND); extern void textfieldHideInvalidBalloonTip(HWND);
extern void setGroupSubclass(HWND, void *); extern void setGroupSubclass(HWND, void *);
extern HWND newUpDown(HWND, void *); extern HWND newUpDown(HWND, void *);
extern void setSpinboxEditSubclass(HWND, void *);
// init_windows.c // init_windows.c
extern HINSTANCE hInstance; extern HINSTANCE hInstance;