diff options
author | John Ankarström <john@ankarstrom.se> | 2022-04-01 13:29:25 +0200 |
---|---|---|
committer | John Ankarström <john@ankarstrom.se> | 2022-04-01 13:29:25 +0200 |
commit | 7b7fcdfef7487770d3089bafaedf467e30ed3afe (patch) | |
tree | 9ae144830bbf4a4ed8b96da3459bef4f30579f30 /c/main.c | |
parent | 0b32a837283c4f90aee67f0721e38bf929a04882 (diff) | |
download | EpisodeBrowser-7b7fcdfef7487770d3089bafaedf467e30ed3afe.tar.gz |
Support per-monitor DPI.
Diffstat (limited to 'c/main.c')
-rw-r--r-- | c/main.c | 18 |
1 files changed, 17 insertions, 1 deletions
@@ -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: |