diff --git a/src/plugins/platforms/windows/qwindowswindow.cpp b/src/plugins/platforms/windows/qwindowswindow.cpp
index 73c78f00903f54fe45a42ac455c0449345b295e2..8ce6dcc9e770f45eca928257cf0dd4fd798ac33d 100644
--- a/src/plugins/platforms/windows/qwindowswindow.cpp
+++ b/src/plugins/platforms/windows/qwindowswindow.cpp
@@ -503,10 +503,14 @@ QWindowsWindow::WindowData
     const QWindowCreationContextPtr context(new QWindowCreationContext(w, rect, data.customMargins, style, exStyle));
     QWindowsContext::instance()->setWindowCreationContext(context);
 
-    if (context->frameX < 0)
-        context->frameX = 0;
-    if (context->frameY < 0)
-        context->frameY = 0;
+    QRect screenGeometry;
+    if (QScreen *screen = w->screen())
+        screenGeometry = screen->availableVirtualGeometry();
+
+    if (context->frameX < screenGeometry.left())
+        context->frameX = screenGeometry.left();
+    if (context->frameY < screenGeometry.top())
+        context->frameY = screenGeometry.top();
 
     if (QWindowsContext::verboseWindows)
         qDebug().nospace()