From 852308114ff901b86cca99268f498fc1d56b622e Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Thu, 16 Jan 2014 17:22:40 +0100 Subject: QWizard: Fix frame when using Vista style/MSVC2012 Work around GetSystemMetrics() returning the wrong value using MSVC2012 and later. The special handling of Windows 8 and later is then no longer required. [ChangeLog][QtWidgets][QWizard] Fixed frame when using Vista style/MSVC2012. Task-number: QTBUG-36192 Change-Id: I39c2ab70a266f12cd65fa740b10b86edffa60417 Reviewed-by: Joerg Bornemann --- src/widgets/dialogs/qwizard_win.cpp | 34 ++++++++++++++++++++++++++++------ 1 file changed, 28 insertions(+), 6 deletions(-) (limited to 'src/widgets/dialogs/qwizard_win.cpp') diff --git a/src/widgets/dialogs/qwizard_win.cpp b/src/widgets/dialogs/qwizard_win.cpp index 4ecf071ea93..747115984d1 100644 --- a/src/widgets/dialogs/qwizard_win.cpp +++ b/src/widgets/dialogs/qwizard_win.cpp @@ -280,8 +280,6 @@ QVistaHelper::~QVistaHelper() void QVistaHelper::updateCustomMargins(bool vistaMargins) { - if (QSysInfo::WindowsVersion >= QSysInfo::WV_WINDOWS8) - return; // Negative margins are not supported on Windows 8. if (QWindow *window = wizard->windowHandle()) { // Reduce top frame to zero since we paint it ourselves. const QMargins customMargins = vistaMargins ? @@ -770,6 +768,33 @@ bool QVistaHelper::drawBlackRect(const QRect &rect, HDC hdc) return value; } +#if !defined(_MSC_VER) || _MSC_VER < 1700 +static inline int getWindowBottomMargin() +{ + return GetSystemMetrics(SM_CYSIZEFRAME); +} +#else // !_MSC_VER || _MSC_VER < 1700 +// QTBUG-36192, GetSystemMetrics(SM_CYSIZEFRAME) returns bogus values +// for MSVC2012 which leads to the custom margin having no effect since +// that only works when removing the entire margin. +static inline int getWindowBottomMargin() +{ + RECT rect = {0, 0, 0, 0}; + AdjustWindowRectEx(&rect, WS_POPUP | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_THICKFRAME | WS_DLGFRAME, FALSE, 0); + return qAbs(rect.bottom); +} +#endif // _MSC_VER >= 1700 + +int QVistaHelper::frameSize() +{ + return getWindowBottomMargin(); +} + +int QVistaHelper::captionSize() +{ + return GetSystemMetrics(SM_CYCAPTION); +} + bool QVistaHelper::resolveSymbols() { static bool tried = false; @@ -828,10 +853,7 @@ int QVistaHelper::topOffset() static const int aeroOffset = QSysInfo::WindowsVersion == QSysInfo::WV_WINDOWS7 ? QStyleHelper::dpiScaled(4) : QStyleHelper::dpiScaled(13); - int result = aeroOffset; - if (QSysInfo::WindowsVersion < QSysInfo::WV_WINDOWS8) - result += titleBarSize(); - return result; + return aeroOffset + titleBarSize(); } QT_END_NAMESPACE -- cgit v1.2.3