use native win32 messagebox to prevent wails dialog crash
All checks were successful
Deploy on Master Change / deploy (push) Successful in 37s

This commit is contained in:
2026-07-01 08:54:01 +07:00
parent 745e93d28d
commit 7a8c397538
3 changed files with 38 additions and 15 deletions

View File

@@ -19,6 +19,7 @@ var (
procSetForegroundWindow = user32Window.NewProc("SetForegroundWindow")
procFlashWindowEx = user32Window.NewProc("FlashWindowEx")
procMessageBeep = user32Window.NewProc("MessageBeep")
procMessageBoxW = user32Window.NewProc("MessageBoxW")
)
const (
@@ -89,3 +90,13 @@ func findWindowByTitleContains(hint string) uintptr {
_, _, _ = procEnumWindows.Call(enumWindowsCallback, 0)
return enumFoundHwnd
}
// ShowWarningMessageBox hiển thị hộp thoại cảnh báo Win32 bất đồng bộ
func ShowWarningMessageBox(title, message string) {
titlePtr, _ := syscall.UTF16PtrFromString(title)
messagePtr, _ := syscall.UTF16PtrFromString(message)
go func() {
// MB_ICONWARNING = 0x00000030, MB_TOPMOST = 0x00040000
_, _, _ = procMessageBoxW.Call(0, uintptr(unsafe.Pointer(messagePtr)), uintptr(unsafe.Pointer(titlePtr)), 0x00040030)
}()
}