Ignore:
Timestamp:
Jul 4, 2001, 7:46:05 PM (24 years ago)
Author:
sandervl
Message:

fix for GetTopWindow/GetWindow calls during WM_NCCREATE

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/user32/win32wbase.cpp

    r6168 r6169  
    1 /* $Id: win32wbase.cpp,v 1.273 2001-07-04 09:55:18 sandervl Exp $ */
     1/* $Id: win32wbase.cpp,v 1.274 2001-07-04 17:46:04 sandervl Exp $ */
    22/*
    33 * Win32 Window Base Class for OS/2
     
    2525 *       Window rectangle in parent coordinates (relative to parent's client window)
    2626 *       (screen coord. if no parent)
     27 *
     28 * NOTE: Status of window:
     29 *       Before a window has processed WM_NCCREATE:
     30 *       - GetTopWindow can't return that window handle
     31 *       - GetWindow(parent, GW_CHILD) can't return that window handle
     32 *       - IsChild works
     33 *       TODO: Does this affect more functions?? (other GetWindow ops)
     34 *       (verified in NT4, SP6)
    2735 *
    2836 * Project Odin Software License can be found in LICENSE.TXT
     
    105113  OS2HwndModalDialog  = 0;
    106114  fInternalMsg     = FALSE;
    107   fNoSizeMsg       = FALSE;
    108115  fParentChange    = FALSE;
    109   fIsDestroyed     = FALSE;
    110116  fDestroyWindowCalled = FALSE;
    111   fCreated         = FALSE;
    112117  fTaskList        = FALSE;
    113118  fParentDC        = FALSE;
    114119  fComingToTop     = FALSE;
    115   fCreateSetWindowPos = FALSE;
    116   fCreationFinished= FALSE;
    117120  fMinMaxChange    = FALSE;
    118121  fVisibleRegionChanged = FALSE;
    119122  fEraseBkgndFlag  = TRUE;
    120123
     124  state            = STATE_INIT;
    121125  windowNameA      = NULL;
    122126  windowNameW      = NULL;
     
    502506    }
    503507    OSLibWinSetVisibleRegionNotify(OS2Hwnd, TRUE);
    504     fCreationFinished = TRUE;   //creation done with success
     508    state = STATE_CREATED;
    505509    SetLastError(0);
    506510    return TRUE;
     
    516520
    517521    OS2Hwnd      = hwndOS2;
    518 
    519     fNoSizeMsg = TRUE;
    520522
    521523    if(OSLibWinSetWindowULong(OS2Hwnd, OFFSET_WIN32WNDPTR, getWindowHandle()) == FALSE) {
     
    718720    maxPos.x = rectWindow.left; maxPos.y = rectWindow.top;
    719721
    720     //Note: Solitaire crashes when receiving WM_SIZE messages before WM_CREATE
    721     fCreated = TRUE;
    722 
    723722    if(fTaskList) {
    724723        hTaskList = OSLibWinAddToTaskList(OS2HwndFrame, windowNameA, (cs->style & WS_VISIBLE) ? 1 : 0);
     
    727726    localSend32 = (isUnicode) ? ::SendMessageW : ::SendMessageA;
    728727
     728    state = STATE_PRE_WMNCCREATE;
    729729    if(localSend32(getWindowHandle(), WM_NCCREATE,0,(LPARAM)cs))
    730730    {
     
    744744        }
    745745        tmpRect = rectWindow;
    746 
    747         fCreateSetWindowPos = TRUE;
     746        state   = STATE_POST_WMNCCREATE;
    748747
    749748        //set the window size and update the client
    750749        SetWindowPos(hwndLinkAfter, tmpRect.left, tmpRect.top, tmpRect.right-tmpRect.left, tmpRect.bottom-tmpRect.top,SWP_NOACTIVATE | SWP_NOREDRAW | SWP_FRAMECHANGED);
    751         fNoSizeMsg = FALSE;
     750
     751        state = STATE_PRE_WMCREATE;
    752752        if (cs->style & WS_VISIBLE) dwStyle |= WS_VISIBLE; //program could change position in WM_CREATE
    753753        if( (localSend32(getWindowHandle(), WM_CREATE, 0, (LPARAM)cs )) != -1 )
    754754        {
     755            state = STATE_POST_WMCREATE;
     756
    755757            if(!(flags & WIN_NEED_SIZE))
    756758            {
     
    839841 HWND hwnd = getWindowHandle();
    840842
    841     fIsDestroyed = TRUE;
     843    state = STATE_DESTROYED;
    842844
    843845    if(fDestroyWindowCalled == FALSE)
     
    863865    TIMER_KillTimerFromWindow(getWindowHandle());
    864866
    865     if(getRefCount() == 0 && getFirstChild() == NULL && fCreationFinished) {
     867    if(getRefCount() == 0 && getFirstChild() == NULL && state == STATE_CREATED) {
    866868        delete this;
    867869    }
     
    895897ULONG Win32BaseWindow::MsgShow(BOOL fShow)
    896898{
    897     if(fNoSizeMsg || fDestroyWindowCalled) {
     899    if(!CanReceiveSizeMsgs() || fDestroyWindowCalled) {
    898900        return 1;
    899901    }
     
    917919    //SvL: Notes crashes when switching views (calls DestroyWindow -> PM sends
    918920    //     a WM_WINDOWPOSCHANGED msg -> crash)
    919     if(fNoSizeMsg || fDestroyWindowCalled)
     921    if(!CanReceiveSizeMsgs() || fDestroyWindowCalled)
    920922        return 0;
    921923
     
    928930    //SvL: Notes crashes when switching views (calls DestroyWindow -> PM sends
    929931    //     a WM_WINDOWPOSCHANGED msg -> crash)
    930     if(fNoSizeMsg || fDestroyWindowCalled)
     932    if(CanReceiveSizeMsgs() || fDestroyWindowCalled)
    931933        return 1;
    932934
     
    12021204    dprintf(("MsgFormatFrame: old window rect (%d,%d)(%d,%d), new window (%d,%d)(%d,%d)", oldWindowRect.left, oldWindowRect.top, oldWindowRect.right, oldWindowRect.bottom, rectWindow.left, rectWindow.top, rectWindow.right, rectWindow.bottom));
    12031205
    1204     if(fNoSizeMsg || !EqualRect(&client, &rectClient)) {
     1206    if(!CanReceiveSizeMsgs() || !EqualRect(&client, &rectClient)) {
    12051207        OSLibWinSetClientPos(getOS2WindowHandle(), rectClient.left, rectClient.top, getClientWidth(), getClientHeight(), getWindowHeight());
    12061208    }
     
    12081210#if 1
    12091211//this doesn't always work
    1210 //  if(!fNoSizeMsg && (client.left != rectClient.left || client.top != rectClient.top))
    1211   if(!fNoSizeMsg && ((oldWindowRect.right - oldWindowRect.left < rectClient.left
     1212//  if(CanReceiveSizeMsgs() && (client.left != rectClient.left || client.top != rectClient.top))
     1213  if(CanReceiveSizeMsgs() && ((oldWindowRect.right - oldWindowRect.left < rectClient.left
    12121214                  || oldWindowRect.bottom - oldWindowRect.top < rectClient.top) ||
    12131215     (EqualRect(&oldWindowRect, &rectWindow) && (client.left != rectClient.left || client.top != rectClient.top))))
     
    24472449#endif
    24482450
    2449     if(!fCreateSetWindowPos)
     2451    //Note: Solitaire crashes when receiving WM_SIZE messages before WM_CREATE
     2452    if(state < STATE_POST_WMNCCREATE)
    24502453    {//don't change size; modify internal structures only
    24512454        //TODO: not 100% correct yet (activate)
     
    27832786   /* Windows hides the window first, then shows it again
    27842787    * including the WM_SHOWWINDOW messages and all */
    2785    if(fCreated && (getStyle() & WS_VISIBLE)) {
     2788   if(IsWindowCreated() && (getStyle() & WS_VISIBLE)) {
    27862789        ShowWindow(SW_HIDE);
    27872790        fShow = TRUE;
     
    28322835      WM_WINDOWPOSCHANGED notification messages.
    28332836   */
    2834    if(fCreated) {
     2837   if(state >= STATE_PRE_WMNCCREATE) {
    28352838        SetWindowPos(HWND_TOPMOST, 0, 0, 0, 0,
    28362839                     SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOSIZE|(fShow? SWP_SHOWWINDOW : 0));
     
    28642867    {
    28652868        topwindow = GetWindowFromOS2FrameHandle(hwndTop);
    2866         if(topwindow) {
     2869        //Note: GetTopWindow can't return a window that hasn't processed
     2870        //      WM_NCCREATE yet (verified in NT4, SP6)
     2871        if(topwindow && topwindow->state >= STATE_POST_WMNCCREATE) {
    28672872            hwndTop = topwindow->getWindowHandle();
    28682873            RELEASE_WNDOBJ(topwindow);
    28692874            return hwndTop;
    28702875        }
     2876        if(topwindow) RELEASE_WNDOBJ(topwindow);
    28712877        return 0;
    28722878    }
    28732879    while(hwndTop) {
    28742880        topwindow = GetWindowFromOS2FrameHandle(hwndTop);
    2875         if(topwindow) {
     2881        //Note: GetTopWindow can't return a window that hasn't processed
     2882        //      WM_NCCREATE yet (verified in NT4, SP6)
     2883        if(topwindow && topwindow->state >= STATE_POST_WMNCCREATE) {
    28762884            hwndTop = topwindow->getWindowHandle();
    28772885            RELEASE_WNDOBJ(topwindow);
    28782886            return hwndTop;
    28792887        }
     2888        if(topwindow) RELEASE_WNDOBJ(topwindow);
    28802889        hwndTop = OSLibWinQueryWindow(hwndTop, QWOS_NEXT);
    28812890    }
     
    32013210        hwndRelated = OSLibWinQueryWindow(getOS2WindowHandle(), QWOS_TOP);
    32023211        window = GetWindowFromOS2FrameHandle(hwndRelated);
     3212
     3213        //Before a window has processed WM_NCCREATE:
     3214        //- GetWindow(parent, GW_CHILD) can't return that window handle
     3215        //(verified in NT4, SP6)
    32033216        if(window) {
    3204              hwndRelated = window->getWindowHandle();
    3205              RELEASE_WNDOBJ(window);
     3217             if(window->state >= STATE_POST_WMNCCREATE) {
     3218                 hwndRelated = window->getWindowHandle();
     3219                 RELEASE_WNDOBJ(window);
     3220             }
     3221             else {
     3222                 hwndRelated = window->GetWindow(GW_HWNDNEXT);
     3223                 RELEASE_WNDOBJ(window);
     3224             }
    32063225        }
    32073226        else hwndRelated = 0;
     3227
    32083228        break;
    32093229    }
Note: See TracChangeset for help on using the changeset viewer.