From db1b664424b8d610d8caf348bfadbd3c49ede3aa Mon Sep 17 00:00:00 2001 From: Hajime Hoshi Date: Fri, 4 Jan 2019 06:02:19 +0900 Subject: [PATCH] devicescale: Refactoring: define Windows error consts --- internal/devicescale/impl_windows.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/internal/devicescale/impl_windows.go b/internal/devicescale/impl_windows.go index 498e43ce9..026aa7aaf 100644 --- a/internal/devicescale/impl_windows.go +++ b/internal/devicescale/impl_windows.go @@ -190,8 +190,16 @@ func getDpiForMonitor(hMonitor uintptr, dpiType uintptr, dpiX, dpiY uintptr) err func getFromLogPixelSx() float64 { dc, err := getWindowDC(0) if err != nil { + const ( + errorInvalidWindowHandle = 1400 + errorResourceDataNotFound = 1812 + ) // On Wine, it looks like GetWindowDC(0) doesn't work (#738, #743). - if code := err.(*winErr).Code; code == 1400 || code == 1812 { + code := err.(*winErr).Code + if code == errorInvalidWindowHandle { + return 1 + } + if code == errorResourceDataNotFound { return 1 } panic(err)