Ignore attempts to hide an already invisible window. Add a test case
for this behaviour, passes on Wine and Windows 2000.

diff --git a/dlls/user/tests/msg.c b/dlls/user/tests/msg.c
index 63114b6..33c2319 100644
--- a/dlls/user/tests/msg.c
+++ b/dlls/user/tests/msg.c
@@ -145,6 +145,10 @@
     { WM_IME_SETCONTEXT, sent|wparam|optional, 0 },
     { 0 }
 };
+/* ShowWindow(SW_HIDE) for an invisible overlapped window */
+static const struct message WmHideInvisibleOverlappedSeq[] = {
+    { 0 }
+};
 /* DestroyWindow for a visible overlapped window */
 static const struct message WmDestroyOverlappedSeq[] = {
     { HCBT_DESTROYWND, hook },
@@ -756,6 +760,10 @@
     ok (hwnd != 0, "Failed to create overlapped window\n");
     ok_sequence(WmCreateOverlappedSeq, "CreateWindow:overlapped");
 
+    /* test ShowWindow(SW_HIDE) on a newly created invisible window */
+    ok( ShowWindow(hwnd, SW_HIDE) == FALSE, "ShowWindow: window was visible\n" );
+    ok_sequence(WmHideInvisibleOverlappedSeq, "ShowWindow(SW_HIDE):overlapped, invisible");
+
     /* test WM_SETREDRAW on a not visible top level window */
     test_WM_SETREDRAW(hwnd);
 
diff --git a/dlls/x11drv/winpos.c b/dlls/x11drv/winpos.c
index 3665880..bd205d1 100644
--- a/dlls/x11drv/winpos.c
+++ b/dlls/x11drv/winpos.c
@@ -1283,6 +1283,7 @@
     switch(cmd)
     {
         case SW_HIDE:
+            if (!wasVisible) goto END;
 	    swp |= SWP_HIDEWINDOW | SWP_NOSIZE | SWP_NOMOVE |
 		        SWP_NOACTIVATE | SWP_NOZORDER;
 	    break;