MSG #3: Add a test+fix for DestroyWindow() on a focused child

Dmitry Timoshkov dmitry at baikal.ru
Thu Mar 25 06:05:16 CST 2004


Hello,

this patch fixes focus handling in DestroyWindow(). It should not mess
with the focus at all, ShowWindow(SW_HIDE) will take care of it.

Actually this patch fixes a crash in one of applications I'm working on.

Please apply after MSG #2.

Changelog:
    Dmitry Timoshkov <dmitry at codeweavers.com>
    MSG #3: Add a test for DestroyWindow() on a focused child.
    Make DestroyWindow() to not mess with a window focus, this should be
    taken care by ShowWindow(SW_HIDE).

--- cvs/hq/wine/dlls/user/tests/msg.c	2004-03-25 19:27:17.000000000 +0800
+++ wine/dlls/user/tests/msg.c	2004-03-25 19:27:37.000000000 +0800
@@ -133,6 +133,9 @@ static const struct message WmDestroyChi
     { WM_WINDOWPOSCHANGING, sent|wparam, 0 },
     { WM_ERASEBKGND, sent|parent|optional },
     { WM_WINDOWPOSCHANGED, sent|wparam, 0 },
+    { HCBT_SETFOCUS, hook }, /* set focus to a parent */
+    { WM_KILLFOCUS, sent },
+    { WM_IME_SETCONTEXT, sent|optional },
     { WM_DESTROY, sent },
     { WM_DESTROY, sent|optional }, /* a bug in win2k sp4 ? */
     { WM_NCDESTROY, sent },
@@ -166,7 +169,7 @@ static const struct message WmDragTitleB
     { 0 }
 };
 /* Sizing by dragging the thick borders (after WM_NCHITTEST and WM_SETCURSOR) (outline move) */
-static const struct message WmDragThinkBordersBarSeq[] = { /* FIXME: add */
+static const struct message WmDragThickBordersBarSeq[] = { /* FIXME: add */
     { WM_NCLBUTTONDOWN, sent|wparam, 0xd },
     { WM_SYSCOMMAND, sent|defwinproc|wparam, 0xf004 },
     { WM_GETMINMAXINFO, sent|defwinproc },
@@ -480,6 +483,9 @@ static void test_messages(void)
     ShowWindow(hchild, TRUE);
     ok_sequence(WmShowChildSeq, "ShowWindow:child");
 
+    SetFocus(hchild);
+    flush_sequence();
+
     MoveWindow(hchild, 10, 10, 20, 20, TRUE);
     ok_sequence(WmResizingChildWithMoveWindowSeq, "MoveWindow:child");
 
--- cvs/hq/wine/windows/win.c	2004-02-18 20:48:18.000000000 +0800
+++ wine/windows/win.c	2004-03-25 19:21:33.000000000 +0800
@@ -1475,7 +1475,6 @@ static void WIN_SendDestroyMsg( HWND hwn
 BOOL WINAPI DestroyWindow( HWND hwnd )
 {
     BOOL is_child;
-    HWND h;
 
     if (!(hwnd = WIN_IsCurrentThread( hwnd )) || (hwnd == GetDesktopWindow()))
     {
@@ -1485,17 +1484,6 @@ BOOL WINAPI DestroyWindow( HWND hwnd )
 
     TRACE("(%p)\n", hwnd);
 
-    /* Look whether the focus is within the tree of windows we will
-     * be destroying.
-     */
-    h = GetFocus();
-    if (h == hwnd || IsChild( hwnd, h ))
-    {
-        HWND parent = GetAncestor( hwnd, GA_PARENT );
-        if (parent == GetDesktopWindow()) parent = 0;
-        SetFocus( parent );
-    }
-
     if (GetWindowLongW(hwnd, GWL_EXSTYLE) & WS_EX_MDICHILD)
         SendMessageW(GetAncestor(hwnd, GA_PARENT), WM_MDIREFRESHMENU, 0, 0);
 






More information about the wine-patches mailing list