ShowWindow(SW_SHOWNA) fix w. test
Rein Klazes
wijn at wanadoo.nl
Mon Dec 20 12:01:26 CST 2004
Hi,
MSDN says SW_SHOWNA is like SW_SHOW except that is does not activate the
window. That is not completely true, for instance a WM_SHOWWINDOW
message is sent, even if the window is already visible.
Changelog:
dlls/x11drv : winpos.c
user/tests : msg.c
Make ShowWindow(...,SW_SHOWNA) also work on already visible
windows with some conformance tests.
Rein.
-------------- next part --------------
--- wine/dlls/x11drv/winpos.c 2004-12-09 19:08:03.000000000 +0100
+++ mywine/dlls/x11drv/winpos.c 2004-12-17 22:18:41.000000000 +0100
@@ -1100,8 +1100,9 @@ BOOL X11DRV_ShowWindow( HWND hwnd, INT c
break;
case SW_SHOWNA:
- swp |= SWP_NOACTIVATE | SWP_NOZORDER;
- /* fall through */
+ swp |= SWP_NOACTIVATE | SWP_SHOWWINDOW | SWP_NOSIZE | SWP_NOMOVE;
+ if( wndPtr->dwStyle & WS_CHILD) swp |= SWP_NOZORDER;
+ break;
case SW_SHOW:
if (wasVisible) goto END;
@@ -1125,7 +1126,7 @@ BOOL X11DRV_ShowWindow( HWND hwnd, INT c
}
showFlag = (cmd != SW_HIDE);
- if (showFlag != wasVisible)
+ if (showFlag != wasVisible || cmd == SW_SHOWNA)
{
SendMessageW( hwnd, WM_SHOWWINDOW, showFlag, 0 );
if (!IsWindow( hwnd )) goto END;
--- wine/dlls/user/tests/msg.c 2004-12-20 18:19:20.000000000 +0100
+++ mywine/dlls/user/tests/msg.c 2004-12-20 18:45:17.000000000 +0100
@@ -4084,6 +4084,109 @@ static void test_timers(void)
ok(DestroyWindow(info.hWnd), "failed to destroy window\n");
}
+/* test if we receive the right sequence of messages */
+/* after calling ShowWindow( SW_SHOWNA) */
+static const struct message WmSHOWNAChildInvisParInvis[] = {
+ { WM_SHOWWINDOW, sent|wparam, 1 },
+ { 0 }
+};
+static const struct message WmSHOWNAChildVisParInvis[] = {
+ { WM_SHOWWINDOW, sent|wparam, 1 },
+ { 0 }
+};
+static const struct message WmSHOWNAChildVisParVis[] = {
+ { WM_SHOWWINDOW, sent|wparam, 1 },
+ { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE|
+ SWP_NOZORDER },
+ { 0 }
+};
+static const struct message WmSHOWNAChildInvisParVis[] = {
+ { WM_SHOWWINDOW, sent|wparam, 1 },
+ { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE
+ |SWP_NOZORDER},
+ { WM_ERASEBKGND, sent|optional },
+ { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|
+ SWP_NOACTIVATE|SWP_NOZORDER|SWP_NOCLIENTMOVE },
+ { 0 }
+};
+static const struct message WmSHOWNATopVisible[] = {
+ { WM_SHOWWINDOW, sent|wparam, 1 },
+ { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOACTIVATE },
+ { 0 }
+};
+static const struct message WmSHOWNATopInvisible[] = {
+ { WM_SHOWWINDOW, sent|wparam, 1 },
+ { WM_WINDOWPOSCHANGING, sent|wparam, SWP_SHOWWINDOW|SWP_NOACTIVATE|SWP_NOSIZE|SWP_NOMOVE },
+ { WM_NCPAINT, sent|wparam, 1 },
+ { WM_GETTEXT, sent|defwinproc|optional },
+ { WM_ERASEBKGND, sent|optional },
+ { WM_WINDOWPOSCHANGED, sent|wparam, SWP_SHOWWINDOW|SWP_NOSIZE|SWP_NOMOVE|SWP_NOCLIENTSIZE|
+ SWP_NOACTIVATE|SWP_NOZORDER|SWP_NOCLIENTMOVE },
+ { WM_SIZE, sent },
+ { WM_MOVE, sent },
+ { 0 }
+};
+
+static void test_showwindow_showna(void)
+{
+ HWND hwnd, hchild;
+
+ hwnd = CreateWindowExA(0, "TestWindowClass", "Test overlapped", WS_OVERLAPPEDWINDOW,
+ 100, 100, 200, 200, 0, 0, 0, NULL);
+ ok (hwnd != 0, "Failed to create overlapped window\n");
+ hchild = CreateWindowExA(0, "TestWindowClass", "Test child", WS_CHILD,
+ 0, 0, 10, 10, hwnd, 0, 0, NULL);
+ ok (hchild != 0, "Failed to create child\n");
+ flush_sequence();
+
+ /* ShowWindow( SW_SHOWNA) for invisible top level window */
+ trace("calling ShowWindow( SW_SHOWNA) for invisible top level window\n");
+ ok( ShowWindow(hwnd, SW_SHOWNA) == FALSE, "ShowWindow: window was visible\n" );
+ ok_sequence(WmSHOWNATopInvisible, "ShowWindow(SW_SHOWNA) on invisible top level window.\n", TRUE);
+ trace("done\n");
+
+ /* ShowWindow( SW_SHOWNA) for now visible top level window */
+ trace("calling ShowWindow( SW_SHOWNA) for now visible top level window\n");
+ ok( ShowWindow(hwnd, SW_SHOWNA) != FALSE, "ShowWindow: window was invisible\n" );
+ ok_sequence(WmSHOWNATopVisible, "ShowWindow(SW_SHOWNA) on visible top level window.\n", FALSE);
+ trace("done\n");
+ /* back to invisible */
+ ShowWindow(hchild, SW_HIDE);
+ ShowWindow(hwnd, SW_HIDE);
+ flush_sequence();
+ /* ShowWindow(SW_SHOWNA) with child and parent invisible */
+ trace("calling ShowWindow( SW_SHOWNA) for invisible child with invisible parent\n");
+ ok( ShowWindow(hchild, SW_SHOWNA) == FALSE, "ShowWindow: window was visible\n" );
+ ok_sequence(WmSHOWNAChildInvisParInvis, "ShowWindow(SW_SHOWNA) invisible child and parent\n", TRUE);
+ trace("done\n");
+ /* ShowWindow(SW_SHOWNA) with child visible and parent invisible */
+ ok( ShowWindow(hchild, SW_SHOW) != FALSE, "ShowWindow: window was invisible\n" );
+ flush_sequence();
+ trace("calling ShowWindow( SW_SHOWNA) for the visible child and invisible parent\n");
+ ok( ShowWindow(hchild, SW_SHOWNA) != FALSE, "ShowWindow: window was invisible\n" );
+ ok_sequence(WmSHOWNAChildVisParInvis, "ShowWindow(SW_SHOWNA) visible child and invisible parent\n", TRUE);
+ trace("done\n");
+ /* ShowWindow(SW_SHOWNA) with child visible and parent visible */
+ ShowWindow( hwnd, SW_SHOW);
+ flush_sequence();
+ trace("calling ShowWindow( SW_SHOWNA) for the visible child and parent\n");
+ ok( ShowWindow(hchild, SW_SHOWNA) != FALSE, "ShowWindow: window was invisible\n" );
+ ok_sequence(WmSHOWNAChildVisParVis, "ShowWindow(SW_SHOWNA) for the visible child and parent\n", FALSE);
+ trace("done\n");
+
+ /* ShowWindow(SW_SHOWNA) with child invisible and parent visible */
+ ShowWindow( hchild, SW_HIDE);
+ flush_sequence();
+ trace("calling ShowWindow( SW_SHOWNA) for the invisible child and visible parent\n");
+ ok( ShowWindow(hchild, SW_SHOWNA) == FALSE, "ShowWindow: window was visible\n" );
+ ok_sequence(WmSHOWNAChildInvisParVis, "ShowWindow(SW_SHOWNA) for the invisible child and visible parent\n", FALSE);
+ trace("done\n");
+
+ DestroyWindow(hchild);
+ DestroyWindow(hwnd);
+ flush_sequence();
+}
+
START_TEST(msg)
{
if (!RegisterWindowClasses()) assert(0);
@@ -4091,6 +4194,7 @@ START_TEST(msg)
hCBT_hook = SetWindowsHookExA(WH_CBT, cbt_hook_proc, 0, GetCurrentThreadId());
assert(hCBT_hook);
+ test_showwindow_showna();
test_messages();
test_mdi_messages();
test_button_messages();
More information about the wine-patches
mailing list