From b87a599f0797ab186db260d25500e6f1fd76d3fa Mon Sep 17 00:00:00 2001 From: Maarten Bent Date: Sun, 14 Jul 2019 17:15:03 +0200 Subject: [PATCH] Remove static reference to NONCLIENTMETRICS These metrics can change when the DPI of a Window changes, so we can not keep a static reference. According to documentation, the second parameter (uiParam) should be set to the size of the NONCLIENTMETRICS object. --- include/wx/msw/private/metrics.h | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/include/wx/msw/private/metrics.h b/include/wx/msw/private/metrics.h index 10c3b41c35..4516bd1485 100644 --- a/include/wx/msw/private/metrics.h +++ b/include/wx/msw/private/metrics.h @@ -22,10 +22,14 @@ namespace wxMSWImpl // in the future // // MT-safety: this function is only meant to be called from the main thread -inline const NONCLIENTMETRICS& GetNonClientMetrics(const wxWindow* win) +inline const NONCLIENTMETRICS GetNonClientMetrics(const wxWindow* win) { - static WinStruct nm; - if ( !wxSystemParametersInfo(SPI_GETNONCLIENTMETRICS, 0, &nm, 0 , win) ) + WinStruct nm; + if ( !wxSystemParametersInfo(SPI_GETNONCLIENTMETRICS, + sizeof(NONCLIENTMETRICS), + &nm, + 0, + win) ) { #if WINVER >= 0x0600 // a new field has been added to NONCLIENTMETRICS under Vista, so @@ -33,7 +37,11 @@ inline const NONCLIENTMETRICS& GetNonClientMetrics(const wxWindow* win) // size incorporating this new value on an older system -- retry // without it nm.cbSize -= sizeof(int); - if ( !wxSystemParametersInfo(SPI_GETNONCLIENTMETRICS, 0, &nm, 0, win) ) + if ( !wxSystemParametersInfo(SPI_GETNONCLIENTMETRICS, + sizeof(NONCLIENTMETRICS), + &nm, + 0, + win) ) #endif // WINVER >= 0x0600 { // maybe we should initialize the struct with some defaults?