diff --git a/v2/internal/frontend/desktop/windows/winc/controlbase.go b/v2/internal/frontend/desktop/windows/winc/controlbase.go index 8dd116780..b745cb1b0 100644 --- a/v2/internal/frontend/desktop/windows/winc/controlbase.go +++ b/v2/internal/frontend/desktop/windows/winc/controlbase.go @@ -250,6 +250,7 @@ func (cba *ControlBase) Size() (width, height int) { rect := w32.GetWindowRect(cba.hwnd) width = int(rect.Right - rect.Left) height = int(rect.Bottom - rect.Top) + width, height = cba.scaleToDefaultDPI(width, height) return } @@ -498,6 +499,14 @@ func (cba *ControlBase) scaleWithWindowDPI(width, height int) (int, int) { return scaledWidth, scaledHeight } +func (cba *ControlBase) scaleToDefaultDPI(width, height int) (int, int) { + dpix, dpiy := cba.GetWindowDPI() + scaledWidth := ScaleToDefaultDPI(width, dpix) + scaledHeight := ScaleToDefaultDPI(height, dpiy) + + return scaledWidth, scaledHeight +} + func (cba *ControlBase) tryInvokeOnCurrentGoRoutine(f func()) bool { runtime.LockOSThread() defer runtime.UnlockOSThread() diff --git a/v2/internal/frontend/desktop/windows/winc/utils.go b/v2/internal/frontend/desktop/windows/winc/utils.go index 00926c70b..c2d91a8c3 100644 --- a/v2/internal/frontend/desktop/windows/winc/utils.go +++ b/v2/internal/frontend/desktop/windows/winc/utils.go @@ -149,3 +149,8 @@ func ScreenToClientRect(hwnd w32.HWND, rect *w32.RECT) *Rect { func ScaleWithDPI(pixels int, dpi uint) int { return (pixels * int(dpi)) / 96 } + +// ScaleToDefaultDPI scales the pixels from scaled DPI-Space to default DPI-Space (96). +func ScaleToDefaultDPI(pixels int, dpi uint) int { + return (pixels * 96) / int(dpi) +}