Windows: Handle WM_WINDOWPOSCHANGING during window creation.

Fix warnings:

QWindowsContext::windowsProc: No Qt Window found for event 0x46 (WM_WINDOWPOSCHANGING), hwnd=0x0xde0408.

occurring when using Active X controls.

Factor out message handling to a static function which can be used
during window creation when QWindowsWindow does not yet exist.

Task-number: QTBUG-36318
Change-Id: I3ce56fd377e3392b0dd22d3d26a7048065380f13
Reviewed-by: Oliver Wolff <oliver.wolff@theqtcompany.com>
bb10
Friedemann Kleint 2014-12-02 14:19:02 +01:00
parent 247607a1af
commit 50d29a695a
3 changed files with 15 additions and 6 deletions

View File

@ -952,6 +952,9 @@ bool QWindowsContext::windowsProc(HWND hwnd, UINT message,
return true;
case QtWindows::CalculateSize:
return QWindowsGeometryHint::handleCalculateSize(d->m_creationContext->customMargins, msg, result);
case QtWindows::GeometryChangingEvent:
return QWindowsWindow::handleGeometryChangingMessage(&msg, d->m_creationContext->window,
d->m_creationContext->margins + d->m_creationContext->customMargins);
default:
break;
}

View File

@ -801,7 +801,7 @@ QWindowCreationContext::QWindowCreationContext(const QWindow *w,
const QRect &geometry,
const QMargins &cm,
DWORD style_, DWORD exStyle_) :
geometryHint(w, cm), style(style_), exStyle(exStyle_),
geometryHint(w, cm), window(w), style(style_), exStyle(exStyle_),
requestedGeometry(geometry), obtainedGeometry(geometry),
margins(QWindowsGeometryHint::frame(style, exStyle)), customMargins(cm),
frameX(CW_USEDEFAULT), frameY(CW_USEDEFAULT),
@ -1783,16 +1783,14 @@ void QWindowsWindow::propagateSizeHints()
qCDebug(lcQpaWindows) << __FUNCTION__ << this << window();
}
bool QWindowsWindow::handleGeometryChanging(MSG *message) const
bool QWindowsWindow::handleGeometryChangingMessage(MSG *message, const QWindow *qWindow, const QMargins &marginsDp)
{
#ifndef Q_OS_WINCE
QWindow *qWin = window();
if (!qWin->isTopLevel())
if (!qWindow->isTopLevel()) // Implement hasHeightForWidth().
return false;
WINDOWPOS *windowPos = reinterpret_cast<WINDOWPOS *>(message->lParam);
if ((windowPos->flags & (SWP_NOCOPYBITS | SWP_NOSIZE)))
return false;
const QMargins marginsDp = frameMarginsDp();
const QRect suggestedFrameGeometryDp(windowPos->x, windowPos->y,
windowPos->cx, windowPos->cy);
const qreal factor = QWindowsScaling::factor();
@ -1800,7 +1798,7 @@ bool QWindowsWindow::handleGeometryChanging(MSG *message) const
const QRectF suggestedGeometry = QRectF(QPointF(suggestedGeometryDp.topLeft()) / factor,
QSizeF(suggestedGeometryDp.size()) / factor);
const QRectF correctedGeometryF =
qt_window_private(qWin)->closestAcceptableGeometry(suggestedGeometry);
qt_window_private(const_cast<QWindow *>(qWindow))->closestAcceptableGeometry(suggestedGeometry);
if (!correctedGeometryF.isValid())
return false;
const QRect correctedFrameGeometryDp
@ -1820,6 +1818,12 @@ bool QWindowsWindow::handleGeometryChanging(MSG *message) const
#endif
}
bool QWindowsWindow::handleGeometryChanging(MSG *message) const
{
const QMargins marginsDp = window()->isTopLevel() ? frameMarginsDp() : QMargins();
return QWindowsWindow::handleGeometryChangingMessage(message, window(), marginsDp);
}
QMargins QWindowsWindow::frameMarginsDp() const
{
// Frames are invalidated by style changes (window state, flags).

View File

@ -84,6 +84,7 @@ struct QWindowCreationContext
#endif
QWindowsGeometryHint geometryHint;
const QWindow *window;
DWORD style;
DWORD exStyle;
QRect requestedGeometry;
@ -183,6 +184,7 @@ public:
void windowEvent(QEvent *event);
void propagateSizeHints() Q_DECL_OVERRIDE;
static bool handleGeometryChangingMessage(MSG *message, const QWindow *qWindow, const QMargins &marginsDp);
bool handleGeometryChanging(MSG *message) const;
QMargins frameMarginsDp() const;
QMargins frameMargins() const Q_DECL_OVERRIDE { return frameMarginsDp() / QWindowsScaling::factor(); }