[user32_winetest]
[reactos.git] / rostests / winetests / user32 / win.c
index bbbac2a..af04851 100644 (file)
@@ -52,6 +52,7 @@ static BOOL (WINAPI *pSetLayeredWindowAttributes)(HWND,COLORREF,BYTE,DWORD);
 static BOOL (WINAPI *pGetMonitorInfoA)(HMONITOR,LPMONITORINFO);
 static HMONITOR (WINAPI *pMonitorFromPoint)(POINT,DWORD);
 static int  (WINAPI *pGetWindowRgnBox)(HWND,LPRECT);
+static BOOL (WINAPI *pGetGUIThreadInfo)(DWORD, GUITHREADINFO*);
 
 static BOOL test_lbuttondown_flag;
 static HWND hwndMessage;
@@ -62,6 +63,8 @@ static const char* szAWRClass = "Winsize";
 static HMENU hmenu;
 static DWORD our_pid;
 
+static BOOL is_win9x = FALSE;
+
 #define COUNTOF(arr) (sizeof(arr)/sizeof(arr[0]))
 
 static void dump_minmax_info( const MINMAXINFO *minmax )
@@ -444,6 +447,17 @@ static void test_parent_owner(void)
     ret = SetParent( test, child );
     ok( ret == desktop, "SetParent return value %p expected %p\n", ret, desktop );
     check_parents( test, child, child, 0, 0, hwndMain, test );
+
+    if (!is_win9x)
+    {
+        ShowWindow( test, SW_SHOW );
+        ret = SetParent( test, test );
+        ok( ret == NULL, "SetParent return value %p expected %p\n", ret, NULL );
+        ok( GetWindowLongA( test, GWL_STYLE ) & WS_VISIBLE, "window is not visible after SetParent\n" );
+        check_parents( test, child, child, 0, 0, hwndMain, test );
+    }
+    else
+        win_skip( "Test crashes on Win9x/WinMe\n" );
     DestroyWindow( test );
 
     /* owned popup */
