From 18a715c7936a262059d75b4d4535edc8795ccb3c Mon Sep 17 00:00:00 2001 From: Toni Wilen Date: Wed, 16 Aug 2017 21:39:19 +0300 Subject: [PATCH] Text window DPI fix. --- od-win32/win32gui.cpp | 4 ++-- od-win32/win32gui.h | 2 +- od-win32/win32gui_extra.cpp | 10 ++++++++++ 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/od-win32/win32gui.cpp b/od-win32/win32gui.cpp index fa45d966..95c63120 100644 --- a/od-win32/win32gui.cpp +++ b/od-win32/win32gui.cpp @@ -2409,7 +2409,7 @@ void gui_infotextbox(HWND hDlg, const TCHAR *text) if (hwnd == NULL) return; - HFONT font = CreateFont (12, 0, 0, 0, 0, 0, 0, 0, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE, _T("Lucida Console")); + HFONT font = CreateFont (getscaledfontsize(-1), 0, 0, 0, 0, 0, 0, 0, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE, _T("Lucida Console")); if (font) SendMessage (GetDlgItem (hwnd, IDC_DISKINFOBOX), WM_SETFONT, WPARAM(font), FALSE); SendMessage (GetDlgItem (hwnd, IDC_DISKINFOBOX), WM_SETTEXT, 0, (LPARAM)text); @@ -2476,7 +2476,7 @@ static void infofloppy (HWND hDlg, int n) if (hwnd == NULL) return; - HFONT font = CreateFont (12, 0, 0, 0, 0, 0, 0, 0, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE, _T("Lucida Console")); + HFONT font = CreateFont (getscaledfontsize(-1), 0, 0, 0, 0, 0, 0, 0, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE, _T("Lucida Console")); if (font) SendMessage (GetDlgItem (hwnd, IDC_DISKINFOBOX), WM_SETFONT, WPARAM(font), FALSE); SendMessage (GetDlgItem (hwnd, IDC_DISKINFOBOX), WM_SETTEXT, 0, (LPARAM)text); diff --git a/od-win32/win32gui.h b/od-win32/win32gui.h index ae6f374c..ef92810d 100644 --- a/od-win32/win32gui.h +++ b/od-win32/win32gui.h @@ -47,5 +47,5 @@ extern void scaleresource_setdefaults (void); extern void scaleresource_setfont (HWND hDlg); extern void scaleresource_getdpimult (double*, double*, int*, int*); extern void scalaresource_listview_font_info(int*); - +extern int getscaledfontsize(int size); #endif diff --git a/od-win32/win32gui_extra.cpp b/od-win32/win32gui_extra.cpp index 39449e35..e2b0f52d 100644 --- a/od-win32/win32gui_extra.cpp +++ b/od-win32/win32gui_extra.cpp @@ -325,6 +325,16 @@ void freescaleresource (struct newresource *ns) xfree (ns); } +int getscaledfontsize(int size) +{ + HDC hdc = GetDC(NULL); + if (size <= 0) + size = fontsize_gui; + size = -MulDiv(size, GetDeviceCaps(hdc, LOGPIXELSY), 72); + ReleaseDC(NULL, hdc); + return size; +} + static void openfont (bool force) { HDC hdc; -- 2.47.3