更新代码
This commit is contained in:
1 parent
eda7e8bc96
commit
6ff632e0b0
19 files changed
+2033
-197
No files matched your search
@@ -23,6 +23,7 @@ var (
|
||||
procEnumDisplayMonitors = user32.NewProc("EnumDisplayMonitors")
|
||||
procGetMonitorInfoW = user32.NewProc("GetMonitorInfoW")
|
||||
procGetDpiForMonitor = shcore.NewProc("GetDpiForMonitor")
|
||||
procMessageBoxW = user32.NewProc("MessageBoxW")
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -242,3 +243,30 @@ func MoveTo(hwnd syscall.Handle, r Rect) error {
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// 消息框的图标与按钮常量。
|
||||
const (
|
||||
// MBOK 是只有「确定」按钮的消息框。
|
||||
MBOK uintptr = 0x00000000
|
||||
// MBError 是带错误图标的消息框。
|
||||
MBError uintptr = 0x00000010
|
||||
// MBInfo 是带信息图标的消息框。
|
||||
MBInfo uintptr = 0x00000040
|
||||
)
|
||||
|
||||
// MessageBox 弹出系统原生消息框。
|
||||
// 程序打包后没有控制台窗口,启动失败之类的错误必须用弹窗告诉用户。
|
||||
func MessageBox(title, text string, icon uintptr) {
|
||||
t, err := windows.UTF16PtrFromString(title)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
m, err := windows.UTF16PtrFromString(text)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
_, _, _ = procMessageBoxW.Call(0,
|
||||
uintptr(unsafe.Pointer(m)),
|
||||
uintptr(unsafe.Pointer(t)),
|
||||
icon|MBOK)
|
||||
}
|
||||
Reference in new issue
Block a user