diff --git a/src/plugins/platforms/windows/qwindowswindow.cpp b/src/plugins/platforms/windows/qwindowswindow.cpp
index cac8ec5..0b65e47 100644
--- a/src/plugins/platforms/windows/qwindowswindow.cpp
+++ b/src/plugins/platforms/windows/qwindowswindow.cpp
@@ -55,6 +55,16 @@
 
 #include <QtCore/QDebug>
 
+static BOOL setWindowPos(HWND hWnd, HWND hWndInsertAfter, int X,
+                            int Y, int cx,  int cy, UINT uFlags)
+{
+    BOOL r = SetWindowPos(hWnd, hWndInsertAfter, X, Y, cx,  cy, uFlags);
+    qDebug() << __FUNCTION__ << hWnd << "hWndInsertAfter="
+             << hWndInsertAfter <<  X << Y << cx <<  cy << "uFlags=" <<uFlags
+             << "returns" << r;
+    return r;
+}
+
 QT_BEGIN_NAMESPACE
 
 enum {
@@ -699,13 +709,13 @@ void WindowCreationData::initialize(const QWindow *w, HWND hwnd, bool frameChang
     if (topLevel) {
         swpFlags |= SWP_NOACTIVATE;
         if ((flags & Qt::WindowStaysOnTopHint) || (type == Qt::ToolTip)) {
-            SetWindowPos(hwnd, HWND_TOPMOST, 0, 0, 0, 0, swpFlags);
+            setWindowPos(hwnd, HWND_TOPMOST, 0, 0, 0, 0, swpFlags);
             if (flags & Qt::WindowStaysOnBottomHint)
                 qWarning() << "QWidget: Incompatible window flags: the window can't be on top and on bottom at the same time";
         } else if (flags & Qt::WindowStaysOnBottomHint) {
-            SetWindowPos(hwnd, HWND_BOTTOM, 0, 0, 0, 0, swpFlags);
+            setWindowPos(hwnd, HWND_BOTTOM, 0, 0, 0, 0, swpFlags);
         } else if (frameChange) { // Force WM_NCCALCSIZE with wParam=1 in case of custom margins.
-            SetWindowPos(hwnd, HWND_NOTOPMOST, 0, 0, 0, 0, swpFlags);
+            setWindowPos(hwnd, HWND_NOTOPMOST, 0, 0, 0, 0, swpFlags);
         }
         if (flags & (Qt::CustomizeWindowHint|Qt::WindowTitleHint)) {
             HMENU systemMenu = GetSystemMenu(hwnd, FALSE);
@@ -716,7 +726,7 @@ void WindowCreationData::initialize(const QWindow *w, HWND hwnd, bool frameChang
         }
         updateGLWindowSettings(w, hwnd, flags, opacityLevel);
     } else { // child.
-        SetWindowPos(hwnd, HWND_TOP, 0, 0, 0, 0, swpFlags);
+        setWindowPos(hwnd, HWND_TOP, 0, 0, 0, 0, swpFlags);
     }
 }
 
@@ -1271,7 +1281,7 @@ void QWindowsWindow::show_sys() const
 
     if (fakedMaximize) {
         setStyle(style() & ~WS_MAXIMIZEBOX);
-        SetWindowPos(m_data.hwnd, 0, 0, 0, 0, 0,
+        setWindowPos(m_data.hwnd, 0, 0, 0, 0, 0,
                      SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE | SWP_NOZORDER | SWP_NOOWNERZORDER
                      | SWP_FRAMECHANGED);
     }
@@ -1285,7 +1295,7 @@ void QWindowsWindow::hide_sys() const
         if (flags & Qt::Popup)
             ShowWindow(m_data.hwnd, SW_HIDE);
         else
-            SetWindowPos(m_data.hwnd,0, 0,0,0,0, SWP_HIDEWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOACTIVATE);
+            setWindowPos(m_data.hwnd,0, 0,0,0,0, SWP_HIDEWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_NOACTIVATE);
     }
 }
 
@@ -1747,7 +1757,7 @@ void QWindowsWindow::setWindowState_sys(Qt::WindowState newState)
             const UINT swpf = SWP_FRAMECHANGED | SWP_NOACTIVATE;
             const bool wasSync = testFlag(SynchronousGeometryChangeEvent);
             setFlag(SynchronousGeometryChangeEvent);
-            SetWindowPos(m_data.hwnd, HWND_TOP, r.left(), r.top(), r.width(), r.height(), swpf);
+            setWindowPos(m_data.hwnd, HWND_TOP, r.left(), r.top(), r.width(), r.height(), swpf);
             if (!wasSync)
                 clearFlag(SynchronousGeometryChangeEvent);
             QWindowSystemInterface::handleGeometryChange(window(), r);
@@ -1764,7 +1774,7 @@ void QWindowsWindow::setWindowState_sys(Qt::WindowState newState)
                 swpf |= SWP_NOSIZE | SWP_NOMOVE;
             const bool wasSync = testFlag(SynchronousGeometryChangeEvent);
             setFlag(SynchronousGeometryChangeEvent);
-            SetWindowPos(m_data.hwnd, 0, m_savedFrameGeometry.x(), m_savedFrameGeometry.y(),
+            setWindowPos(m_data.hwnd, 0, m_savedFrameGeometry.x(), m_savedFrameGeometry.y(),
                          m_savedFrameGeometry.width(), m_savedFrameGeometry.height(), swpf);
             if (!wasSync)
                 clearFlag(SynchronousGeometryChangeEvent);
@@ -1816,14 +1826,14 @@ void QWindowsWindow::setExStyle(unsigned s) const
 void QWindowsWindow::raise()
 {
     qCDebug(lcQpaWindows) << __FUNCTION__ << this << window();
-    SetWindowPos(m_data.hwnd, HWND_TOP, 0, 0, 0, 0, SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE);
+    setWindowPos(m_data.hwnd, HWND_TOP, 0, 0, 0, 0, SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE);
 }
 
 void QWindowsWindow::lower()
 {
     qCDebug(lcQpaWindows) << __FUNCTION__ << this << window();
     if (m_data.hwnd)
-        SetWindowPos(m_data.hwnd, HWND_BOTTOM, 0, 0, 0, 0, SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE);
+        setWindowPos(m_data.hwnd, HWND_BOTTOM, 0, 0, 0, 0, SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE);
 }
 
 void QWindowsWindow::windowEvent(QEvent *event)
@@ -2298,7 +2308,7 @@ void QWindowsWindow::setCustomMargins(const QMargins &newCustomMargins)
         setFlag(FrameDirty);
         qCDebug(lcQpaWindows) << __FUNCTION__ << oldCustomMargins << "->" << newCustomMargins
             << currentFrameGeometry << "->" << newFrame;
-        SetWindowPos(m_data.hwnd, 0, newFrame.x(), newFrame.y(), newFrame.width(), newFrame.height(), SWP_NOZORDER | SWP_FRAMECHANGED);
+        setWindowPos(m_data.hwnd, 0, newFrame.x(), newFrame.y(), newFrame.width(), newFrame.height(), SWP_NOZORDER | SWP_FRAMECHANGED);
     }
 }
 
