Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update DPI awareness context and handle WM_DPICHANGED for dynamic DPI adjustments #143

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion Photino.Native/Photino.Windows.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ void Photino::Register(HINSTANCE hInstance)

RegisterClassEx(&wcx);

SetThreadDpiAwarenessContext(DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE);
SetThreadDpiAwarenessContext(DPI_AWARENESS_CONTEXT_PER_MONITOR_AWARE_V2);
}

Photino::Photino(PhotinoInitParams* initParams)
Expand Down Expand Up @@ -333,6 +333,25 @@ LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
}
break;
}
case WM_DPICHANGED:
{
UINT dpiX = HIWORD(wParam);
UINT dpiY = LOWORD(wParam);

RECT* newWindowRect = (RECT*)lParam;

SetWindowPos(
hwnd,
NULL,
newWindowRect->left,
newWindowRect->top,
newWindowRect->right - newWindowRect->left,
newWindowRect->bottom - newWindowRect->top,
SWP_NOZORDER | SWP_NOACTIVATE
);

return 0;
}
case WM_SETTINGCHANGE:
{
if (IsColorSchemeChange(lParam))
Expand Down