From 7b7fcdfef7487770d3089bafaedf467e30ed3afe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?John=20Ankarstr=C3=B6m?= Date: Fri, 1 Apr 2022 13:29:25 +0200 Subject: Support per-monitor DPI. --- c/main.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'c/main.c') diff --git a/c/main.c b/c/main.c index 4b3a91d..3f60407 100644 --- a/c/main.c +++ b/c/main.c @@ -11,6 +11,7 @@ HFONT HfBold; HMENU HPopupMenu; HWND HFocus; HWND HWnd; +int IDPI = -1; static LRESULT CALLBACK WndProc(HWND, UINT, WPARAM, LPARAM); static INT_PTR CALLBACK AboutDlgProc(HWND, UINT, WPARAM, LPARAM); static int Attach(void); @@ -60,6 +61,7 @@ WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, tszErr = TEXT("Could not register window class."); if (!RegisterClassEx(&wc)) goto f; + /* Create window. */ hWnd = CreateWindowEx( @@ -67,11 +69,12 @@ WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, TEXT("Episode Browser"), TEXT("Episode Browser"), WS_OVERLAPPEDWINDOW, - CW_USEDEFAULT, CW_USEDEFAULT, 510, 400, + CW_USEDEFAULT, CW_USEDEFAULT, 0, 0, NULL, NULL, hInstance, NULL ); tszErr = TEXT("Could not create main window."); if (!hWnd) goto f; + SetWindowPos(hWnd, NULL, -1, -1, Dpi(510), Dpi(400), SWP_NOMOVE); SetupFonts(); ShowWindow(hWnd, nCmdShow); @@ -121,6 +124,19 @@ WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) case WM_THEMECHANGED: UpdateTheme(); break; + case 0x02E0: /* WM_DPICHANGED */ + { + LPRECT lpr; + lpr = (LPRECT)lParam; + IDPI = HIWORD(wParam); + SetWindowPos(hWnd, NULL, + lpr->left, lpr->top, + lpr->right-lpr->left, + lpr->bottom-lpr->top, + SWP_NOZORDER | SWP_NOACTIVATE); + UpdateLayout(); + break; + } case WM_ACTIVATE: switch (wParam) { case WA_INACTIVE: -- cgit v1.2.3