diff --git a/src/plugins/platforms/windows/qwindowswindow.cpp b/src/plugins/platforms/windows/qwindowswindow.cpp index be6410f7522..7ec05bd5499 100644 --- a/src/plugins/platforms/windows/qwindowswindow.cpp +++ b/src/plugins/platforms/windows/qwindowswindow.cpp @@ -931,6 +931,8 @@ QMargins QWindowsGeometryHint::frameOnPrimaryScreen(const QWindow *w, DWORD styl QMargins QWindowsGeometryHint::frameOnPrimaryScreen(const QWindow *w, HWND hwnd) { + if (!w->isTopLevel() || w->flags().testFlag(Qt::FramelessWindowHint)) + return {}; return frameOnPrimaryScreen(w, DWORD(GetWindowLongPtr(hwnd, GWL_STYLE)), DWORD(GetWindowLongPtr(hwnd, GWL_EXSTYLE))); } @@ -970,6 +972,14 @@ QMargins QWindowsGeometryHint::frame(const QWindow *w, HWND hwnd, DWORD style, D return frame(w, style, exStyle, dpi); } +QMargins QWindowsGeometryHint::frame(const QWindow *w, HWND hwnd) +{ + if (!w->isTopLevel() || w->flags().testFlag(Qt::FramelessWindowHint)) + return {}; + return frame(w, hwnd, DWORD(GetWindowLongPtrW(hwnd, GWL_STYLE)), + DWORD(GetWindowLongPtrW(hwnd, GWL_EXSTYLE))); +} + // For newly created windows. QMargins QWindowsGeometryHint::frame(const QWindow *w, const QRect &geometry, DWORD style, DWORD exStyle) diff --git a/src/plugins/platforms/windows/qwindowswindow.h b/src/plugins/platforms/windows/qwindowswindow.h index 915254dbd80..d18e617c7a1 100644 --- a/src/plugins/platforms/windows/qwindowswindow.h +++ b/src/plugins/platforms/windows/qwindowswindow.h @@ -66,6 +66,7 @@ struct QWindowsGeometryHint static QMargins frameOnPrimaryScreen(const QWindow *w, HWND hwnd); static QMargins frame(const QWindow *w, DWORD style, DWORD exStyle, qreal dpi); static QMargins frame(const QWindow *w, HWND hwnd, DWORD style, DWORD exStyle); + static QMargins frame(const QWindow *w, HWND hwnd); static QMargins frame(const QWindow *w, const QRect &geometry, DWORD style, DWORD exStyle); static bool handleCalculateSize(const QMargins &customMargins, const MSG &msg, LRESULT *result);