Implemented Window.Close() on Windows.
This commit is contained in:
parent
1cdc6bad27
commit
530810deda
|
@ -25,3 +25,4 @@ package ui
|
||||||
|
|
||||||
// wfunc user32 SendMessageW uintptr t_UINT t_WPARAM t_LPARAM t_LRESULT,noerr
|
// wfunc user32 SendMessageW uintptr t_UINT t_WPARAM t_LPARAM t_LRESULT,noerr
|
||||||
// wfunc user32 UpdateWindow uintptr uintptr
|
// wfunc user32 UpdateWindow uintptr uintptr
|
||||||
|
// wfunc user32 DestroyWindow uintptr uintptr
|
||||||
|
|
|
@ -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 {
|
func (w *window) Close() *Request {
|
||||||
c := make(chan interface{})
|
c := make(chan interface{})
|
||||||
return &Request{
|
return &Request{
|
||||||
op: func() {
|
op: func() {
|
||||||
// TODO
|
doclose(w)
|
||||||
c <- struct{}{}
|
c <- struct{}{}
|
||||||
},
|
},
|
||||||
resp: c,
|
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)
|
return f_DefWindowProcW(hwnd, msg, wParam, lParam)
|
||||||
}
|
}
|
||||||
switch msg {
|
switch msg {
|
||||||
|
case c_WM_CLOSE:
|
||||||
|
close := w.closing.fire()
|
||||||
|
if close {
|
||||||
|
doclose(w)
|
||||||
|
}
|
||||||
|
return 0
|
||||||
default:
|
default:
|
||||||
return f_DefWindowProcW(hwnd, msg, wParam, lParam)
|
return f_DefWindowProcW(hwnd, msg, wParam, lParam)
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue