diff options
author | Friedemann Kleint <Friedemann.Kleint@digia.com> | 2013-03-05 16:31:35 +0100 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2013-03-06 21:50:28 +0100 |
commit | 872a84c2e66d151074caa602b0cab25358043621 (patch) | |
tree | 93d07400a27171c1e14cf8c3e5aaf5235ee098c1 /src/widgets/dialogs/qwizard_win.cpp | |
parent | 3c329b09fab98087efa6f23905257cba5f665bcd (diff) |
Aero-Style-QWizard: Do not use parent window handle.
If no window exists at the time QWizard::setWizardStyle() is
set, further delay initialization of the Aero style until show().
If the wizard is a child window, just adapt the geometry.
Task-number: QTBUG-29904
Change-Id: I3805331ae726a0aa2020815d5bff571ca407efbc
Reviewed-by: Joerg Bornemann <joerg.bornemann@digia.com>
Reviewed-by: Oliver Wolff <oliver.wolff@digia.com>
Diffstat (limited to 'src/widgets/dialogs/qwizard_win.cpp')
-rw-r--r-- | src/widgets/dialogs/qwizard_win.cpp | 33 |
1 files changed, 22 insertions, 11 deletions
diff --git a/src/widgets/dialogs/qwizard_win.cpp b/src/widgets/dialogs/qwizard_win.cpp index 42bdb8369f..2586ced60f 100644 --- a/src/widgets/dialogs/qwizard_win.cpp +++ b/src/widgets/dialogs/qwizard_win.cpp @@ -50,6 +50,7 @@ #include "qpaintengine.h" #include "qapplication.h" #include <QtCore/QVariant> +#include <QtCore/QDebug> #include <QtGui/QMouseEvent> #include <QtGui/QWindow> #include <QtWidgets/QDesktopWidget> @@ -345,9 +346,9 @@ bool QVistaHelper::setDWMTitleBar(TitleBarChangeType type) mar.cyTopHeight = 0; else mar.cyTopHeight = titleBarSize() + topOffset(); - HWND wizardHandle = QApplicationPrivate::getHWNDForWidget(wizard); - HRESULT hr = pDwmExtendFrameIntoClientArea(wizardHandle, &mar); - value = SUCCEEDED(hr); + if (const HWND wizardHandle = wizardHWND()) + if (SUCCEEDED(pDwmExtendFrameIntoClientArea(wizardHandle, &mar))) + value = true; } return value; } @@ -405,8 +406,8 @@ void QVistaHelper::setTitleBarIconAndCaptionVisible(bool visible) opt.dwMask = 0; else opt.dwMask = WIZ_WTNCA_NODRAWICON | WIZ_WTNCA_NODRAWCAPTION; - HWND handle = QApplicationPrivate::getHWNDForWidget(wizard); - pSetWindowThemeAttribute(handle, WIZ_WTA_NONCLIENT, &opt, sizeof(WIZ_WTA_OPTIONS)); + if (const HWND handle = wizardHWND()) + pSetWindowThemeAttribute(handle, WIZ_WTA_NONCLIENT, &opt, sizeof(WIZ_WTA_OPTIONS)); } } @@ -585,8 +586,7 @@ bool QVistaHelper::eventFilter(QObject *obj, QEvent *event) msg.message = WM_NCHITTEST; msg.wParam = 0; msg.lParam = MAKELPARAM(mouseEvent->globalX(), mouseEvent->globalY()); - HWND handle = QApplicationPrivate::getHWNDForWidget(wizard); - msg.hwnd = handle; + msg.hwnd = wizardHWND(); winEvent(&msg, &result); msg.wParam = result; msg.message = WM_NCMOUSEMOVE; @@ -600,8 +600,7 @@ bool QVistaHelper::eventFilter(QObject *obj, QEvent *event) msg.message = WM_NCHITTEST; msg.wParam = 0; msg.lParam = MAKELPARAM(mouseEvent->globalX(), mouseEvent->globalY()); - HWND handle = QApplicationPrivate::getHWNDForWidget(wizard); - msg.hwnd = handle; + msg.hwnd = wizardHWND(); winEvent(&msg, &result); msg.wParam = result; msg.message = WM_NCLBUTTONDOWN; @@ -616,8 +615,7 @@ bool QVistaHelper::eventFilter(QObject *obj, QEvent *event) msg.message = WM_NCHITTEST; msg.wParam = 0; msg.lParam = MAKELPARAM(mouseEvent->globalX(), mouseEvent->globalY()); - HWND handle = QApplicationPrivate::getHWNDForWidget(wizard); - msg.hwnd = handle; + msg.hwnd = wizardHWND(); winEvent(&msg, &result); msg.wParam = result; msg.message = WM_NCLBUTTONUP; @@ -644,6 +642,19 @@ HFONT QVistaHelper::getCaptionFont(HANDLE hTheme) return CreateFontIndirect(&lf); } +HWND QVistaHelper::wizardHWND() const +{ + // Obtain the HWND if the wizard is a top-level window. + // Do not use winId() as this enforces native children of the parent + // widget when called before show() as happens when calling setWizardStyle(). + if (QWindow *window = wizard->windowHandle()) + if (window->handle()) + if (void *vHwnd = QGuiApplication::platformNativeInterface()->nativeResourceForWindow(QByteArrayLiteral("handle"), window)) + return static_cast<HWND>(vHwnd); + qWarning().nospace() << "Failed to obtain HWND for wizard."; + return 0; +} + bool QVistaHelper::drawTitleText(QPainter *painter, const QString &text, const QRect &rect, HDC hdc) { bool value = false; |