Alexandre Julliard : user32: Get the system DPI from the registry instead of from GDI.
Alexandre Julliard
julliard at winehq.org
Thu Apr 12 15:28:14 CDT 2018
Module: wine
Branch: master
Commit: 74a9c91964bcbc9a5d550c2059c07c307c227414
URL: https://source.winehq.org/git/wine.git/?a=commit;h=74a9c91964bcbc9a5d550c2059c07c307c227414
Author: Alexandre Julliard <julliard at winehq.org>
Date: Thu Apr 12 13:24:36 2018 +0200
user32: Get the system DPI from the registry instead of from GDI.
Signed-off-by: Alexandre Julliard <julliard at winehq.org>
---
dlls/user32/sysparams.c | 32 ++++++++++++++++++++++++++------
1 file changed, 26 insertions(+), 6 deletions(-)
diff --git a/dlls/user32/sysparams.c b/dlls/user32/sysparams.c
index 95a883d..7b948eb 100644
--- a/dlls/user32/sysparams.c
+++ b/dlls/user32/sysparams.c
@@ -612,6 +612,31 @@ static BOOL init_entry_string( struct sysparam_entry *entry, const WCHAR *str )
return init_entry( entry, str, (strlenW(str) + 1) * sizeof(WCHAR), REG_SZ );
}
+static DWORD get_reg_dword( HKEY base, const WCHAR *key_name, const WCHAR *value_name )
+{
+ HKEY key;
+ DWORD type, ret = 0, size = sizeof(ret);
+
+ if (RegOpenKeyW( base, key_name, &key )) return 0;
+ if (RegQueryValueExW( key, value_name, NULL, &type, (void *)&ret, &size ) || type != REG_DWORD)
+ ret = 0;
+ RegCloseKey( key );
+ return ret;
+}
+
+/* get the system dpi from the registry */
+static UINT get_system_dpi(void)
+{
+ static const WCHAR dpi_key_name[] = {'C','o','n','t','r','o','l',' ','P','a','n','e','l','\\','D','e','s','k','t','o','p','\0'};
+ static const WCHAR def_dpi_key_name[] = {'S','o','f','t','w','a','r','e','\\','F','o','n','t','s','\0'};
+ static const WCHAR dpi_value_name[] = {'L','o','g','P','i','x','e','l','s','\0'};
+ DWORD dpi;
+
+ if ((dpi = get_reg_dword( HKEY_CURRENT_USER, dpi_key_name, dpi_value_name ))) return dpi;
+ if ((dpi = get_reg_dword( HKEY_CURRENT_CONFIG, def_dpi_key_name, dpi_value_name ))) return dpi;
+ return USER_DEFAULT_SCREEN_DPI;
+}
+
HDC get_display_dc(void)
{
static const WCHAR DISPLAY[] = {'D','I','S','P','L','A','Y',0};
@@ -3065,12 +3090,7 @@ UINT WINAPI GetDpiForSystem(void)
if (!IsProcessDPIAware()) return USER_DEFAULT_SCREEN_DPI;
- if (!display_dpi)
- {
- HDC hdc = get_display_dc();
- display_dpi = GetDeviceCaps( hdc, LOGPIXELSY );
- release_display_dc( hdc );
- }
+ if (!display_dpi) display_dpi = get_system_dpi();
return display_dpi;
}
More information about the wine-cvs
mailing list