Skip to content

Commit

Permalink
[v2, windows] Make SetBackgroundColour compatible for windows/386
Browse files Browse the repository at this point in the history
  • Loading branch information
stffabi committed Jun 24, 2022
1 parent fe16186 commit 54150c9
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
1 change: 1 addition & 0 deletions v2/internal/frontend/desktop/windows/win32/consts.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ var (
moduser32 = syscall.NewLazyDLL("user32.dll")
procSystemParametersInfo = moduser32.NewProc("SystemParametersInfoW")
procGetWindowLong = moduser32.NewProc("GetWindowLongW")
procSetClassLong = moduser32.NewProc("SetClassLongW")
procSetClassLongPtr = moduser32.NewProc("SetClassLongPtrW")
procShowWindow = moduser32.NewProc("ShowWindow")
)
Expand Down
18 changes: 16 additions & 2 deletions v2/internal/frontend/desktop/windows/win32/window.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@ package win32

import (
"fmt"
"github.com/wailsapp/wails/v2/internal/frontend/desktop/windows/winc"
"log"
"strconv"
"syscall"
"unsafe"

"github.com/wailsapp/wails/v2/internal/frontend/desktop/windows/winc"
)

const (
Expand Down Expand Up @@ -119,7 +121,19 @@ func dwmExtendFrameIntoClientArea(hwnd uintptr, margins *MARGINS) error {
}

func setClassLongPtr(hwnd uintptr, param int32, val uintptr) bool {
ret, _, _ := procSetClassLongPtr.Call(
proc := procSetClassLongPtr
if strconv.IntSize == 32 {
/*
https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-setclasslongptrw
Note: To write code that is compatible with both 32-bit and 64-bit Windows, use SetClassLongPtr.
When compiling for 32-bit Windows, SetClassLongPtr is defined as a call to the SetClassLong function
=> We have to do this dynamically when directly calling the DLL procedures
*/
proc = procSetClassLong
}

ret, _, _ := proc.Call(
hwnd,
uintptr(param),
val,
Expand Down

0 comments on commit 54150c9

Please sign in to comment.