diff options
| author | Pietro Gagliardi <[email protected]> | 2014-03-05 13:21:45 -0500 |
|---|---|---|
| committer | Pietro Gagliardi <[email protected]> | 2014-03-05 13:21:45 -0500 |
| commit | c0c1e091865029aa1006602d2b195b5c6c4c8dae (patch) | |
| tree | 30194cfebf8e1f3050bc476bfc829346a99518aa | |
| parent | db87ddae7f7aa713722e99a05e3964cd973cb84f (diff) | |
Have ui.Go() return on main() return on Windows.
| -rw-r--r-- | uitask_windows.go | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/uitask_windows.go b/uitask_windows.go index 33ab0ad..c8e94f2 100644 --- a/uitask_windows.go +++ b/uitask_windows.go @@ -29,6 +29,7 @@ type uiret struct { const ( _WM_APP = 0x8000 + iota msgRequested + msgQuit ) var ( @@ -49,7 +50,17 @@ func ui(main func()) error { go msgloop(threadIDReq, msglooperrs) threadID := <-threadIDReq - go main() + go func() { + main() + r1, _, err := _postThreadMessage.Call( + threadID, + msgQuit, + uintptr(0), + uintptr(0)) + if r1 == 0 { // failure + panic("error sending quit message to message loop: " + err.Error()) // TODO + } + }() quit := false for !quit { @@ -123,6 +134,11 @@ func msgloop(threadID chan uintptr, errors chan error) { } continue } + if msg.Message == msgQuit { + // does not return a value according to MSDN + _postQuitMessage.Call(0) + continue + } _translateMessage.Call(uintptr(unsafe.Pointer(&msg))) _dispatchMessage.Call(uintptr(unsafe.Pointer(&msg))) } |
