devicescale: Bug fix: SetProcessDPIAware needs to be called

This commit is contained in:
Hajime Hoshi 2018-01-03 15:43:56 +09:00
parent d18fc36040
commit 7b759faf36

View File

@ -32,7 +32,34 @@ package devicescale
// }
import "C"
import (
"fmt"
"syscall"
)
var (
user32 = syscall.NewLazyDLL("user32")
)
var (
procSetProcessDPIAware = user32.NewProc("SetProcessDPIAware")
)
func setProcessDPIAware() error {
r, _, e := syscall.Syscall(procSetProcessDPIAware.Addr(), 0, 0, 0, 0)
if e != 0 {
return fmt.Errorf("devicescale: SetProcessDPIAware failed: error code: %d", e)
}
if r == 0 {
return fmt.Errorf("devicescale: SetProcessDPIAware failed: returned value: %d", r)
}
return nil
}
func impl() float64 {
if err := setProcessDPIAware(); err != nil {
panic(err)
}
dpi := C.int(0)
if errmsg := C.GoString(C.getDPI(&dpi)); errmsg != "" {
panic(errmsg)