mirror of
https://git.sr.ht/~eliasnaur/gio
synced 2026-07-05 01:15:35 +00:00
app/internal/window: use GetDpiForWindow if available
Signed-off-by: Elias Naur <mail@eliasnaur.com>
This commit is contained in:
@@ -207,6 +207,7 @@ var (
|
||||
_GetClientRect = user32.NewProc("GetClientRect")
|
||||
_GetClipboardData = user32.NewProc("GetClipboardData")
|
||||
_GetDC = user32.NewProc("GetDC")
|
||||
_GetDpiForWindow = user32.NewProc("GetDpiForWindow")
|
||||
_GetKeyState = user32.NewProc("GetKeyState")
|
||||
_GetMessage = user32.NewProc("GetMessageW")
|
||||
_GetMessageTime = user32.NewProc("GetMessageTime")
|
||||
@@ -343,7 +344,7 @@ func getDpiForMonitor(hmonitor syscall.Handle, dpiType uint32) int {
|
||||
|
||||
// GetSystemDPI returns the effective DPI of the system.
|
||||
func GetSystemDPI() int {
|
||||
// Check for getDpiForMonitor, introduced in Windows 8.1.
|
||||
// Check for GetDpiForMonitor, introduced in Windows 8.1.
|
||||
if _GetDpiForMonitor.Find() == nil {
|
||||
hmon := monitorFromPoint(Point{}, MONITOR_DEFAULTTOPRIMARY)
|
||||
return getDpiForMonitor(hmon, MDT_EFFECTIVE_DPI)
|
||||
@@ -377,6 +378,17 @@ func GetMessageTime() time.Duration {
|
||||
return time.Duration(r) * time.Millisecond
|
||||
}
|
||||
|
||||
// GetWindowDPI returns the effective DPI of the window.
|
||||
func GetWindowDPI(hwnd syscall.Handle) int {
|
||||
// Check for GetDpiForWindow, introduced in Windows 10.
|
||||
if _GetDpiForWindow.Find() == nil {
|
||||
dpi, _, _ := _GetDpiForWindow.Call(uintptr(hwnd))
|
||||
return int(dpi)
|
||||
} else {
|
||||
return GetSystemDPI()
|
||||
}
|
||||
}
|
||||
|
||||
func GlobalAlloc(size int) (syscall.Handle, error) {
|
||||
r, _, err := _GlobalAlloc.Call(GHND, uintptr(size))
|
||||
if r == 0 {
|
||||
|
||||
Reference in New Issue
Block a user