https://git.reactos.org/?p=reactos.git;a=commitdiff;h=f606fecb0d8c5d5aab11e9ac5214e3b48429ed5f

commit f606fecb0d8c5d5aab11e9ac5214e3b48429ed5f
Author:     Katayama Hirofumi MZ <[email protected]>
AuthorDate: Sat Dec 4 11:52:38 2021 +0900
Commit:     GitHub <[email protected]>
CommitDate: Sat Dec 4 11:52:38 2021 +0900

    [NTUSER] Fix where linking newly created window is done (#4127)
    
    Co-authored-by: I_Kill_Bugs <>
    CORE-12052
---
 win32ss/user/ntuser/window.c | 23 ++++++++++++++---------
 1 file changed, 14 insertions(+), 9 deletions(-)

diff --git a/win32ss/user/ntuser/window.c b/win32ss/user/ntuser/window.c
index d7877395159..7d2a97f3584 100644
--- a/win32ss/user/ntuser/window.c
+++ b/win32ss/user/ntuser/window.c
@@ -2190,14 +2190,9 @@ co_UserCreateWindowEx(CREATESTRUCTW* Cs,
 
    Window->rcClient = Window->rcWindow;
 
-   /* Link the window */
-   if (NULL != ParentWindow)
+   if (Window->spwndNext || Window->spwndPrev)
    {
-      /* Link the window into the siblings list */
-      if ((Cs->style & (WS_CHILD|WS_MAXIMIZE)) == WS_CHILD)
-          IntLinkHwnd(Window, HWND_BOTTOM);
-      else
-          IntLinkHwnd(Window, hwndInsertAfter);
+      ERR("Window 0x%p has been linked too early!\n", Window);
    }
 
    if (!(Window->state2 & WNDS2_WIN31COMPAT))
@@ -2210,10 +2205,10 @@ co_UserCreateWindowEx(CREATESTRUCTW* Cs,
    {
       if ( !IntIsTopLevelWindow(Window) )
       {
-         if (pti != Window->spwndParent->head.pti)
+         if (pti != ParentWindow->head.pti)
          {
             //ERR("CreateWindow Parent in.\n");
-            UserAttachThreadInput(pti, Window->spwndParent->head.pti, TRUE);
+            UserAttachThreadInput(pti, ParentWindow->head.pti, TRUE);
          }
       }
    }
@@ -2226,6 +2221,16 @@ co_UserCreateWindowEx(CREATESTRUCTW* Cs,
       goto cleanup;
    }
 
+   /* Link the window */
+   if (ParentWindow != NULL)
+   {
+      /* Link the window into the siblings list */
+      if ((Cs->style & (WS_CHILD | WS_MAXIMIZE)) == WS_CHILD)
+          IntLinkHwnd(Window, HWND_BOTTOM);
+      else
+          IntLinkHwnd(Window, hwndInsertAfter);
+   }
+
    /* Send the WM_NCCALCSIZE message */
    {
   // RECT rc;

Reply via email to