From: <sv...@op...> - 2024-11-24 20:15:46
|
Author: sagamusix Date: Sun Nov 24 21:15:34 2024 New Revision: 22291 URL: https://source.openmpt.org/browse/openmpt/?op=revision&rev=22291 Log: [Fix] Quick Start: Use DPI-aware AdjustWindowRectEx if available. Modified: trunk/OpenMPT/mptrack/HighDPISupport.cpp trunk/OpenMPT/mptrack/HighDPISupport.h trunk/OpenMPT/mptrack/QuickStartDialog.cpp Modified: trunk/OpenMPT/mptrack/HighDPISupport.cpp ============================================================================== --- trunk/OpenMPT/mptrack/HighDPISupport.cpp Sun Nov 24 14:05:15 2024 (r22290) +++ trunk/OpenMPT/mptrack/HighDPISupport.cpp Sun Nov 24 21:15:34 2024 (r22291) @@ -25,6 +25,7 @@ m_user32.Bind(m_GetDpiForWindow, "GetDpiForWindow"); m_user32.Bind(m_GetSystemMetricsForDpi, "GetSystemMetricsForDpi"); m_user32.Bind(m_SystemParametersInfoForDpi, "SystemParametersInfoForDpi"); + m_user32.Bind(m_AdjustWindowRectExForDpi, "AdjustWindowRectExForDpi"); } mpt::Library m_user32; @@ -40,6 +41,9 @@ using PSYSTEMPARAMETERSINFOFORPDI = BOOL(WINAPI *)(UINT, UINT, void *, UINT, UINT); PSYSTEMPARAMETERSINFOFORPDI m_SystemParametersInfoForDpi = nullptr; + + using PADJUSTWINDOWRECTEXFORDPI = BOOL(WINAPI *)(LPRECT, DWORD, BOOL, DWORD, UINT); + PADJUSTWINDOWRECTEXFORDPI m_AdjustWindowRectExForDpi = nullptr; }; @@ -154,6 +158,15 @@ } +BOOL HighDPISupport::AdjustWindowRectEx(LPRECT lpRect, DWORD dwStyle, BOOL bMenu, DWORD dwExStyle, uint32 dpi) +{ + if(auto instance = GetHighDPISupportData(); instance->m_AdjustWindowRectExForDpi) + return instance->m_AdjustWindowRectExForDpi(lpRect, dwStyle, bMenu, dwExStyle, dpi); + else + return ::AdjustWindowRectEx(lpRect, dwStyle, bMenu, dwExStyle); +} + + void HighDPISupport::CreateGUIFont(CFont &font, HWND hwnd) { NONCLIENTMETRICS metrics; Modified: trunk/OpenMPT/mptrack/HighDPISupport.h ============================================================================== --- trunk/OpenMPT/mptrack/HighDPISupport.h Sun Nov 24 14:05:15 2024 (r22290) +++ trunk/OpenMPT/mptrack/HighDPISupport.h Sun Nov 24 21:15:34 2024 (r22291) @@ -40,6 +40,7 @@ int GetSystemMetrics(int index, HWND hwnd); BOOL SystemParametersInfo(UINT uiAction, UINT uiParam, void *pvParam, UINT fWinIni, uint32 dpi); BOOL SystemParametersInfo(UINT uiAction, UINT uiParam, void *pvParam, UINT fWinIni, HWND hwnd); + BOOL AdjustWindowRectEx(LPRECT lpRect, DWORD dwStyle, BOOL bMenu, DWORD dwExStyle, uint32 dpi); void CreateGUIFont(CFont &font, HWND hwnd); Modified: trunk/OpenMPT/mptrack/QuickStartDialog.cpp ============================================================================== --- trunk/OpenMPT/mptrack/QuickStartDialog.cpp Sun Nov 24 14:05:15 2024 (r22290) +++ trunk/OpenMPT/mptrack/QuickStartDialog.cpp Sun Nov 24 21:15:34 2024 (r22291) @@ -125,7 +125,7 @@ CRect windowRect{CPoint{}, m_prevSize}; windowRect.right = Util::muldiv(windowRect.right, GetDPI(), m_prevDPI); windowRect.bottom = Util::muldiv(windowRect.bottom, GetDPI(), m_prevDPI); - AdjustWindowRectEx(windowRect, GetStyle(), FALSE, GetExStyle()); + HighDPISupport::AdjustWindowRectEx(windowRect, GetStyle(), FALSE, GetExStyle(), GetDPI()); SetWindowPos(nullptr, 0, 0, windowRect.Width(), windowRect.Height(), SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOMOVE); } @@ -205,7 +205,7 @@ windowRect.bottom += viewRect.bottom - listRect.bottom; const int maxHeight = Util::muldiv(parentRect.bottom, 9, 10); LimitMax(windowRect.bottom, maxHeight); - AdjustWindowRectEx(windowRect, GetStyle(), FALSE, GetExStyle()); + HighDPISupport::AdjustWindowRectEx(windowRect, GetStyle(), FALSE, GetExStyle(), GetDPI()); SetWindowPos(nullptr, 0, 0, windowRect.Width(), windowRect.Height(), SWP_NOZORDER | SWP_NOACTIVATE | SWP_NOMOVE); } |