From 57f27af169ee36a98720ef884519be53cc90e656 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sat, 26 Jan 2008 01:38:06 +0000 Subject: [PATCH] fix assert when using owner-drawn menu items with the newest (Vista) SDK [backport from trunk] git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_8_BRANCH@51379 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- docs/changes.txt | 1 + src/msw/ownerdrw.cpp | 16 +++++++++++++++- 2 files changed, 16 insertions(+), 1 deletion(-) 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;