Skip to content
This repository has been archived by the owner on Aug 23, 2019. It is now read-only.

Commit

Permalink
add SetProcessDPIAware
Browse files Browse the repository at this point in the history
  • Loading branch information
shelllet committed Jul 25, 2019
1 parent ef13a8a commit 8beb721
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion user32.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
"encoding/binary"
"errors"
"fmt"

//"regexp"
"syscall"
"unicode/utf8"
Expand Down Expand Up @@ -136,6 +137,7 @@ var (
procVkKeyScanW = moduser32.NewProc("VkKeyScanW")
procVkKeyScanExW = moduser32.NewProc("VkKeyScanExW")
procWaitMessage = moduser32.NewProc("WaitMessage")
setProcessDPIAware = moduser32.NewProc("SetProcessDPIAware")
)

func SendMessageTimeout(hwnd HWND, msg uint32, wParam, lParam uintptr, fuFlags, uTimeout uint32, lpdwResult uintptr) uintptr {
Expand Down Expand Up @@ -1261,11 +1263,18 @@ func VkKeyScanW(char uint16) int16 {
}

// Translates a character to the corresponding virtual-key code and shift state.
//See https://docs.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-vkkeyscanexw
// See https://docs.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-vkkeyscanexw
func VkKeyScanExW(char uint16, hkl HKL) int16 {
ret, _, _ := procVkKeyScanExW.Call(
uintptr(char),
uintptr(hkl),
)
return int16(ret)
}

// Sets the process-default DPI awareness to system-DPI awareness.
// See https://docs.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-setprocessdpiaware
func SetProcessDPIAware() bool {
ret, _, _ := setProcessDPIAware.Call()
return ret != 0
}

0 comments on commit 8beb721

Please sign in to comment.