Commit a5256319 authored by Alexandre Julliard's avatar Alexandre Julliard

user32: Scale dialog base units based on DPI awareness.

parent 19c364bd
......@@ -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 ));
}
......
......@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment