Skip to content

Fix Windows 32-bit support for GetWindowLong/SetWindowLong functions #81

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions internal/w32/w32.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down
14 changes: 14 additions & 0 deletions internal/w32/w32_386.go
Original file line number Diff line number Diff line change
@@ -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
}
15 changes: 15 additions & 0 deletions internal/w32/w32_64bit.go
Original file line number Diff line number Diff line change
@@ -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
}
4 changes: 2 additions & 2 deletions webview.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down