user32: Scale dialog base units based on DPI awareness.

Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Alexandre Julliard 2018-08-28 12:05:55 +02:00
parent 19c364bd0d
commit a525631920
2 changed files with 16 additions and 8 deletions

View File

@ -1505,22 +1505,22 @@ BOOL WINAPI CheckRadioButton( HWND hwndDlg, int firstID,
*/ */
DWORD WINAPI GetDialogBaseUnits(void) DWORD WINAPI GetDialogBaseUnits(void)
{ {
static DWORD units; static LONG cx, cy;
if (!units) if (!cx)
{ {
HDC hdc; HDC hdc;
SIZE size;
if ((hdc = GetDC(0))) if ((hdc = GetDC(0)))
{ {
size.cx = GdiGetCharDimensions( hdc, NULL, &size.cy ); cx = GdiGetCharDimensions( hdc, NULL, &cy );
if (size.cx) units = MAKELONG( size.cx, size.cy );
ReleaseDC( 0, hdc ); 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 ));
} }

View File

@ -3217,7 +3217,7 @@ static void test_dpi_mapping(void)
{ {
HWND hwnd, child; HWND hwnd, child;
HDC hdc; HDC hdc;
UINT win_dpi; UINT win_dpi, units;
POINT point; POINT point;
BOOL ret; BOOL ret;
HRGN rgn, update; HRGN rgn, update;
@ -3292,6 +3292,7 @@ static void test_dpi_mapping(void)
ShowWindow( hwnd, SW_MINIMIZE ); ShowWindow( hwnd, SW_MINIMIZE );
ShowWindow( hwnd, SW_RESTORE ); ShowWindow( hwnd, SW_RESTORE );
GetWindowPlacement( hwnd, &wpl_orig ); GetWindowPlacement( hwnd, &wpl_orig );
units = GetDialogBaseUnits();
for (j = DPI_AWARENESS_UNAWARE; j <= DPI_AWARENESS_PER_MONITOR_AWARE; j++) 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) ); i, j, wine_dbgstr_rect(&rect), wine_dbgstr_rect(&expect) );
UpdateWindow( hwnd ); UpdateWindow( hwnd );
DeleteObject( update ); 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 */ /* test window points mapping */
SetRect( &rect, 0, 0, 100, 100 ); SetRect( &rect, 0, 0, 100, 100 );
rect.right = rect.left + 100; rect.right = rect.left + 100;