Added monitor dpi awareness to NetHackW splash dialog.

This commit is contained in:
Bart House
2018-11-13 20:48:56 -08:00
parent 8e907a0b0f
commit 489abb45f5
4 changed files with 81 additions and 25 deletions

View File

@@ -45,6 +45,17 @@ void win10_init()
}
void win10_monitor_size(HWND hWnd, int * width, int * height)
{
HMONITOR monitor = MonitorFromWindow(hWnd, MONITOR_DEFAULTTONEAREST);
MONITORINFO info;
info.cbSize = sizeof(MONITORINFO);
BOOL success = GetMonitorInfo(monitor, &info);
nhassert(success);
*width = info.rcMonitor.right - info.rcMonitor.left;
*height = info.rcMonitor.bottom - info.rcMonitor.top;
}
int win10_monitor_dpi(HWND hWnd)
{
UINT monitorDpi = 96;
@@ -63,4 +74,10 @@ int win10_monitor_dpi(HWND hWnd)
double win10_monitor_scale(HWND hWnd)
{
return (double) win10_monitor_dpi(hWnd) / 96.0;
}
void win10_monitor_info(HWND hWnd, MonitorInfo * monitorInfo)
{
monitorInfo->scale = win10_monitor_scale(hWnd);
win10_monitor_size(hWnd, &monitorInfo->width, &monitorInfo->height);
}

View File

@@ -19,11 +19,19 @@ typedef struct {
GetDpiForWindowProc GetDpiForWindow;
} Win10;
typedef struct {
double scale; // dpi of monitor / 96
int width; // in pixels
int height; // in pixels
} MonitorInfo;
extern Win10 gWin10;
void win10_init();
int win10_monitor_dpi(HWND hWnd);
double win10_monitor_scale(HWND hWnd);
void win10_monitor_size(HWND hWnd, int * width, int * height);
void win10_monitor_info(HWND hWnd, MonitorInfo * monitorInfo);
#endif // WIN10_H