EnableWindow

Ulrich Czekalla ulrich.czekalla at utoronto.ca
Fri May 28 20:24:43 CDT 2004


Here is an updated patch with the test included in win.c.

/Ulrich

On Fri, May 28, 2004 at 05:00:42PM -0700, Alexandre Julliard wrote:
> Ulrich Czekalla <ulrich.czekalla at utoronto.ca> writes:
> 
> > ChangeLog:
> > 	Ulrich Czekalla <ulrich at codeweavers.com>
> > 	EnableWindow should not remove the focus of child windows
> 
> Thanks for providing a test, but could you please merge it with the
> existing win.c and/or msg.c tests?  We can't create a new file for
> every API being tested.
> 
> -- 
> Alexandre Julliard
> julliard at winehq.org
-------------- next part --------------
Index: dlls/user/tests/win.c
===================================================================
RCS file: /home/wine/wine/dlls/user/tests/win.c,v
retrieving revision 1.26
diff -u -r1.26 win.c
--- dlls/user/tests/win.c	24 May 2004 19:08:41 -0000	1.26
+++ dlls/user/tests/win.c	29 May 2004 01:21:30 -0000
@@ -49,6 +49,8 @@
 static HWND hwndMain, hwndMain2;
 static HHOOK hhook;
 
+static UINT enableWindowMsgIndex;
+
 /* check the values returned by the various parent/owner functions on a given window */
 static void check_parents( HWND hwnd, HWND ga_parent, HWND gwl_parent, HWND get_parent,
                            HWND gw_owner, HWND ga_root, HWND ga_root_owner )
@@ -1644,6 +1646,83 @@
     ok( GetActiveWindow() != hwnd2, "Window %p is still active\n", hwnd2 );
 }
 
+static LRESULT WINAPI enable_window_procA(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
+{
+    switch (msg)
+    {
+        case WM_CANCELMODE:
+            ok (enableWindowMsgIndex++ == 1, "WM_CANCELMODE received out of sequence\n");
+            break;
+
+        case WM_ENABLE:
+            ok (enableWindowMsgIndex++ == 2, "WM_ENABLE received out of sequence\n");
+            break;
+
+        default:
+            break;
+    }
+
+    return DefWindowProcA(hwnd, msg, wparam, lparam);
+}
+
+static LRESULT WINAPI enable_window_child_procA(HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
+{
+    switch (msg)
+    {
+        case WM_SETFOCUS:
+            ok (enableWindowMsgIndex++ == 0, "WM_SETFOCUS received out of sequence\n");
+            break;
+
+        case WM_KILLFOCUS:
+            ok (FALSE, "WM_KILLFOCUS received out of sequence\n");
+            break;
+
+        default:
+            break;
+    }
+
+    return DefWindowProcA(hwnd, msg, wparam, lparam);
+}
+
+static void test_EnableWindow()
+{
+    HWND hWndMain;
+    HWND hWndChild;
+    WNDCLASSA cls;
+
+    cls.style = 0;
+    cls.lpfnWndProc = enable_window_procA;
+    cls.cbClsExtra = 0;
+    cls.cbWndExtra = 0;
+    cls.hInstance = GetModuleHandleA(0);
+    cls.hIcon = 0;
+    cls.hCursor = LoadCursorA(0, (LPSTR)IDC_ARROW);
+    cls.hbrBackground = GetStockObject(WHITE_BRUSH);
+    cls.lpszMenuName = NULL;
+    cls.lpszClassName = "EnableWindowClass";
+    RegisterClassA(&cls);
+
+    cls.lpfnWndProc = enable_window_child_procA;
+    cls.hbrBackground = GetStockObject(GRAY_BRUSH);
+    cls.lpszClassName = "EnableWindowChildClass";
+    RegisterClassA(&cls);
+
+    enableWindowMsgIndex = 0;
+
+    hWndMain = CreateWindowExA(0, "EnableWindowClass", "",  WS_VISIBLE | WS_POPUP | WS_CAPTION | WS_SYSMENU,
+        0, 0, 100, 100, NULL, NULL, NULL, NULL);
+    hWndChild = CreateWindowExA(0, "EnableWindowChildClass", "", WS_VISIBLE | WS_CHILD,
+        20, 20, 60, 60, hWndMain, NULL, NULL, NULL);
+
+    assert( hWndMain );
+    assert( hWndChild );
+
+    SetFocus(hWndChild);
+    EnableWindow(hWndMain, FALSE);
+
+    ok (GetFocus() == hWndChild, "Window %p should have focus\n", hWndChild);
+}
+
 START_TEST(win)
 {
     pGetAncestor = (void *)GetProcAddress( GetModuleHandleA("user32.dll"), "GetAncestor" );
@@ -1695,4 +1774,6 @@
     test_children_zorder(hwndMain);
 
     UnhookWindowsHookEx(hhook);
+
+    test_EnableWindow();
 }
Index: windows/win.c
===================================================================
RCS file: /home/wine/wine/windows/win.c,v
retrieving revision 1.242
diff -u -r1.242 win.c
--- windows/win.c	28 May 2004 19:35:37 -0000	1.242
+++ windows/win.c	29 May 2004 01:21:31 -0000
@@ -1759,7 +1759,7 @@
         WIN_SetStyle( hwnd, style | WS_DISABLED );
 
         focus_wnd = GetFocus();
-        if (hwnd == focus_wnd || IsChild(hwnd, focus_wnd))
+        if (hwnd == focus_wnd)
             SetFocus( 0 );  /* A disabled window can't have the focus */
 
         capture_wnd = GetCapture();


More information about the wine-patches mailing list