diff --git a/include/wx/msw/private/metrics.h b/include/wx/msw/private/metrics.h index 0e1b41deb5..10c3b41c35 100644 --- a/include/wx/msw/private/metrics.h +++ b/include/wx/msw/private/metrics.h @@ -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 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? diff --git a/src/msw/menuitem.cpp b/src/msw/menuitem.cpp index 0aba58f50f..83733eb4aa 100644 --- a/src/msw/menuitem.cpp +++ b/src/msw/menuitem.cpp @@ -363,7 +363,7 @@ void MenuDrawData::Init() else #endif // wxUSE_UXTHEME { - const NONCLIENTMETRICS& metrics = wxMSWImpl::GetNonClientMetrics(); + const NONCLIENTMETRICS& metrics = wxMSWImpl::GetNonClientMetrics(window); CheckMargin.cxLeftWidth = CheckMargin.cxRightWidth = wxGetSystemMetrics(SM_CXEDGE, window); diff --git a/src/msw/msgdlg.cpp b/src/msw/msgdlg.cpp index be241ba6d5..8e2a101a55 100644 --- a/src/msw/msgdlg.cpp +++ b/src/msw/msgdlg.cpp @@ -396,7 +396,8 @@ void wxMessageDialog::AdjustButtonLabels() /* static */ wxFont wxMessageDialog::GetMessageFont() { - const NONCLIENTMETRICS& ncm = wxMSWImpl::GetNonClientMetrics(); + const wxWindow* win = wxTheApp ? wxTheApp->GetTopWindow() : NULL; + const NONCLIENTMETRICS& ncm = wxMSWImpl::GetNonClientMetrics(win); return wxNativeFontInfo(ncm.lfMessageFont); } diff --git a/src/msw/settings.cpp b/src/msw/settings.cpp index 15ff0b0924..9cdc03be3c 100644 --- a/src/msw/settings.cpp +++ b/src/msw/settings.cpp @@ -26,6 +26,7 @@ #include "wx/settings.h" #ifndef WX_PRECOMP + #include "wx/app.h" #include "wx/utils.h" #include "wx/gdicmn.h" #include "wx/module.h" @@ -181,8 +182,9 @@ wxFont wxSystemSettingsNative::GetFont(wxSystemFont index) // for most (simple) controls, e.g. buttons and such but other // controls may prefer to use lfStatusFont or lfCaptionFont if it // is more appropriate for them + const wxWindow* win = wxTheApp ? wxTheApp->GetTopWindow() : NULL; const wxNativeFontInfo - info(wxMSWImpl::GetNonClientMetrics().lfMessageFont); + info(wxMSWImpl::GetNonClientMetrics(win).lfMessageFont); gs_fontDefault = new wxFont(info); } @@ -337,12 +339,14 @@ extern wxFont wxGetCCDefaultFont() // font which is also used for the icon titles and not the stock default // GUI font LOGFONT lf; - if ( ::SystemParametersInfo + const wxWindow* win = wxTheApp ? wxTheApp->GetTopWindow() : NULL; + if ( wxSystemParametersInfo ( SPI_GETICONTITLELOGFONT, sizeof(lf), &lf, - 0 + 0, + win ) ) { return wxFont(lf);