Implemented Window.Close() on Windows.

This commit is contained in:
Pietro Gagliardi 2014-07-12 16:15:10 -04:00
parent 1cdc6bad27
commit 530810deda
2 changed files with 15 additions and 1 deletions

View File

@ -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

View File

@ -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)
}