From a525631920d74e9d797f38305b89e63aed1c5c41 Mon Sep 17 00:00:00 2001 From: Alexandre Julliard Date: Tue, 28 Aug 2018 12:05:55 +0200 Subject: [PATCH] user32: Scale dialog base units based on DPI awareness. Signed-off-by: Alexandre Julliard --- 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 e584cc1d048..7b918193fd8 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 846551e5897..8f9defc41fb 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;