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.
This commit is contained in:
@@ -22,10 +22,14 @@ namespace wxMSWImpl
|
|||||||
// in the future
|
// in the future
|
||||||
//
|
//
|
||||||
// MT-safety: this function is only meant to be called from the main thread
|
// 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<NONCLIENTMETRICS> nm;
|
WinStruct<NONCLIENTMETRICS> nm;
|
||||||
if ( !wxSystemParametersInfo(SPI_GETNONCLIENTMETRICS, 0, &nm, 0 , win) )
|
if ( !wxSystemParametersInfo(SPI_GETNONCLIENTMETRICS,
|
||||||
|
sizeof(NONCLIENTMETRICS),
|
||||||
|
&nm,
|
||||||
|
0,
|
||||||
|
win) )
|
||||||
{
|
{
|
||||||
#if WINVER >= 0x0600
|
#if WINVER >= 0x0600
|
||||||
// a new field has been added to NONCLIENTMETRICS under Vista, so
|
// 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
|
// size incorporating this new value on an older system -- retry
|
||||||
// without it
|
// without it
|
||||||
nm.cbSize -= sizeof(int);
|
nm.cbSize -= sizeof(int);
|
||||||
if ( !wxSystemParametersInfo(SPI_GETNONCLIENTMETRICS, 0, &nm, 0, win) )
|
if ( !wxSystemParametersInfo(SPI_GETNONCLIENTMETRICS,
|
||||||
|
sizeof(NONCLIENTMETRICS),
|
||||||
|
&nm,
|
||||||
|
0,
|
||||||
|
win) )
|
||||||
#endif // WINVER >= 0x0600
|
#endif // WINVER >= 0x0600
|
||||||
{
|
{
|
||||||
// maybe we should initialize the struct with some defaults?
|
// maybe we should initialize the struct with some defaults?
|
||||||
|
Reference in New Issue
Block a user