-
Notifications
You must be signed in to change notification settings - Fork 24
/
message_box.go
46 lines (35 loc) · 1.09 KB
/
message_box.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
//+build windows
package wui
import "github.com/gonutz/w32/v2"
func MessageBox(caption, text string) {
msgBox(caption, text, w32.MB_OK)
}
func MessageBoxError(caption, text string) {
msgBox(caption, text, w32.MB_OK|w32.MB_ICONERROR)
}
func MessageBoxWarning(caption, text string) {
msgBox(caption, text, w32.MB_OK|w32.MB_ICONWARNING)
}
func MessageBoxInfo(caption, text string) {
msgBox(caption, text, w32.MB_OK|w32.MB_ICONINFORMATION)
}
func MessageBoxQuestion(caption, text string) {
msgBox(caption, text, w32.MB_OK|w32.MB_ICONQUESTION)
}
func MessageBoxOKCancel(caption, text string) bool {
return msgBox(caption, text, w32.MB_OKCANCEL) == w32.IDOK
}
func MessageBoxYesNo(caption, text string) bool {
return msgBox(caption, text, w32.MB_YESNO|w32.MB_ICONQUESTION) == w32.IDYES
}
func MessageBoxCustom(caption, text string, flags uint) int {
return msgBox(caption, text, flags)
}
func msgBox(caption, text string, flags uint) int {
var handle w32.HWND
parent := windows.top()
if parent != nil {
handle = parent.handle
}
return w32.MessageBox(handle, text, caption, w32.MB_TOPMOST|flags)
}