mirror of
https://github.com/wailsapp/wails.git
synced 2026-03-14 14:45:49 +01:00
[v3 windows] Add MessageBoxIndirect
This commit is contained in:
parent
f9a87944cf
commit
23d7ac0e58
3 changed files with 49 additions and 0 deletions
28
v3/pkg/w32/dialogs.go
Normal file
28
v3/pkg/w32/dialogs.go
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
//go:build windows
|
||||
|
||||
package w32
|
||||
|
||||
import (
|
||||
"unsafe"
|
||||
)
|
||||
|
||||
func MessageBoxWithIcon(hwnd HWND, text *uint16, caption *uint16, iconID int, flags uint32) (int32, error) {
|
||||
|
||||
params := MSGBOXPARAMS{
|
||||
cbSize: uint32(unsafe.Sizeof(MSGBOXPARAMS{})),
|
||||
hwndOwner: hwnd,
|
||||
hInstance: 0,
|
||||
lpszText: text,
|
||||
lpszCaption: caption,
|
||||
dwStyle: flags,
|
||||
lpszIcon: (*uint16)(unsafe.Pointer(uintptr(iconID))),
|
||||
}
|
||||
|
||||
r, _, err := procMessageBoxIndirect.Call(
|
||||
uintptr(unsafe.Pointer(¶ms)),
|
||||
)
|
||||
if r == 0 {
|
||||
return 0, err
|
||||
}
|
||||
return int32(r), nil
|
||||
}
|
||||
|
|
@ -476,6 +476,19 @@ type DIBSECTION struct {
|
|||
DsOffset uint32
|
||||
}
|
||||
|
||||
type MSGBOXPARAMS struct {
|
||||
cbSize uint32
|
||||
hwndOwner HWND
|
||||
hInstance HANDLE
|
||||
lpszText *uint16
|
||||
lpszCaption *uint16
|
||||
dwStyle uint32
|
||||
lpszIcon *uint16
|
||||
dwContextHelp uintptr
|
||||
lpfnMsgBoxCallback uintptr
|
||||
dwLanguageId uint32
|
||||
}
|
||||
|
||||
// http://msdn.microsoft.com/en-us/library/windows/desktop/dd162607.aspx
|
||||
type ENHMETAHEADER struct {
|
||||
IType uint32
|
||||
|
|
|
|||
|
|
@ -67,6 +67,7 @@ var (
|
|||
procReleaseCapture = moduser32.NewProc("ReleaseCapture")
|
||||
procGetWindowThreadProcessId = moduser32.NewProc("GetWindowThreadProcessId")
|
||||
procMessageBox = moduser32.NewProc("MessageBoxW")
|
||||
procMessageBoxIndirect = moduser32.NewProc("MessageBoxIndirectW")
|
||||
procGetSystemMetrics = moduser32.NewProc("GetSystemMetrics")
|
||||
procPostThreadMessageW = moduser32.NewProc("PostThreadMessageW")
|
||||
procRegisterWindowMessageA = moduser32.NewProc("RegisterWindowMessageA")
|
||||
|
|
@ -222,6 +223,13 @@ func LoadCursorWithResourceID(instance HINSTANCE, res uint16) HCURSOR {
|
|||
return HCURSOR(ret)
|
||||
}
|
||||
|
||||
func MessageBoxIndirect(msgbox *MSGBOXPARAMS) int32 {
|
||||
ret, _, _ := procMessageBoxIndirect.Call(
|
||||
uintptr(unsafe.Pointer(msgbox)))
|
||||
|
||||
return int32(ret)
|
||||
}
|
||||
|
||||
func ShowWindow(hwnd HWND, cmdshow int) bool {
|
||||
ret, _, _ := procShowWindow.Call(
|
||||
uintptr(hwnd),
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue