Use associated window in wxMSWDCImpl::GetPPI()

This commit is contained in:
Maarten Bent
2019-10-01 23:41:14 +02:00
parent abb20c414d
commit 6fb86323f5

View File

@@ -2452,10 +2452,24 @@ void wxMSWDCImpl::DoGetSizeMM(int *w, int *h) const
wxSize wxMSWDCImpl::GetPPI() const wxSize wxMSWDCImpl::GetPPI() const
{ {
int x = ::GetDeviceCaps(GetHdc(), LOGPIXELSX); // As documented by MSDN, GetDeviceCaps() returns the same value for all
int y = ::GetDeviceCaps(GetHdc(), LOGPIXELSY); // HDCs on the system, and so can't be used to retrieve the correct value
// for the HDCs associated with the windows on monitors other than the
// primary one if they use different DPI. Hence prefer to get this
// information from the associated window, if possible.
wxSize ppi;
if ( m_window )
{
ppi = m_window->GetDPI();
}
return wxSize(x, y); if ( !ppi.x || !ppi.y )
{
ppi.x = ::GetDeviceCaps(GetHdc(), LOGPIXELSX);
ppi.y = ::GetDeviceCaps(GetHdc(), LOGPIXELSY);
}
return ppi;
} }
double wxMSWDCImpl::GetContentScaleFactor() const double wxMSWDCImpl::GetContentScaleFactor() const