@@ -639,7 +653,6 @@ static LRESULT WINAPI main_window_procA(HWND hwnd, UINT msg, WPARAM wparam, LPAR
        }
        case WM_WINDOWPOSCHANGING:
        {
-           BOOL is_win9x = GetWindowLongPtrW(hwnd, GWLP_WNDPROC) == 0;
            WINDOWPOS *winpos = (WINDOWPOS *)lparam;
            trace("main: WM_WINDOWPOSCHANGING %p after %p, x %d, y %d, cx %d, cy %d flags %08x\n",
                   winpos->hwnd, winpos->hwndInsertAfter,
@@ -848,7 +861,6 @@ static void test_nonclient_area(HWND hwnd)
     DWORD style, exstyle;
     RECT rc_window, rc_client, rc;
     BOOL menu;
-    BOOL is_win9x = GetWindowLongPtrW(hwnd, GWLP_WNDPROC) == 0;
     LRESULT ret;
 
     style = GetWindowLongA(hwnd, GWL_STYLE);
@@ -1028,13 +1040,12 @@ static void test_shell_window(void)
     DWORD error;
     HMODULE hinst, hUser32;
     BOOL (WINAPI*SetShellWindow)(HWND);
-    BOOL (WINAPI*SetShellWindowEx)(HWND, HWND);
     HWND hwnd1, hwnd2, hwnd3, hwnd4, hwnd5;
     HWND shellWindow, nextWnd;
 
-    if (!GetWindowLongW(GetDesktopWindow(), GWL_STYLE))
+    if (is_win9x)
     {
-        trace("Skipping shell window test on Win9x\n");
+        win_skip("Skipping shell window test on Win9x\n");
         return;
     }
 
@@ -1043,7 +1054,6 @@ static void test_shell_window(void)
     hUser32 = GetModuleHandleA("user32");
 
     SetShellWindow = (void *)GetProcAddress(hUser32, "SetShellWindow");
-    SetShellWindowEx = (void *)GetProcAddress(hUser32, "SetShellWindowEx");
 
     trace("previous shell window: %p\n", shellWindow);
 
@@ -1899,7 +1909,6 @@ static void test_SetWindowPos(HWND hwnd)
 {
     RECT orig_win_rc, rect;
     LONG_PTR old_proc;
-    BOOL is_win9x = GetWindowLongPtrW(hwnd, GWLP_WNDPROC) == 0;
 
     SetRect(&rect, 111, 222, 333, 444);
     ok(!GetWindowRect(0, &rect), "GetWindowRect succeeded\n");
@@ -1962,7 +1971,6 @@ static void test_SetMenu(HWND parent)
 {
     HWND child;
     HMENU hMenu, ret;
-    BOOL is_win9x = GetWindowLongPtrW(parent, GWLP_WNDPROC) == 0;
     BOOL retok;
     DWORD style;
 
@@ -2149,7 +2157,7 @@ static void check_z_order_debug(HWND hwnd, HWND next, HWND prev, HWND owner,
         /*trace("skipping next %p (%p)\n", test, UlongToHandle(GetWindowLongPtr(test, GWLP_HINSTANCE)));*/
         test = GetWindow(test, GW_HWNDNEXT);
     }
-    ok_(file, line)(next == test, "expected next %p, got %p\n", next, test);
+    ok_(file, line)(next == test, "%p: expected next %p, got %p\n", hwnd, next, test);
 
     test = GetWindow(hwnd, GW_HWNDPREV);
     /* skip foreign windows */
@@ -2161,16 +2169,17 @@ static void check_z_order_debug(HWND hwnd, HWND next, HWND prev, HWND owner,
         /*trace("skipping prev %p (%p)\n", test, UlongToHandle(GetWindowLongPtr(test, GWLP_HINSTANCE)));*/
         test = GetWindow(test, GW_HWNDPREV);
     }
-    ok_(file, line)(prev == test, "expected prev %p, got %p\n", prev, test);
+    ok_(file, line)(prev == test, "%p: expected prev %p, got %p\n", hwnd, prev, test);
 
     test = GetWindow(hwnd, GW_OWNER);
-    ok_(file, line)(owner == test, "expected owner %p, got %p\n", owner, test);
+    ok_(file, line)(owner == test, "%p: expected owner %p, got %p\n", hwnd, owner, test);
 
     ex_style = GetWindowLong(hwnd, GWL_EXSTYLE);
-    ok_(file, line)(!(ex_style & WS_EX_TOPMOST) == !topmost, "expected %stopmost\n", topmost ? "" : "NOT ");
+    ok_(file, line)(!(ex_style & WS_EX_TOPMOST) == !topmost, "%p: expected %stopmost\n",
+                    hwnd, topmost ? "" : "NOT ");
 }
 
-static void test_popup_zorder(HWND hwnd_D, HWND hwnd_E)
+static void test_popup_zorder(HWND hwnd_D, HWND hwnd_E, DWORD style)
 {
     HWND hwnd_A, hwnd_B, hwnd_C, hwnd_F;
 
@@ -2194,7 +2203,7 @@ static void test_popup_zorder(HWND hwnd_D, HWND hwnd_E)
     check_z_order(hwnd_D, hwnd_E, 0, 0, FALSE);
 
     hwnd_C = CreateWindowEx(0, "MainWindowClass", NULL,
-                            WS_POPUP,
+                            style,
                             100, 100, 100, 100,
                             hwnd_F, 0, GetModuleHandle(0), NULL);
     trace("hwnd_C %p\n", hwnd_C);
@@ -2204,7 +2213,7 @@ static void test_popup_zorder(HWND hwnd_D, HWND hwnd_E)
     check_z_order(hwnd_C, hwnd_D, 0, hwnd_F, FALSE);
 
     hwnd_B = CreateWindowEx(WS_EX_TOPMOST, "MainWindowClass", NULL,
-                            WS_POPUP,
+                            style,
                             100, 100, 100, 100,
                             hwnd_F, 0, GetModuleHandle(0), NULL);
     trace("hwnd_B %p\n", hwnd_B);
@@ -2215,7 +2224,7 @@ static void test_popup_zorder(HWND hwnd_D, HWND hwnd_E)
     check_z_order(hwnd_B, hwnd_C, 0, hwnd_F, TRUE);
 
     hwnd_A = CreateWindowEx(WS_EX_TOPMOST, "MainWindowClass", NULL,
-                            WS_POPUP,
+                            style,
                             100, 100, 100, 100,
                             0, 0, GetModuleHandle(0), NULL);
     trace("hwnd_A %p\n", hwnd_A);
@@ -2248,6 +2257,20 @@ static void test_popup_zorder(HWND hwnd_D, HWND hwnd_E)
     check_z_order(hwnd_A, hwnd_D, 0, 0, TRUE);
 #endif
 
+    /* make hwnd_C owned by a topmost window */
+    DestroyWindow( hwnd_C );
+    hwnd_C = CreateWindowEx(0, "MainWindowClass", NULL,
+                            style,
+                            100, 100, 100, 100,
+                            hwnd_A, 0, GetModuleHandle(0), NULL);
+    trace("hwnd_C %p\n", hwnd_C);
+    check_z_order(hwnd_E, 0, hwnd_D, 0, FALSE);
+    check_z_order(hwnd_D, hwnd_E, hwnd_F, 0, FALSE);
+    check_z_order(hwnd_F, hwnd_D, hwnd_B, 0, FALSE);
+    check_z_order(hwnd_B, hwnd_F, hwnd_A, hwnd_F, TRUE);
+    check_z_order(hwnd_A, hwnd_B, hwnd_C, 0, TRUE);
+    check_z_order(hwnd_C, hwnd_A, 0, hwnd_A, TRUE);
+
     DestroyWindow(hwnd_A);
     DestroyWindow(hwnd_B);
     DestroyWindow(hwnd_C);
@@ -2265,7 +2288,7 @@ static void test_vis_rgn( HWND hwnd )
     ok( GetRandomRgn( hdc, hrgn, SYSRGN ) != 0, "GetRandomRgn failed\n" );
     GetWindowRect( hwnd, &win_rect );
     GetRgnBox( hrgn, &rgn_rect );
-    if (GetVersion() & 0x80000000)
+    if (is_win9x)
     {
         trace("win9x, mapping to screen coords\n");
         MapWindowPoints( hwnd, 0, (POINT *)&rgn_rect, 2 );
@@ -2451,10 +2474,39 @@ static void test_SetActiveWindow(HWND hwnd)
     check_wnd_state(hwnd, hwnd, hwnd, 0);
 }
 
+struct create_window_thread_params
+{
+    HWND window;
+    HANDLE window_created;
+    HANDLE test_finished;
+};
+
+static DWORD WINAPI create_window_thread(void *param)
+{
+    struct create_window_thread_params *p = param;
+    DWORD res;
+    BOOL ret;
+
+    p->window = CreateWindowA("static", NULL, WS_POPUP | WS_VISIBLE, 0, 0, 0, 0, 0, 0, 0, 0);
+
+    ret = SetEvent(p->window_created);
+    ok(ret, "SetEvent failed, last error %#x.\n", GetLastError());
+
+    res = WaitForSingleObject(p->test_finished, INFINITE);
+    ok(res == WAIT_OBJECT_0, "Wait failed (%#x), last error %#x.\n", res, GetLastError());
+
+    DestroyWindow(p->window);
+    return 0;
+}
+
 static void test_SetForegroundWindow(HWND hwnd)
 {
+    struct create_window_thread_params thread_params;
+    HANDLE thread;
+    DWORD res, tid;
     BOOL ret;
     HWND hwnd2;
+    MSG msg;
 
     flush_events( TRUE );
     ShowWindow(hwnd, SW_HIDE);
@@ -2527,6 +2579,34 @@ static void test_SetForegroundWindow(HWND hwnd)
 
     DestroyWindow(hwnd2);
     check_wnd_state(hwnd, hwnd, hwnd, 0);
+
+    hwnd2 = CreateWindowA("static", NULL, WS_POPUP | WS_VISIBLE, 0, 0, 0, 0, 0, 0, 0, 0);
+    check_wnd_state(hwnd2, hwnd2, hwnd2, 0);
+
+    thread_params.window_created = CreateEvent(NULL, FALSE, FALSE, NULL);
+    ok(!!thread_params.window_created, "CreateEvent failed, last error %#x.\n", GetLastError());
+    thread_params.test_finished = CreateEvent(NULL, FALSE, FALSE, NULL);
+    ok(!!thread_params.test_finished, "CreateEvent failed, last error %#x.\n", GetLastError());
+    thread = CreateThread(NULL, 0, create_window_thread, &thread_params, 0, &tid);
+    ok(!!thread, "Failed to create thread, last error %#x.\n", GetLastError());
+    res = WaitForSingleObject(thread_params.window_created, INFINITE);
+    ok(res == WAIT_OBJECT_0, "Wait failed (%#x), last error %#x.\n", res, GetLastError());
+    check_wnd_state(hwnd2, thread_params.window, hwnd2, 0);
+
+    SetForegroundWindow(hwnd2);
+    check_wnd_state(hwnd2, hwnd2, hwnd2, 0);
+
+    while (PeekMessage(&msg, 0, 0, 0, PM_REMOVE)) DispatchMessage(&msg);
+    if (0) check_wnd_state(hwnd2, hwnd2, hwnd2, 0);
+    todo_wine ok(GetActiveWindow() == hwnd2, "Expected active window %p, got %p.\n", hwnd2, GetActiveWindow());
+    todo_wine ok(GetFocus() == hwnd2, "Expected focus window %p, got %p.\n", hwnd2, GetFocus());
+
+    SetEvent(thread_params.test_finished);
+    WaitForSingleObject(thread, INFINITE);
+    CloseHandle(thread_params.test_finished);
+    CloseHandle(thread_params.window_created);
+    CloseHandle(thread);
+    DestroyWindow(hwnd2);
 }
 
 static WNDPROC old_button_proc;
@@ -2697,6 +2777,122 @@ static void test_capture_3(HWND hwnd1, HWND hwnd2)
     ok (ret, "releasecapture did not return TRUE after second try.\n");
 }
 
+static LRESULT CALLBACK test_capture_4_proc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
+{
+    GUITHREADINFO gti;
+    HWND cap_wnd, cap_wnd2, set_cap_wnd;
+    BOOL status;
+    switch (msg)
+    {
+        case WM_CAPTURECHANGED:
+
+            /* now try to release capture from menu. this should fail */
+            if (pGetGUIThreadInfo)
+            {
+                memset(&gti, 0, sizeof(GUITHREADINFO));
+                gti.cbSize = sizeof(GUITHREADINFO);
+                status = pGetGUIThreadInfo(GetCurrentThreadId(), &gti);
+                ok(status, "GetGUIThreadInfo() failed!\n");
+                ok(gti.flags & GUI_INMENUMODE, "Thread info incorrect (flags=%08X)!\n", gti.flags);
+            }
+            cap_wnd = GetCapture();
+
+            /* check that re-setting the capture for the menu fails */
+            set_cap_wnd = SetCapture(cap_wnd);
+            ok(!set_cap_wnd || broken(set_cap_wnd == cap_wnd), /* nt4 */
+               "SetCapture should have failed!\n");
+            if (set_cap_wnd)
+            {
+                DestroyWindow(hWnd);
+                break;
+            }
+
+            /* check that SetCapture fails for another window and that it does not touch the error code */
+            set_cap_wnd = SetCapture(hWnd);
+            ok(!set_cap_wnd, "SetCapture should have failed!\n");
+
+            /* check that ReleaseCapture fails and does not touch the error code */
+            status = ReleaseCapture();
+            ok(!status, "ReleaseCapture should have failed!\n");
+
+            /* check that thread info did not change */
+            if (pGetGUIThreadInfo)
+            {
+                memset(&gti, 0, sizeof(GUITHREADINFO));
+                gti.cbSize = sizeof(GUITHREADINFO);
+                status = pGetGUIThreadInfo(GetCurrentThreadId(), &gti);
+                ok(status, "GetGUIThreadInfo() failed!\n");
+                ok(gti.flags & GUI_INMENUMODE, "Thread info incorrect (flags=%08X)!\n", gti.flags);
+            }
+
+            /* verify that no capture change took place */
+            cap_wnd2 = GetCapture();
+            ok(cap_wnd2 == cap_wnd, "Capture changed!\n");
+
+            /* we are done. kill the window */
+            DestroyWindow(hWnd);
+            break;
+
+        default:
+            return( DefWindowProcA( hWnd, msg, wParam, lParam ) );
+    }
+    return 0;
+}
+
+/* Test that no-one can mess around with the current capture while a menu is open */
+static void test_capture_4(void)
+{
+    BOOL ret;
+    HMENU hmenu;
+    HWND hwnd;
+    WNDCLASSA wclass;
+    HINSTANCE hInstance = GetModuleHandleA( NULL );
+
+    if (!pGetGUIThreadInfo)
+    {
+        win_skip("GetGUIThreadInfo is not available\n");
+        return;
+    }
+    wclass.lpszClassName = "TestCapture4Class";
+    wclass.style         = CS_HREDRAW | CS_VREDRAW;
+    wclass.lpfnWndProc   = test_capture_4_proc;
+    wclass.hInstance     = hInstance;
+    wclass.hIcon         = LoadIconA( 0, IDI_APPLICATION );
+    wclass.hCursor       = LoadCursorA( NULL, IDC_ARROW );
+    wclass.hbrBackground = (HBRUSH)( COLOR_WINDOW + 1 );
+    wclass.lpszMenuName  = 0;
+    wclass.cbClsExtra    = 0;
+    wclass.cbWndExtra    = 0;
+    assert (RegisterClassA( &wclass ));
+    assert (hwnd = CreateWindowA( wclass.lpszClassName, "MenuTest",
+                                  WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, 0,
+                                  400, 200, NULL, NULL, hInstance, NULL) );
+    ok(hwnd != NULL, "CreateWindowEx failed with error %d\n", GetLastError());
+    if (!hwnd) return;
+    hmenu = CreatePopupMenu();
+
+    ret = AppendMenuA( hmenu, MF_STRING, 1, "winetest2");
+    ok( ret, "AppendMenuA has failed!\n");
+
+    /* set main window to have initial capture */
+    SetCapture(hwnd);
+
+    if (is_win9x)
+    {
+        win_skip("TrackPopupMenu test crashes on Win9x/WinMe\n");
+    }
+    else
+    {
+        /* create popup (it will self-destruct) */
+        ret = TrackPopupMenu(hmenu, TPM_RETURNCMD, 100, 100, 0, hwnd, NULL);
+        ok( ret == 0, "TrackPopupMenu returned %d expected zero\n", ret);
+    }
+
+    /* clean up */
+    DestroyMenu(hmenu);
+    DestroyWindow(hwnd);
+}
+
 /* PeekMessage wrapper that ignores the messages we don't care about */
 static BOOL peek_message( MSG *msg )
 {
@@ -2812,7 +3008,7 @@ static void test_mouse_input(HWND hwnd)
     BOOL ret;
     LRESULT res;
 
-    ShowWindow(hwnd, SW_SHOW);
+    ShowWindow(hwnd, SW_SHOWNORMAL);
     UpdateWindow(hwnd);
     SetWindowPos( hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOSIZE|SWP_NOMOVE );
 
@@ -2871,6 +3067,7 @@ static void test_mouse_input(HWND hwnd)
         if (msg.message == WM_TIMER || ignore_message(msg.message)) continue;
         ok(msg.hwnd == popup && msg.message == WM_MOUSEMOVE,
            "hwnd %p message %04x\n", msg.hwnd, msg.message);
+        DispatchMessage(&msg);
     }
     ret = peek_message(&msg);
     ok( !ret, "message %04x available\n", msg.message);
@@ -3016,10 +3213,12 @@ static void test_validatergn(HWND hwnd)
     GetWindowRect( child, &rc);
     MapWindowPoints( NULL, hwnd, (POINT*) &rc, 2);
     ret = GetUpdateRect( child, &rc2, 0);
+    ok( ret == 1, "Expected GetUpdateRect to return non-zero, got %d\n", ret);
     ok( rc2.right > rc2.left && rc2.bottom > rc2.top,
             "Update rectangle is empty!\n");
     ValidateRect( hwnd, &rc);
     ret = GetUpdateRect( child, &rc2, 0);
+    ok( !ret, "Expected GetUpdateRect to return zero, got %d\n", ret);
     ok( rc2.left == 0 && rc2.top == 0 && rc2.right == 0 && rc2.bottom == 0,
             "Update rectangle %d,%d-%d,%d is not empty!\n", rc2.left, rc2.top,
             rc2.right, rc2.bottom);
@@ -3031,6 +3230,7 @@ static void test_validatergn(HWND hwnd)
     rgn = CreateRectRgnIndirect( &rc);
     ValidateRgn( hwnd, rgn);
     ret = GetUpdateRect( child, &rc2, 0);
+    ok( !ret, "Expected GetUpdateRect to return zero, got %d\n", ret);
     ok( rc2.left == 0 && rc2.top == 0 && rc2.right == 0 && rc2.bottom == 0,
             "Update rectangle %d,%d-%d,%d is not empty!\n", rc2.left, rc2.top,
             rc2.right, rc2.bottom);
@@ -3096,7 +3296,6 @@ static void test_SetParent(void)
     BOOL ret;
     HWND desktop = GetDesktopWindow();
     HMENU hMenu;
-    BOOL is_win9x = GetWindowLongPtrW(desktop, GWLP_WNDPROC) == 0;
     HWND parent, child1, child2, child3, child4, sibling;
 
     parent = CreateWindowExA(0, "static", NULL, WS_OVERLAPPEDWINDOW,
@@ -3142,20 +3341,44 @@ static void test_SetParent(void)
 
     if (!is_win9x) /* Win9x doesn't survive this test */
     {
+        HWND ret;
+
         ok(!SetParent(parent, child1), "SetParent should fail\n");
         ok(!SetParent(child2, child3), "SetParent should fail\n");
         ok(SetParent(child1, parent) != 0, "SetParent should not fail\n");
-        ok(SetParent(parent, child2) != 0, "SetParent should not fail\n");
-        ok(SetParent(parent, child3) != 0, "SetParent should not fail\n");
-        ok(!SetParent(child2, parent), "SetParent should fail\n");
-        ok(SetParent(parent, child4) != 0, "SetParent should not fail\n");
-
-        check_parents(parent, child4, child4, 0, 0, child4, parent);
-        check_parents(child1, parent, parent, parent, 0, child4, parent);
-        check_parents(child2, desktop, parent, parent, parent, child2, parent);
-        check_parents(child3, child2, child2, child2, 0, child2, parent);
-        check_parents(child4, desktop, child2, child2, child2, child4, parent);
+        ret = SetParent(parent, child2);
+        todo_wine ok( !ret || broken( ret != 0 ), "SetParent should fail\n");
+        if (ret)  /* nt4, win2k */
+        {
+            ret = SetParent(parent, child3);
+            ok(ret != 0, "SetParent should not fail\n");
+            ret = SetParent(child2, parent);
+            ok(!ret, "SetParent should fail\n");
+            ret = SetParent(parent, child4);
+            ok(ret != 0, "SetParent should not fail\n");
+            check_parents(parent, child4, child4, 0, 0, child4, parent);
+            check_parents(child1, parent, parent, parent, 0, child4, parent);
+            check_parents(child2, desktop, parent, parent, parent, child2, parent);
+            check_parents(child3, child2, child2, child2, 0, child2, parent);
+            check_parents(child4, desktop, child2, child2, child2, child4, parent);
+        }
+        else
+        {
+            ret = SetParent(parent, child3);
+            ok(ret != 0, "SetParent should not fail\n");
+            ret = SetParent(child2, parent);
+            ok(!ret, "SetParent should fail\n");
+            ret = SetParent(parent, child4);
+            ok(!ret, "SetParent should fail\n");
+            check_parents(parent, child3, child3, 0, 0, child2, parent);
+            check_parents(child1, parent, parent, parent, 0, child2, parent);
+            check_parents(child2, desktop, parent, parent, parent, child2, parent);
+            check_parents(child3, child2, child2, child2, 0, child2, parent);
+            check_parents(child4, desktop, child2, child2, child2, child4, parent);
+        }
     }
+    else
+        skip("Win9x/WinMe crash\n");
 
     hMenu = CreateMenu();
     sibling = CreateWindowExA(0, "static", NULL, WS_OVERLAPPEDWINDOW,
@@ -3279,6 +3502,14 @@ static void test_window_styles(void)
     check_window_style(WS_CHILD, WS_EX_DLGMODALFRAME|WS_EX_STATICEDGE, WS_CHILD, WS_EX_STATICEDGE|WS_EX_WINDOWEDGE|WS_EX_DLGMODALFRAME);
     check_window_style(WS_CAPTION, WS_EX_STATICEDGE, WS_CLIPSIBLINGS|WS_CAPTION, WS_EX_STATICEDGE|WS_EX_WINDOWEDGE);
     check_window_style(0, WS_EX_APPWINDOW, WS_CLIPSIBLINGS|WS_CAPTION, WS_EX_APPWINDOW|WS_EX_WINDOWEDGE);
+
+    if (pGetLayeredWindowAttributes)
+    {
+        check_window_style(0, WS_EX_LAYERED, WS_CLIPSIBLINGS|WS_CAPTION, WS_EX_LAYERED|WS_EX_WINDOWEDGE);
+        check_window_style(0, WS_EX_LAYERED|WS_EX_TRANSPARENT, WS_CLIPSIBLINGS|WS_CAPTION, WS_EX_LAYERED|WS_EX_TRANSPARENT|WS_EX_WINDOWEDGE);
+        check_window_style(0, WS_EX_LAYERED|WS_EX_TRANSPARENT|WS_EX_TOOLWINDOW, WS_CLIPSIBLINGS|WS_CAPTION,
+                                                      WS_EX_LAYERED|WS_EX_TRANSPARENT|WS_EX_TOOLWINDOW|WS_EX_WINDOWEDGE);
+    }
 }
 
 static void test_scrollwindow( HWND hwnd)
@@ -4959,14 +5190,14 @@ static LRESULT CALLBACK TestExposedRegion_WndProc(HWND hwnd, UINT msg, WPARAM wP
 
 static void test_Expose(void)
 {
-    ATOM atom;
     WNDCLASSA cls;
     HWND mw;
+
     memset(&cls, 0, sizeof(WNDCLASSA));
     cls.lpfnWndProc = TestExposedRegion_WndProc;
     cls.hbrBackground = GetStockObject(WHITE_BRUSH);
     cls.lpszClassName = "TestExposeClass";
-    atom = RegisterClassA(&cls);
+    RegisterClassA(&cls);
 
     mw = CreateWindowA("TestExposeClass", "MainWindow", WS_VISIBLE|WS_OVERLAPPEDWINDOW,
                             0, 0, 200, 100, NULL, NULL, 0, NULL);
@@ -5008,6 +5239,7 @@ static void run_NCRedrawLoop(UINT flags)
                          NULL, NULL, 0, &flags);
     ShowWindow(hwnd, SW_SHOW);
     UpdateWindow(hwnd);
+    flush_events( FALSE );
     while(PeekMessage(&msg, hwnd, 0, 0, PM_REMOVE) != 0)
     {
         if (msg.message == WM_PAINT) loopcount++;
@@ -5790,9 +6022,14 @@ START_TEST(win)
     pGetMonitorInfoA = (void *)GetProcAddress( user32,  "GetMonitorInfoA" );
     pMonitorFromPoint = (void *)GetProcAddress( user32,  "MonitorFromPoint" );
     pGetWindowRgnBox = (void *)GetProcAddress( user32, "GetWindowRgnBox" );
+    pGetGUIThreadInfo = (void *)GetProcAddress( user32, "GetGUIThreadInfo" );
 
     if (!RegisterWindowClasses()) assert(0);
 
+    SetLastError(0xdeafbeef);
+    GetWindowLongPtrW(GetDesktopWindow(), GWLP_WNDPROC);
+    is_win9x = (GetLastError() == ERROR_CALL_NOT_IMPLEMENTED);
+
     hhook = SetWindowsHookExA(WH_CBT, cbt_hook_proc, 0, GetCurrentThreadId());
     if (!hhook) win_skip( "Cannot set CBT hook, skipping some tests\n" );
 
@@ -5822,6 +6059,9 @@ START_TEST(win)
     test_capture_2();
     test_capture_3(hwndMain, hwndMain2);
 
+    skip("skipping test_capture_4, that hangs on reactos\n");
+    //test_capture_4();
+
     test_CreateWindow();
     test_parent_owner();
     test_SetParent();
@@ -5836,7 +6076,8 @@ START_TEST(win)
     test_NCRedraw();
 
     test_children_zorder(hwndMain);
-    test_popup_zorder(hwndMain2, hwndMain);
+    test_popup_zorder(hwndMain2, hwndMain, WS_POPUP);
+    test_popup_zorder(hwndMain2, hwndMain, 0);
     test_keyboard_input(hwndMain);
     test_mouse_input(hwndMain);
     test_validatergn(hwndMain);
@@ -5860,7 +6101,7 @@ START_TEST(win)
     test_layered_window();
 
     test_SetForegroundWindow(hwndMain);
-//    test_shell_window();
+    test_shell_window();
     test_handles( hwndMain );
     test_winregion();