Add debugging check for using possibly incorrect DPI in wxMSW
When calling GetDPI() for a window which is not created itself yet and doesn't have any valid top level parent neither, we have no choice but to fall back on using the screen DPI, but this doesn't always work correctly for the systems using multiple monitors with different DPIs, so warn when this happens -- any situations when it does indicate a potential bug that should be fixed. See #22193.
This commit is contained in:
@@ -4872,6 +4872,17 @@ wxSize wxWindowMSW::GetDPI() const
|
||||
{
|
||||
hwnd = GetHwndOf(topWin);
|
||||
}
|
||||
|
||||
if ( hwnd == NULL )
|
||||
{
|
||||
// We shouldn't be using this function without a valid HWND because
|
||||
// we can't really find the correct DPI to use in this case for a
|
||||
// system with multiple monitors using different DPIs, so warn
|
||||
// about doing it but still return the screen DPI which will often,
|
||||
// if not always, be the correct value to use anyhow.
|
||||
wxLogDebug("Using possibly wrong DPI for %s", wxDumpWindow(this));
|
||||
return wxGetDPIofHDC(ScreenHDC());
|
||||
}
|
||||
}
|
||||
|
||||
wxSize dpi = GetWindowDPI(hwnd);
|
||||
|
||||
Reference in New Issue
Block a user