diff --git a/documentation/gui b/documentation/gui index cbbcbfb1a35..43bac7543c3 100644 --- a/documentation/gui +++ b/documentation/gui @@ -54,7 +54,7 @@ Messages sent: CreateWindow (for child window, not initially visible) Messages sent: - WM_NCCREATE + WM_NCCREATE (Note that win->parent->child will not contain win. link is done after sucessfull WM_NCCREATE) WM_NCCALCSIZE (wParam=0) WM_CREATE WM_SIZE diff --git a/windows/win.c b/windows/win.c index 27db81454eb..5dc7bea7d43 100644 --- a/windows/win.c +++ b/windows/win.c @@ -310,6 +310,7 @@ void WIN_WalkWindows( HWND hwnd, int indent ) BOOL WIN_UnlinkWindow( HWND hwnd ) { WND *wndPtr, **ppWnd; + BOOL ret = FALSE; if (!(wndPtr = WIN_FindWndPtr( hwnd ))) return FALSE; else if(!wndPtr->parent) @@ -317,11 +318,16 @@ BOOL WIN_UnlinkWindow( HWND hwnd ) WIN_ReleaseWndPtr(wndPtr); return FALSE; } + ppWnd = &wndPtr->parent->child; - while (*ppWnd != wndPtr) ppWnd = &(*ppWnd)->next; - *ppWnd = wndPtr->next; + while (*ppWnd && *ppWnd != wndPtr) ppWnd = &(*ppWnd)->next; + if (*ppWnd) + { + *ppWnd = wndPtr->next; + ret = TRUE; + } WIN_ReleaseWndPtr(wndPtr); - return TRUE; + return ret; } diff --git a/windows/winpos.c b/windows/winpos.c index d07f01b9e18..b64e626f986 100644 --- a/windows/winpos.c +++ b/windows/winpos.c @@ -2525,8 +2525,13 @@ Pos: /* ----------------------------------------------------------------------- if(!(winpos.flags & SWP_NOZORDER)) { - WIN_UnlinkWindow( winpos.hwnd ); - WIN_LinkWindow( winpos.hwnd, hwndInsertAfter ); + /* upon window creation (while processing WM_NCCREATE), wndPtr->parent is set correctly + * but wndPtr is not yet in wndPtr->parent->child list + * in those cases (SetWindowPos called while processing WM_NCCREATE), + * do not unlink/link winPtr in parent->child + */ + if ( WIN_UnlinkWindow( winpos.hwnd ) ) + WIN_LinkWindow( winpos.hwnd, hwndInsertAfter ); } /* Reset active DCEs */