Use DPI Aware wxGetSystemMetrics

If no wxWindow is known, use wxTheApp->GetTopWindow().
Also use a wxWindow for all wxSystemSettings::GetMetric calls.
This commit is contained in:
Maarten Bent
2018-07-22 14:16:51 +02:00
parent 04b99d54bd
commit f74d756ca5
37 changed files with 106 additions and 87 deletions

View File

@@ -473,9 +473,10 @@ bool wxICOFileHandler::LoadIcon(wxIcon *icon,
}
else
#endif
// were we asked for a large icon?
if ( desiredWidth == ::GetSystemMetrics(SM_CXICON) &&
desiredHeight == ::GetSystemMetrics(SM_CYICON) )
// were we asked for a large icon?
const wxWindow* win = wxTheApp ? wxTheApp->GetTopWindow() : NULL;
if ( desiredWidth == wxGetSystemMetrics(SM_CXICON, win) &&
desiredHeight == wxGetSystemMetrics(SM_CYICON, win) )
{
// get the specified large icon from file
if ( !::ExtractIconEx(nameReal.t_str(), iconIndex, &hicon, NULL, 1) )
@@ -487,8 +488,8 @@ bool wxICOFileHandler::LoadIcon(wxIcon *icon,
name.c_str());
}
}
else if ( desiredWidth == ::GetSystemMetrics(SM_CXSMICON) &&
desiredHeight == ::GetSystemMetrics(SM_CYSMICON) )
else if ( desiredWidth == wxGetSystemMetrics(SM_CXSMICON, win) &&
desiredHeight == wxGetSystemMetrics(SM_CYSMICON, win) )
{
// get the specified small icon from file
if ( !::ExtractIconEx(nameReal.t_str(), iconIndex, NULL, &hicon, 1) )
@@ -668,8 +669,9 @@ wxSize wxGetHiconSize(HICON hicon)
if ( !size.x )
{
// use default icon size on this hardware
size.x = ::GetSystemMetrics(SM_CXICON);
size.y = ::GetSystemMetrics(SM_CYICON);
const wxWindow* win = wxTheApp ? wxTheApp->GetTopWindow() : NULL;
size.x = wxGetSystemMetrics(SM_CXICON, win);
size.y = wxGetSystemMetrics(SM_CYICON, win);
}
return size;