diff options
| author | Pietro Gagliardi <[email protected]> | 2014-07-12 16:15:10 -0400 |
|---|---|---|
| committer | Pietro Gagliardi <[email protected]> | 2014-07-12 16:15:10 -0400 |
| commit | 530810deda0de9caf90c3937102085eb19ed6870 (patch) | |
| tree | d5e63a25720c2aba4c53e3f3abba6e1821069ecd | |
| parent | 1cdc6bad27b27adc2184f745cf3e7da2d6ee7270 (diff) | |
Implemented Window.Close() on Windows.
| -rw-r--r-- | redo/funcnames_windows.go | 1 | ||||
| -rw-r--r-- | redo/window_windows.go | 15 |
2 files changed, 15 insertions, 1 deletions
diff --git a/redo/funcnames_windows.go b/redo/funcnames_windows.go index ce334f2..689e54e 100644 --- a/redo/funcnames_windows.go +++ b/redo/funcnames_windows.go @@ -25,3 +25,4 @@ package ui // wfunc user32 SendMessageW uintptr t_UINT t_WPARAM t_LPARAM t_LRESULT,noerr // wfunc user32 UpdateWindow uintptr uintptr +// wfunc user32 DestroyWindow uintptr uintptr diff --git a/redo/window_windows.go b/redo/window_windows.go index 4406704..f2e8951 100644 --- a/redo/window_windows.go +++ b/redo/window_windows.go @@ -123,11 +123,18 @@ func (w *window) Hide() *Request { } } +func doclose(w *window) { + res, err := f_DestroyWindow(w.hwnd) + if res == 0 { + panic(fmt.Errorf("error destroying window: %v", err)) + } +} + func (w *window) Close() *Request { c := make(chan interface{}) return &Request{ op: func() { - // TODO + doclose(w) c <- struct{}{} }, resp: c, @@ -158,6 +165,12 @@ func windowWndProc(hwnd uintptr, msg t_UINT, wParam t_WPARAM, lParam t_LPARAM) t return f_DefWindowProcW(hwnd, msg, wParam, lParam) } switch msg { + case c_WM_CLOSE: + close := w.closing.fire() + if close { + doclose(w) + } + return 0 default: return f_DefWindowProcW(hwnd, msg, wParam, lParam) } |
