summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPietro Gagliardi <[email protected]>2014-05-30 23:28:41 -0400
committerPietro Gagliardi <[email protected]>2014-05-30 23:28:41 -0400
commitb13453ad9e9aa20b6fca064f8b185b0ea86e5aaf (patch)
tree2dab455088ade6c908595785db222ceb347f61fe
parent09f5c7764ea654faf9a616c838076af5902010a7 (diff)
Changed storeSysData() on Windows to write the HWND to the sysData structure there. This will be important for removing some of the TODOs from areaWndProc().
-rw-r--r--stdwndclass_windows.go4
-rw-r--r--sysdata_windows.go7
2 files changed, 9 insertions, 2 deletions
diff --git a/stdwndclass_windows.go b/stdwndclass_windows.go
index c90bb92..3c189a7 100644
--- a/stdwndclass_windows.go
+++ b/stdwndclass_windows.go
@@ -60,7 +60,9 @@ func storeSysData(hwnd _HWND, uMsg uint32, wParam _WPARAM, lParam _LPARAM) _LRES
cs := (*uintptr)(unsafe.Pointer(lParam))
saddr := *cs
setWindowLongPtr(hwnd, negConst(_GWLP_USERDATA), saddr)
- // don't set s; we return here
+ // also set s.hwnd here so it can be used by other window messages right away
+ s := (*sysData)(unsafe.Pointer(saddr))
+ s.hwnd = hwnd
}
// TODO is this correct for WM_NCCREATE? I think the above link does it but I'm not entirely sure...
return defWindowProc(hwnd, uMsg, wParam, lParam)
diff --git a/sysdata_windows.go b/sysdata_windows.go
index 2a15ea8..fdfbd8c 100644
--- a/sysdata_windows.go
+++ b/sysdata_windows.go
@@ -179,7 +179,12 @@ func (s *sysData) make(window *sysData) (err error) {
}
return fmt.Errorf("error actually creating window/control: %v", r.err)
}
- s.hwnd = _HWND(r.ret)
+ if !ct.storeSysData { // regular control; store s.hwnd ourselves
+ s.hwnd = _HWND(r.ret)
+ } else if s.hwnd != _HWND(r.ret) { // we store sysData in storeSysData(); sanity check
+ // TODO really panic?
+ panic(fmt.Errorf("hwnd mismatch creating window/control: storeSysData() stored 0x%X but CreateWindowEx() returned 0x%X", s.hwnd, ret))
+ }
if !ct.doNotLoadFont {
uitask <- &uimsg{
call: _sendMessage,