diff --git a/internal/w32/w32.go b/internal/w32/w32.go index 35aa2f3..e76f894 100644 --- a/internal/w32/w32.go +++ b/internal/w32/w32.go @@ -36,7 +36,9 @@ var ( User32PostMessageW = user32.NewProc("PostMessageW") User32SetWindowTextW = user32.NewProc("SetWindowTextW") User32PostThreadMessageW = user32.NewProc("PostThreadMessageW") + User32GetWindowLongW = user32.NewProc("GetWindowLongW") User32GetWindowLongPtrW = user32.NewProc("GetWindowLongPtrW") + User32SetWindowLongW = user32.NewProc("SetWindowLongW") User32SetWindowLongPtrW = user32.NewProc("SetWindowLongPtrW") User32AdjustWindowRect = user32.NewProc("AdjustWindowRect") User32SetWindowPos = user32.NewProc("SetWindowPos") diff --git a/internal/w32/w32_386.go b/internal/w32/w32_386.go new file mode 100644 index 0000000..728d4c7 --- /dev/null +++ b/internal/w32/w32_386.go @@ -0,0 +1,14 @@ +//go:build windows && 386 +// +build windows,386 + +package w32 + +func GetWindowLong(hwnd uintptr, index int) uintptr { + ret, _, _ := User32GetWindowLongW.Call(hwnd, uintptr(index)) + return ret +} + +func SetWindowLong(hwnd uintptr, index int, newLong uintptr) uintptr { + ret, _, _ := User32SetWindowLongW.Call(hwnd, uintptr(index), newLong) + return ret +} diff --git a/internal/w32/w32_64bit.go b/internal/w32/w32_64bit.go new file mode 100644 index 0000000..b5bf9d9 --- /dev/null +++ b/internal/w32/w32_64bit.go @@ -0,0 +1,15 @@ +//go:build windows && (amd64 || arm64) +// +build windows +// +build amd64 arm64 + +package w32 + +func GetWindowLong(hwnd uintptr, index int) uintptr { + ret, _, _ := User32GetWindowLongPtrW.Call(hwnd, uintptr(index)) + return ret +} + +func SetWindowLong(hwnd uintptr, index int, newLong uintptr) uintptr { + ret, _, _ := User32SetWindowLongPtrW.Call(hwnd, uintptr(index), newLong) + return ret +} diff --git a/webview.go b/webview.go index 263d083..8f35aec 100644 --- a/webview.go +++ b/webview.go @@ -404,13 +404,13 @@ func (w *webview) SetTitle(title string) { func (w *webview) SetSize(width int, height int, hints Hint) { index := w32.GWLStyle - style, _, _ := w32.User32GetWindowLongPtrW.Call(w.hwnd, uintptr(index)) + style := w32.GetWindowLong(w.hwnd, index) if hints == HintFixed { style &^= (w32.WSThickFrame | w32.WSMaximizeBox) } else { style |= (w32.WSThickFrame | w32.WSMaximizeBox) } - _, _, _ = w32.User32SetWindowLongPtrW.Call(w.hwnd, uintptr(index), style) + w32.SetWindowLong(w.hwnd, index, style) if hints == HintMax { w.maxsz.X = int32(width)