Alexandre Julliard : user32: Scale dialog base units based on DPI awareness.

Alexandre Julliard julliard at winehq.org
Tue Aug 28 16:53:01 CDT 2018


Module: wine
Branch: master
Commit: a525631920d74e9d797f38305b89e63aed1c5c41
URL:    https://source.winehq.org/git/wine.git/?a=commit;h=a525631920d74e9d797f38305b89e63aed1c5c41

Author: Alexandre Julliard <julliard at winehq.org>
Date:   Tue Aug 28 12:05:55 2018 +0200

user32: Scale dialog base units based on DPI awareness.

Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 dlls/user32/dialog.c          | 14 +++++++-------
 dlls/user32/tests/sysparams.c | 10 +++++++++-
 2 files changed, 16 insertions(+), 8 deletions(-)

diff --git a/dlls/user32/dialog.c b/dlls/user32/dialog.c
index e584cc1..7b91819 100644
--- a/dlls/user32/dialog.c
+++ b/dlls/user32/dialog.c
@@ -1505,22 +1505,22 @@ BOOL WINAPI CheckRadioButton( HWND hwndDlg, int firstID,
  */
 DWORD WINAPI GetDialogBaseUnits(void)
 {
-    static DWORD units;
+    static LONG cx, cy;
 
-    if (!units)
+    if (!cx)
     {
         HDC hdc;
-        SIZE size;
 
         if ((hdc = GetDC(0)))
         {
-            size.cx = GdiGetCharDimensions( hdc, NULL, &size.cy );
-            if (size.cx) units = MAKELONG( size.cx, size.cy );
+            cx = GdiGetCharDimensions( hdc, NULL, &cy );
             ReleaseDC( 0, hdc );
         }
-        TRACE("base units = %d,%d\n", LOWORD(units), HIWORD(units) );
+        TRACE( "base units = %d,%d\n", cx, cy );
     }
-    return units;
+
+    return MAKELONG( MulDiv( cx, GetDpiForSystem(), USER_DEFAULT_SCREEN_DPI ),
+                     MulDiv( cy, GetDpiForSystem(), USER_DEFAULT_SCREEN_DPI ));
 }
 
 
diff --git a/dlls/user32/tests/sysparams.c b/dlls/user32/tests/sysparams.c
index 846551e..8f9defc 100644
--- a/dlls/user32/tests/sysparams.c
+++ b/dlls/user32/tests/sysparams.c
@@ -3217,7 +3217,7 @@ static void test_dpi_mapping(void)
 {
     HWND hwnd, child;
     HDC hdc;
-    UINT win_dpi;
+    UINT win_dpi, units;
     POINT point;
     BOOL ret;
     HRGN rgn, update;
@@ -3292,6 +3292,7 @@ static void test_dpi_mapping(void)
         ShowWindow( hwnd, SW_MINIMIZE );
         ShowWindow( hwnd, SW_RESTORE );
         GetWindowPlacement( hwnd, &wpl_orig );
+        units = GetDialogBaseUnits();
 
         for (j = DPI_AWARENESS_UNAWARE; j <= DPI_AWARENESS_PER_MONITOR_AWARE; j++)
         {
@@ -3407,6 +3408,13 @@ static void test_dpi_mapping(void)
                 i, j, wine_dbgstr_rect(&rect), wine_dbgstr_rect(&expect) );
             UpdateWindow( hwnd );
             DeleteObject( update );
+            /* test dialog units */
+            ret = GetDialogBaseUnits();
+            point.x = LOWORD( units );
+            point.y = HIWORD( units );
+            scale_point_dpi_aware( &point, i, j );
+            ok( LOWORD(ret) == point.x && HIWORD(ret) == point.y, "%lu/%lu: wrong units %d,%d / %d,%d\n",
+                i, j, LOWORD(ret), HIWORD(ret), point.x, point.y );
             /* test window points mapping */
             SetRect( &rect, 0, 0, 100, 100 );
             rect.right = rect.left + 100;




More information about the wine-cvs mailing list