Use DPI Aware wxSystemParametersInfo

Require a wxWindow when requesting GetNonClientMetrics.
If no wxWindow is known, use wxTheApp->GetTopWindow().
This commit is contained in:
Maarten Bent
2018-07-22 14:21:36 +02:00
parent c0c6a4b826
commit 0a79c48631
4 changed files with 15 additions and 8 deletions

View File

@@ -10,6 +10,8 @@
#ifndef _WX_MSW_PRIVATE_METRICS_H_
#define _WX_MSW_PRIVATE_METRICS_H_
#include "wx/msw/private.h"
namespace wxMSWImpl
{
@@ -20,10 +22,10 @@ namespace wxMSWImpl
// in the future
//
// MT-safety: this function is only meant to be called from the main thread
inline const NONCLIENTMETRICS& GetNonClientMetrics()
inline const NONCLIENTMETRICS& GetNonClientMetrics(const wxWindow* win)
{
static WinStruct<NONCLIENTMETRICS> nm;
if ( !::SystemParametersInfo(SPI_GETNONCLIENTMETRICS, 0, &nm, 0) )
if ( !wxSystemParametersInfo(SPI_GETNONCLIENTMETRICS, 0, &nm, 0 , win) )
{
#if WINVER >= 0x0600
// a new field has been added to NONCLIENTMETRICS under Vista, so
@@ -31,7 +33,7 @@ inline const NONCLIENTMETRICS& GetNonClientMetrics()
// size incorporating this new value on an older system -- retry
// without it
nm.cbSize -= sizeof(int);
if ( !::SystemParametersInfo(SPI_GETNONCLIENTMETRICS, 0, &nm, 0) )
if ( !wxSystemParametersInfo(SPI_GETNONCLIENTMETRICS, 0, &nm, 0, win) )
#endif // WINVER >= 0x0600
{
// maybe we should initialize the struct with some defaults?