Skip to content

Commit 129b6ff

Browse files
committed
dialog add OnClose OnDestroy
1 parent 86aec39 commit 129b6ff

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

dialog.go

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ type Dialog struct {
3737
// Indicates whether it is a modal dialog
3838
cb ModalDialogCallBack
3939
wndCallBack uintptr
40+
// if return true,will eat message.
41+
OnClose func() bool
42+
OnDestroy func()
4043
// TODO Support optionsl sub wnd class.
4144
}
4245

@@ -124,6 +127,11 @@ func (dlg *Dialog) dialogWndProc(hwnd win.HWND, msg uint32, wParam, lParam uintp
124127
// return 0
125128
case win.WM_CLOSE:
126129
log.Println("WM_CLOSE", hwnd)
130+
if dlg.OnClose != nil {
131+
if dlg.OnClose() {
132+
return 0
133+
}
134+
}
127135
if dlg.cb != nil {
128136
win.EndDialog(hwnd, 0)
129137
} else {
@@ -132,6 +140,9 @@ func (dlg *Dialog) dialogWndProc(hwnd win.HWND, msg uint32, wParam, lParam uintp
132140
return 0
133141
case win.WM_DESTROY:
134142
log.Println("WM_DESTROY", hwnd, dlgCount)
143+
if dlg.OnDestroy != nil {
144+
dlg.OnDestroy()
145+
}
135146
dlgCount--
136147
if dlgCount == 0 {
137148
win.PostQuitMessage(0)

0 commit comments

Comments
 (0)