Skip to content

Commit

Permalink
dialog add OnClose OnDestroy
Browse files Browse the repository at this point in the history
  • Loading branch information
whtiehack committed Jun 16, 2020
1 parent 86aec39 commit 129b6ff
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions dialog.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ type Dialog struct {
// Indicates whether it is a modal dialog
cb ModalDialogCallBack
wndCallBack uintptr
// if return true,will eat message.
OnClose func() bool
OnDestroy func()
// TODO Support optionsl sub wnd class.
}

Expand Down Expand Up @@ -124,6 +127,11 @@ func (dlg *Dialog) dialogWndProc(hwnd win.HWND, msg uint32, wParam, lParam uintp
// return 0
case win.WM_CLOSE:
log.Println("WM_CLOSE", hwnd)
if dlg.OnClose != nil {
if dlg.OnClose() {
return 0
}
}
if dlg.cb != nil {
win.EndDialog(hwnd, 0)
} else {
Expand All @@ -132,6 +140,9 @@ func (dlg *Dialog) dialogWndProc(hwnd win.HWND, msg uint32, wParam, lParam uintp
return 0
case win.WM_DESTROY:
log.Println("WM_DESTROY", hwnd, dlgCount)
if dlg.OnDestroy != nil {
dlg.OnDestroy()
}
dlgCount--
if dlgCount == 0 {
win.PostQuitMessage(0)
Expand Down

0 comments on commit 129b6ff

Please sign in to comment.