diff --git a/docs/changes.txt b/docs/changes.txt index 90d6f6149a..5ceb7e8374 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -127,6 +127,7 @@ wxMSW: - Fix setting icons when they have non-default (16*16 and 32*32) sizes. - Fixed wxLocale::GetInfo to use the C locale. - Don't enable disabled windows when showing them (Harry McKame). +- Fix assert when using owner-drawn menu items with the newest (Vista) SDK wxGTK: diff --git a/src/msw/ownerdrw.cpp b/src/msw/ownerdrw.cpp index d772273b13..36967d809e 100644 --- a/src/msw/ownerdrw.cpp +++ b/src/msw/ownerdrw.cpp @@ -50,7 +50,21 @@ public: #if defined(__WXMSW__) && defined(__WIN32__) && defined(SM_CXMENUCHECK) NONCLIENTMETRICS nm; nm.cbSize = sizeof(NONCLIENTMETRICS); - SystemParametersInfo(SPI_GETNONCLIENTMETRICS,0,&nm,0); + if ( !::SystemParametersInfo(SPI_GETNONCLIENTMETRICS,0,&nm,0) ) + { +#if WINVER >= 0x0600 + // a new field has been added to NONCLIENTMETRICS under Vista, so + // the call to SystemParametersInfo() fails if we use the struct + // size incorporating this new value on an older system -- retry + // without it + nm.cbSize -= sizeof(int); + if ( !::SystemParametersInfo(SPI_GETNONCLIENTMETRICS, 0, &nm, 0) ) +#endif // WINVER >= 0x0600 + { + // maybe we should initialize the struct with some defaults? + wxLogLastError(_T("SystemParametersInfo(SPI_GETNONCLIENTMETRICS)")); + } + } ms_systemMenuButtonWidth = nm.iMenuHeight; ms_systemMenuHeight = nm.iMenuHeight;