Add DPI Aware replacement of SystemParametersInfo

Use SystemParametersInfoForDpi when this function is available and the DPI is
known. Otherwise keep using SystemParametersInfo.
This commit is contained in:
Maarten Bent
2018-07-22 14:20:38 +02:00
parent f74d756ca5
commit c0c6a4b826
2 changed files with 39 additions and 0 deletions

View File

@@ -302,6 +302,10 @@ HCURSOR wxBitmapToHCURSOR(const wxBitmap& bmp, int hotSpotX, int hotSpotY);
extern int wxGetSystemMetrics(int nIndex, const wxWindow* win); extern int wxGetSystemMetrics(int nIndex, const wxWindow* win);
extern bool wxSystemParametersInfo(UINT uiAction, UINT uiParam,
PVOID pvParam, UINT fWinIni,
const wxWindow* win);
#if wxUSE_OWNER_DRAWN #if wxUSE_OWNER_DRAWN
// Draw the bitmap in specified state (this is used by owner drawn controls) // Draw the bitmap in specified state (this is used by owner drawn controls)

View File

@@ -4761,6 +4761,41 @@ int wxGetSystemMetrics(int nIndex, const wxWindow* win)
return ::GetSystemMetrics(nIndex); return ::GetSystemMetrics(nIndex);
} }
/*extern*/
bool wxSystemParametersInfo(UINT uiAction, UINT uiParam, PVOID pvParam, UINT fWinIni, const wxWindow* win)
{
#if wxUSE_DYNLIB_CLASS
const wxTopLevelWindow* tlw = wxGetWinTLW(win);
if ( tlw )
{
typedef int (WINAPI * SystemParametersInfoForDpi_t)(UINT uiAction, UINT uiParam, PVOID pvParam, UINT fWinIni, UINT dpi);
static SystemParametersInfoForDpi_t s_pfnSystemParametersInfoForDpi = NULL;
static bool s_initDone = false;
if ( !s_initDone )
{
wxLoadedDLL dllUser32("user32.dll");
wxDL_INIT_FUNC(s_pfn, SystemParametersInfoForDpi, dllUser32);
s_initDone = true;
}
if ( s_pfnSystemParametersInfoForDpi )
{
const int y = ::GetDeviceCaps(::GetDC(tlw->GetHWND()), LOGPIXELSY);
if ( s_pfnSystemParametersInfoForDpi(uiAction, uiParam, pvParam, fWinIni, y) == TRUE )
{
return true;
}
}
}
#else
wxUnusedVar(win);
#endif // wxUSE_DYNLIB_CLASS
return ::SystemParametersInfo(uiAction, uiParam, pvParam, fWinIni) == TRUE;
}
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
// colours and palettes // colours and palettes
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------