Skip to content

Commit 5659883

Browse files
authored
Fix Windows 32-bit support for GetWindowLong/SetWindowLong functions (#81)
* Fix Windows 32-bit support for GetWindowLong/SetWindowLong functions * Use build tags --------- Co-authored-by: LowLvlGod <88935541+LowLvlGod@users.noreply.github.com>
1 parent 0bcfea0 commit 5659883

File tree

4 files changed

+33
-2
lines changed

4 files changed

+33
-2
lines changed

internal/w32/w32.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,9 @@ var (
3636
User32PostMessageW = user32.NewProc("PostMessageW")
3737
User32SetWindowTextW = user32.NewProc("SetWindowTextW")
3838
User32PostThreadMessageW = user32.NewProc("PostThreadMessageW")
39+
User32GetWindowLongW = user32.NewProc("GetWindowLongW")
3940
User32GetWindowLongPtrW = user32.NewProc("GetWindowLongPtrW")
41+
User32SetWindowLongW = user32.NewProc("SetWindowLongW")
4042
User32SetWindowLongPtrW = user32.NewProc("SetWindowLongPtrW")
4143
User32AdjustWindowRect = user32.NewProc("AdjustWindowRect")
4244
User32SetWindowPos = user32.NewProc("SetWindowPos")

internal/w32/w32_386.go

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
//go:build windows && 386
2+
// +build windows,386
3+
4+
package w32
5+
6+
func GetWindowLong(hwnd uintptr, index int) uintptr {
7+
ret, _, _ := User32GetWindowLongW.Call(hwnd, uintptr(index))
8+
return ret
9+
}
10+
11+
func SetWindowLong(hwnd uintptr, index int, newLong uintptr) uintptr {
12+
ret, _, _ := User32SetWindowLongW.Call(hwnd, uintptr(index), newLong)
13+
return ret
14+
}

internal/w32/w32_64bit.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
//go:build windows && (amd64 || arm64)
2+
// +build windows
3+
// +build amd64 arm64
4+
5+
package w32
6+
7+
func GetWindowLong(hwnd uintptr, index int) uintptr {
8+
ret, _, _ := User32GetWindowLongPtrW.Call(hwnd, uintptr(index))
9+
return ret
10+
}
11+
12+
func SetWindowLong(hwnd uintptr, index int, newLong uintptr) uintptr {
13+
ret, _, _ := User32SetWindowLongPtrW.Call(hwnd, uintptr(index), newLong)
14+
return ret
15+
}

webview.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -404,13 +404,13 @@ func (w *webview) SetTitle(title string) {
404404

405405
func (w *webview) SetSize(width int, height int, hints Hint) {
406406
index := w32.GWLStyle
407-
style, _, _ := w32.User32GetWindowLongPtrW.Call(w.hwnd, uintptr(index))
407+
style := w32.GetWindowLong(w.hwnd, index)
408408
if hints == HintFixed {
409409
style &^= (w32.WSThickFrame | w32.WSMaximizeBox)
410410
} else {
411411
style |= (w32.WSThickFrame | w32.WSMaximizeBox)
412412
}
413-
_, _, _ = w32.User32SetWindowLongPtrW.Call(w.hwnd, uintptr(index), style)
413+
w32.SetWindowLong(w.hwnd, index, style)
414414

415415
if hints == HintMax {
416416
w.maxsz.X = int32(width)

0 commit comments

Comments
 (0)