diff --git a/internal/w32/w32.go b/internal/w32/w32.go index cfd1bfb..f765aeb 100644 --- a/internal/w32/w32.go +++ b/internal/w32/w32.go @@ -1,10 +1,11 @@ package w32 import ( - "golang.org/x/sys/windows" "syscall" "unicode/utf16" "unsafe" + + "golang.org/x/sys/windows" ) var ( @@ -38,6 +39,8 @@ var ( User32SetWindowLongPtrW = user32.NewProc("SetWindowLongPtrW") User32AdjustWindowRect = user32.NewProc("AdjustWindowRect") User32SetWindowPos = user32.NewProc("SetWindowPos") + User32IsDialogMessage = user32.NewProc("IsDialogMessage") + User32GetAncestor = user32.NewProc("GetAncestor") ) const ( @@ -68,6 +71,12 @@ const ( WMApp = 0x8000 ) +const ( + GAParent = 1 + GARoot = 2 + GARootOwner = 3 +) + const ( GWLStyle = -16 ) diff --git a/webview.go b/webview.go index 15328f7..591b698 100644 --- a/webview.go +++ b/webview.go @@ -298,6 +298,11 @@ func (w *webview) Run() { } else if msg.Message == w32.WMQuit { return } + r, _, _ := w32.User32GetAncestor.Call(uintptr(msg.Hwnd), w32.GARoot) + r, _, _ = w32.User32IsDialogMessage.Call(r, uintptr(unsafe.Pointer(&msg))) + if r != 0 { + continue + } _, _, _ = w32.User32TranslateMessage.Call(uintptr(unsafe.Pointer(&msg))) _, _, _ = w32.User32DispatchMessageW.Call(uintptr(unsafe.Pointer(&msg))) }