Changeset 5935 for trunk/src


Ignore:
Timestamp:
Jun 9, 2001, 4:50:26 PM (24 years ago)
Author:
sandervl
Message:

reference count (window + class objects) rewrite

Location:
trunk/src/user32
Files:
41 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/user32/HOOK.CPP

    r5863 r5935  
    1 /* $Id: HOOK.CPP,v 1.19 2001-06-01 10:28:17 sandervl Exp $ */
     1/* $Id: HOOK.CPP,v 1.20 2001-06-09 14:50:15 sandervl Exp $ */
    22
    33/*
     
    767767            hi.dwContextId = wnd->getWindowContextHelpId();
    768768            hi.MousePos = msg->pt;
     769            RELEASE_WNDOBJ(wnd);
    769770            SendMessageA(msg->hwnd, WM_HELP, 0, (LPARAM)&hi);
    770771        }
  • trunk/src/user32/Makefile

    r5899 r5935  
    1 # $Id: Makefile,v 1.84 2001-06-03 12:02:25 sandervl Exp $
     1# $Id: Makefile,v 1.85 2001-06-09 14:50:15 sandervl Exp $
    22
    33#
     
    3232$(OBJDIR)\dcscroll.obj \
    3333$(OBJDIR)\user32.obj \
    34 $(OBJDIR)\loadres.obj \
    3534$(OBJDIR)\dde.obj \
    36 $(OBJDIR)\win32wndhandle.obj \
    3735$(OBJDIR)\wsprintf.obj \
     36$(OBJDIR)\winkeyboard.obj \
    3837$(OBJDIR)\winmouse.obj \
    39 $(OBJDIR)\icon.obj \
    40 $(OBJDIR)\hook.obj \
    41 $(OBJDIR)\winkeyboard.obj \
    4238$(OBJDIR)\defwndproc.obj \
    4339$(OBJDIR)\syscolor.obj \
     
    5046$(OBJDIR)\display.obj \
    5147$(OBJDIR)\pmwindow.obj \
    52 $(OBJDIR)\win32class.obj \
    53 $(OBJDIR)\win32wnd.obj \
    54 $(OBJDIR)\win32dlg.obj \
     48$(OBJDIR)\oslibmsgtranslate.obj \
    5549$(OBJDIR)\msgbox.obj \
    5650$(OBJDIR)\window.obj \
     51$(OBJDIR)\gen_object.obj \
     52$(OBJDIR)\win32wndchild.obj \
     53$(OBJDIR)\win32wbase.obj \
     54$(OBJDIR)\win32wbasenonclient.obj \
     55$(OBJDIR)\win32wnd.obj \
     56$(OBJDIR)\win32wbasepos.obj \
     57$(OBJDIR)\win32wbaseprop.obj \
     58$(OBJDIR)\win32wndhandle.obj \
     59$(OBJDIR)\windowword.obj \
    5760$(OBJDIR)\windowmsg.obj \
     61$(OBJDIR)\winproc.obj \
     62$(OBJDIR)\oslibmsg.obj \
     63$(OBJDIR)\hook.obj \
     64$(OBJDIR)\win32wmdichild.obj \
     65$(OBJDIR)\win32wmdiclient.obj \
     66$(OBJDIR)\win32wdesktop.obj \
     67$(OBJDIR)\win32dlg.obj \
     68$(OBJDIR)\windlgmsg.obj \
     69$(OBJDIR)\windlg.obj \
     70$(OBJDIR)\win32class.obj \
    5871$(OBJDIR)\windowclass.obj \
    59 $(OBJDIR)\win32wbase.obj \
    60 $(OBJDIR)\windowword.obj \
    61 $(OBJDIR)\gen_object.obj \
    6272$(OBJDIR)\oslibwin.obj \
    63 $(OBJDIR)\win32wndchild.obj \
    6473$(OBJDIR)\controls.obj \
    6574$(OBJDIR)\button.obj \
     
    7382$(OBJDIR)\icontitle.obj \
    7483$(OBJDIR)\clipboard.obj \
    75 $(OBJDIR)\winicon.obj \
    76 $(OBJDIR)\win32wmdiclient.obj \
    7784$(OBJDIR)\oslibutil.obj \
    78 $(OBJDIR)\oslibmsg.obj \
    7985$(OBJDIR)\dib.obj \
    8086$(OBJDIR)\oslibdos.obj \
    81 $(OBJDIR)\win32wmdichild.obj \
    8287$(OBJDIR)\oslibgdi.obj \
     88$(OBJDIR)\oslibres.obj \
     89$(OBJDIR)\loadres.obj \
    8390$(OBJDIR)\winaccel.obj \
    84 $(OBJDIR)\win32wbasepos.obj \
    85 $(OBJDIR)\win32wbaseprop.obj \
    86 $(OBJDIR)\oslibres.obj \
     91$(OBJDIR)\icon.obj \
     92$(OBJDIR)\winicon.obj \
    8793$(OBJDIR)\timer.obj \
    8894$(OBJDIR)\dbglocal.obj \
    8995$(OBJDIR)\caret.obj \
    90 $(OBJDIR)\winproc.obj \
    9196$(OBJDIR)\text.obj \
    92 $(OBJDIR)\oslibmsgtranslate.obj \
    93 $(OBJDIR)\windlgmsg.obj \
    94 $(OBJDIR)\windlg.obj \
    95 $(OBJDIR)\win32wdesktop.obj \
    96 $(OBJDIR)\win32wbasenonclient.obj \
    9797$(OBJDIR)\oldnls32.obj \
    9898$(OBJDIR)\user32rsrc.obj
  • trunk/src/user32/caret.cpp

    r5685 r5935  
    1 /* $Id: caret.cpp,v 1.17 2001-05-11 08:39:41 sandervl Exp $ */
     1/* $Id: caret.cpp,v 1.18 2001-06-09 14:50:16 sandervl Exp $ */
    22
    33/*
     
    7979
    8080       wnd->RemoveFakeOpen32();
     81       RELEASE_WNDOBJ(wnd);
    8182       return (rc);
    8283   }
     
    144145           if (!pHps)
    145146           {
     147              RELEASE_WNDOBJ(wnd);
    146148              SetLastError(ERROR_INTERNAL_ERROR);
    147149              return FALSE;
     
    166168        CaretPosX = x;
    167169        CaretPosY = y;
     170        RELEASE_WNDOBJ(wnd);
    168171
    169172        rc = WinCreateCursor (cursorInfo.hwnd, xNew, yNew, 0, 0, CURSOR_SETPOS, NULL);
     
    212215            cursorInfo.y  = height - caretPos.y;
    213216         }
     217         RELEASE_WNDOBJ(wnd);
    214218      }
    215219      pPoint->x = cursorInfo.x;
  • trunk/src/user32/clipboard.cpp

    r5606 r5935  
    1 /* $Id: clipboard.cpp,v 1.11 2001-04-27 17:36:36 sandervl Exp $ */
     1/* $Id: clipboard.cpp,v 1.12 2001-06-09 14:50:16 sandervl Exp $ */
    22
    33/*
     
    2727{
    2828  Win32BaseWindow *wndRemove, *wndNext;
     29  HWND hwndOS2Remove, hwndOS2Next;
    2930
    3031    wndRemove = Win32BaseWindow::GetWindowFromHandle(hwndRemove);
     
    3435        return 0;
    3536    }
     37    hwndOS2Remove = wndRemove->getOS2WindowHandle();
     38    RELEASE_WNDOBJ(wndRemove);
     39
    3640    wndNext = Win32BaseWindow::GetWindowFromHandle(hwndNext);
    3741    if(!wndNext) {
     
    4044        return 0;
    4145    }
     46    hwndOS2Next = wndNext->getOS2WindowHandle();
     47    RELEASE_WNDOBJ(wndNext);
     48
    4249    dprintf(("USER32:  ChangeClipboardChain\n"));
    43     return O32_ChangeClipboardChain(wndRemove->getOS2WindowHandle(),
    44                                     wndNext->getOS2WindowHandle());
     50    return O32_ChangeClipboardChain(hwndOS2Remove, hwndOS2Next);
    4551}
    4652//******************************************************************************
     
    114120        return NULL;
    115121    }
    116     return window->getWindowHandle();
     122    hwndOwner = window->getWindowHandle();
     123    RELEASE_WNDOBJ(window);
     124    return hwndOwner;
    117125}
    118126//******************************************************************************
     
    131139        return NULL;
    132140    }
    133     return window->getWindowHandle();
     141    hwndViewer = window->getWindowHandle();
     142    RELEASE_WNDOBJ(window);
     143    return hwndViewer;
    134144}
    135145//******************************************************************************
     
    148158        return NULL;
    149159    }
    150     return window->getWindowHandle();
     160    hwnd = window->getWindowHandle();
     161    RELEASE_WNDOBJ(window);
     162    return hwnd;
    151163}
    152164//******************************************************************************
     
    177189            return 0;
    178190        }
     191        hwnd = window->getOS2WindowHandle();
     192        RELEASE_WNDOBJ(window);
    179193    }
    180194    dprintf(("USER32: OpenClipboard %x", hwnd));
    181     return O32_OpenClipboard(hwnd ? window->getOS2WindowHandle() : NULL);
     195    return O32_OpenClipboard(hwnd);
    182196}
    183197//******************************************************************************
     
    214228  Win32BaseWindow *wndnew, *wndold;
    215229  HWND hwndOld;
     230  HWND hwndOS2New;
    216231
    217232    wndnew = Win32BaseWindow::GetWindowFromHandle(hwndNew);
    218233    if(!wndnew) {
    219         dprintf(("OpenClipboard, window %x not found", hwndNew));
     234        dprintf(("SetClipboardViewer, window %x not found", hwndNew));
    220235        SetLastError(ERROR_INVALID_WINDOW_HANDLE);
    221236        return 0;
    222237    }
    223     dprintf(("USER32:  SetClipboardViewer\n"));
    224     hwndOld = O32_SetClipboardViewer(wndnew->getOS2WindowHandle());
     238    dprintf(("USER32: SetClipboardViewer %x", hwndNew));
     239    hwndOS2New = wndnew->getOS2WindowHandle();
     240    RELEASE_WNDOBJ(wndnew);
     241
     242    hwndOld = O32_SetClipboardViewer(hwndOS2New);
    225243
    226244    wndold = Win32BaseWindow::GetWindowFromOS2Handle(hwndOld);
     
    229247        return 0;
    230248    }
    231     return wndold->getWindowHandle();
    232 }
    233 //******************************************************************************
    234 //******************************************************************************
     249    hwndOld = wndold->getWindowHandle();
     250    RELEASE_WNDOBJ(wndold);
     251    return hwndOld;
     252}
     253//******************************************************************************
     254//******************************************************************************
  • trunk/src/user32/dc.cpp

    r5899 r5935  
    1 /* $Id: dc.cpp,v 1.108 2001-06-03 12:02:26 sandervl Exp $ */
     1/* $Id: dc.cpp,v 1.109 2001-06-09 14:50:16 sandervl Exp $ */
    22
    33/*
     
    450450   }
    451451   else wnd = Win32BaseWindow::GetWindowFromOS2FrameHandle(pHps->hwnd);
    452    return changePageXForm(wnd, pHps, pValue, x, y, pPrev);
     452   BOOL ret = changePageXForm(wnd, pHps, pValue, x, y, pPrev);
     453   if(wnd) RELEASE_WNDOBJ(wnd);
     454   return ret;
    453455}
    454456//******************************************************************************
     
    462464   }
    463465   else wnd = Win32BaseWindow::GetWindowFromOS2FrameHandle(pHps->hwnd);
    464    return setPageXForm(wnd, pHps);
     466   BOOL ret = setPageXForm(wnd, pHps);
     467   if(wnd) RELEASE_WNDOBJ(wnd);
     468   return ret;
    465469}
    466470//******************************************************************************
     
    476480   if(wnd) {
    477481      removeClientArea(wnd, pHps);
     482      RELEASE_WNDOBJ(wnd);
    478483   }
    479484}
     
    490495   if(wnd) {
    491496      selectClientArea(wnd, pHps);
     497      RELEASE_WNDOBJ(wnd);
    492498   }
    493499}
     
    505511      if(pHps->isClient)
    506512          selectClientArea(wnd, pHps);
     513      RELEASE_WNDOBJ(wnd);
    507514   }
    508515}
     
    521528   }
    522529   else wnd = Win32BaseWindow::GetWindowFromOS2FrameHandle(pHps->hwnd);
    523    return clientHeight(wnd, hwnd, pHps);
     530   LONG ret = clientHeight(wnd, hwnd, pHps);
     531   if(wnd) RELEASE_WNDOBJ(wnd);
     532   return ret;
    524533}
    525534//******************************************************************************
     
    533542   }
    534543   else wnd = Win32BaseWindow::GetWindowFromOS2FrameHandle(pHps->hwnd);
    535    return setMapMode(wnd, pHps, mode);
     544   int ret = setMapMode(wnd, pHps, mode);
     545   if(wnd) RELEASE_WNDOBJ(wnd);
     546   return ret;
    536547}
    537548//******************************************************************************
     
    673684            {
    674685                dprintf (("USER32: BeginPaint %x invalid parameter %x", hWnd, lpps));
     686                RELEASE_WNDOBJ(wnd);
    675687                SetLastError(ERROR_INVALID_PARAMETER_W);
    676688                return (HDC)NULLHANDLE;
     
    685697        {
    686698            dprintf (("USER32: BeginPaint %x invalid parameter %x", hWnd, lpps));
     699            RELEASE_WNDOBJ(wnd);
    687700            SetLastError(ERROR_INVALID_PARAMETER_W);
    688701            return (HDC)NULLHANDLE;
     
    773786        lpps->rcPaint.right = lpps->rcPaint.left = 0;
    774787    }
     788    RELEASE_WNDOBJ(wnd);
    775789
    776790    SetLastError(0);
     
    814828
    815829exit:
     830    if(wnd) RELEASE_WNDOBJ(wnd);
    816831    SetLastError(0);
    817832    return TRUE;
     
    850865            dprintf2(("ReleaseDC: CS_OWNDC, not released"));
    851866        }
     867        RELEASE_WNDOBJ(wnd);
    852868    }
    853869
     
    928944            //TODO: intersect/exclude clip region?
    929945            dprintf (("User32: GetDCEx hwnd %x (%x %x) -> wnd %x hdc %x", hwnd, hrgn, flags, wnd, hps));
     946
     947            RELEASE_WNDOBJ(wnd);
    930948            return (HDC)hps;
    931949        }
     
    10581076
    10591077    dprintf (("User32: GetDCEx hwnd %x (%x %x) -> hdc %x", hwnd, hrgn, flags, pHps->hps));
     1078    RELEASE_WNDOBJ(wnd);
     1079
    10601080    return (HDC)pHps->hps;
    10611081
     
    10801100        O32_DeleteObject (pHps->nullBitmapHandle);
    10811101    }
     1102    if(wnd) RELEASE_WNDOBJ(wnd);
    10821103    SetLastError(ERROR_INVALID_PARAMETER_W);
    10831104    return NULL;
     
    13231344        SetLastError(ERROR_INVALID_PARAMETER_W);
    13241345    }
     1346    if(wnd) RELEASE_WNDOBJ(wnd);
    13251347    return (success);
    13261348}
     
    13581380//    if(!WinIsWindowShowing(wnd->getOS2FrameWindowHandle()) || !WinIsWindowShowing(wnd->getOS2WindowHandle())) {
    13591381//        dprintf(("UpdateWindow: window not showing %d/%d", WinIsWindowShowing(wnd->getOS2FrameWindowHandle()), WinIsWindowShowing(wnd->getOS2WindowHandle()) ));
     1382//        RELEASE_WNDOBJ(wnd);
    13601383//        return FALSE;
    13611384//    }
     
    13711394    }
    13721395#endif
     1396    RELEASE_WNDOBJ(wnd);
    13731397    return rc;
    13741398}
     
    15511575    if (lComplexity == RGN_ERROR)
    15521576    {
     1577        RELEASE_WNDOBJ(window);
    15531578        return ERROR_W;
    15541579    }
     
    15761601                if(!child) {
    15771602                    dprintf(("ERROR: ScrollWindowEx, child %x not found", hwnd));
     1603                    RELEASE_WNDOBJ(window);
    15781604                    return 0;
    15791605                }
     
    15841610                     child->ScrollWindow(dx, orgdy);
    15851611                }
    1586                 hwndChild = GetWindow(hwndChild, GW_HWNDNEXT_W);
     1612                RELEASE_WNDOBJ(child);
     1613                hwndChild = GetWindow(hwndChild, GW_HWNDNEXT_W);       
    15871614            }
    15881615            dprintf(("***ScrollWindowEx: Scroll child windows DONE"));
     
    16161643       if (rc == FALSE)
    16171644       {
     1645          RELEASE_WNDOBJ(window);
    16181646          return (0);
    16191647       }
     
    16371665    }
    16381666
     1667    RELEASE_WNDOBJ(window);
    16391668    return (regionType);
    16401669}
     
    16431672BOOL WIN32API ScrollWindow(HWND hwnd, int dx, int dy, const RECT *pScroll, const RECT *pClip)
    16441673{
    1645  Win32BaseWindow *window;
    1646 
    1647     window = Win32BaseWindow::GetWindowFromHandle(hwnd);
    1648     if(!window) {
    1649         dprintf(("ScrollWindow, window %x not found", hwnd));
    1650         return 0;
    1651     }
    16521674    dprintf(("ScrollWindow %x %d %d %x %x", hwnd, dx, dy, pScroll, pClip));
    16531675    return (ERROR_W != ScrollWindowEx(hwnd, dx, dy, pScroll, pClip, 0, NULL,
  • trunk/src/user32/dcrgn.cpp

    r5687 r5935  
    1 /* $Id: dcrgn.cpp,v 1.5 2001-05-11 13:31:54 sandervl Exp $ */
     1/* $Id: dcrgn.cpp,v 1.6 2001-06-09 14:50:17 sandervl Exp $ */
    22
    33/*
     
    6868    if (!pRect) {
    6969        dprintf(("GetUpdateRect returned %d", updateRegionExists));
     70        RELEASE_WNDOBJ(wnd);
    7071        return (updateRegionExists);
    7172    }
     
    7879                pRect->left = pRect->top = pRect->right = pRect->bottom = 0;
    7980            }
     81            RELEASE_WNDOBJ(wnd);
    8082            return FALSE;
    8183        }
     
    9799
    98100   dprintf(("GetUpdateRect returned (%d,%d)(%d,%d)", pRect->left, pRect->top, pRect->right, pRect->bottom));
     101   RELEASE_WNDOBJ(wnd);
    99102   return updateRegionExists;
    100103}
     
    112115        dprintf(("WARNING: GetUpdateRgn %x %x %d; invalid handle", hwnd, hrgn, erase));
    113116        SetLastError(ERROR_INVALID_WINDOW_HANDLE_W);
     117        if(wnd) RELEASE_WNDOBJ(wnd);
    114118        return ERROR_W;
    115119    }
     
    118122        dprintf(("WARNING: GetUpdateRgn %x %x %d; RGN_ERROR", hwnd, hrgn, erase));
    119123        SetLastError(ERROR_INVALID_WINDOW_HANDLE_W);
     124        RELEASE_WNDOBJ(wnd);
    120125        return ERROR_W;
    121126    }
     
    127132            dprintf(("WARNING: GetUpdateRgn %x %x %d; setWinDeviceRegionFromPMDeviceRegion failed!", hwnd, hrgn, erase));
    128133            SetLastError(ERROR_INVALID_WINDOW_HANDLE_W);
     134            RELEASE_WNDOBJ(wnd);
    129135            return ERROR_W;
    130136        }
    131137        if(erase) sendEraseBkgnd(wnd);
    132138    }
     139    RELEASE_WNDOBJ(wnd);
    133140    return lComplexity;
    134141}
     
    146153        dprintf(("WARNING: ExcludeUpdateRgn %x %x; invalid handle", hdc, hwnd));
    147154        SetLastError(ERROR_INVALID_WINDOW_HANDLE_W);
     155        if(wnd) RELEASE_WNDOBJ(wnd);
    148156        return ERROR_W;
    149157    }
     
    155163    }
    156164    else SetLastError(ERROR_SUCCESS_W);
     165
     166    RELEASE_WNDOBJ(wnd);
    157167    return lComplexity;      // windows and PM values are identical
    158168}
     
    183193    dprintf(("USER32:GetWindowRgn (%x,%x)", hwnd, hRgn));
    184194    hWindowRegion = window->GetWindowRegion();
    185 
     195    RELEASE_WNDOBJ(window);
    186196    return CombineRgn(hRgn, hWindowRegion, 0, RGN_COPY_W);
    187197}
     
    228238        RedrawWindow(hwnd, 0, 0, RDW_UPDATENOW_W);
    229239    }
     240    RELEASE_WNDOBJ(window);
    230241//TODO:
    231242//  When this function is called, the system sends the WM_WINDOWPOSCHANGING and
  • trunk/src/user32/defwndproc.cpp

    r4194 r5935  
    1 /* $Id: defwndproc.cpp,v 1.14 2000-09-05 19:20:33 sandervl Exp $ */
     1/* $Id: defwndproc.cpp,v 1.15 2001-06-09 14:50:17 sandervl Exp $ */
    22
    33/*
     
    3131{
    3232  Win32BaseWindow *window;
     33  LRESULT result;
    3334
    3435    dprintf2(("DefWindowProcA %x %x %x %x", hwnd, Msg, wParam, lParam));
     
    3839        return 0;
    3940    }
    40     return window->DefWindowProcA(Msg, wParam, lParam);
     41    result = window->DefWindowProcA(Msg, wParam, lParam);
     42    RELEASE_WNDOBJ(window);
     43    return result;
    4144}
    4245//******************************************************************************
     
    4548{
    4649  Win32BaseWindow *window;
     50  LRESULT result;
    4751
    4852    dprintf2(("DefWindowProcW %x %x %x %x", hwnd, Msg, wParam, lParam));
     
    5256        return 0;
    5357    }
    54     return window->DefWindowProcW(Msg, wParam, lParam);
     58    result = window->DefWindowProcW(Msg, wParam, lParam);
     59    RELEASE_WNDOBJ(window);
     60    return result;
    5561}
    5662//******************************************************************************
     
    5965{
    6066  Win32Dialog *dialog;
     67  LRESULT result;
    6168
    6269    dialog = (Win32Dialog *)Win32BaseWindow::GetWindowFromHandle(hwnd);
     
    6875    }
    6976    if(dialog->IsDialog())
    70          return dialog->DefDlgProcA(Msg, wParam, lParam);
    71     else return dialog->DefWindowProcA(Msg, wParam, lParam);
     77         result = dialog->DefDlgProcA(Msg, wParam, lParam);
     78    else result = dialog->DefWindowProcA(Msg, wParam, lParam);
     79    RELEASE_WNDOBJ(dialog);
     80    return result;
    7281}
    7382//******************************************************************************
     
    7685{
    7786  Win32Dialog *dialog;
     87  LRESULT result;
    7888
    7989    dialog = (Win32Dialog *)Win32BaseWindow::GetWindowFromHandle(hwnd);
     
    8595    }
    8696    if(dialog->IsDialog())
    87          return dialog->DefDlgProcW(Msg, wParam, lParam);
    88     else return dialog->DefWindowProcW(Msg, wParam, lParam);
     97         result = dialog->DefDlgProcW(Msg, wParam, lParam);
     98    else result = dialog->DefWindowProcW(Msg, wParam, lParam);
     99    RELEASE_WNDOBJ(dialog);
     100    return result;
    89101}
    90102//******************************************************************************
     
    93105{
    94106  Win32Window *window;
     107  LRESULT result;
    95108
    96109    window = (Win32Window *)Win32BaseWindow::GetWindowFromHandle(hwndFrame);
     
    99112        return 0;
    100113    }
    101     return window->DefFrameProcA(hwndMDIClient, Msg, wParam, lParam);
     114    result = window->DefFrameProcA(hwndMDIClient, Msg, wParam, lParam);
     115    RELEASE_WNDOBJ(window);
     116    return result;
    102117}
    103118//******************************************************************************
     
    106121{
    107122  Win32Window *window;
     123  LRESULT result;
    108124
    109125    window = (Win32Window *)Win32BaseWindow::GetWindowFromHandle(hwndFrame);
     
    112128        return 0;
    113129    }
    114     return window->DefFrameProcW(hwndMDIClient, Msg, wParam, lParam);
     130    result = window->DefFrameProcW(hwndMDIClient, Msg, wParam, lParam);
     131    RELEASE_WNDOBJ(window);
     132    return result;
    115133}
    116134//******************************************************************************
     
    119137{
    120138  Win32MDIChildWindow *window;
     139  LRESULT result;
    121140
    122141    window = (Win32MDIChildWindow *)Win32BaseWindow::GetWindowFromHandle(hwnd);
     
    127146    if(!window->isMDIChild()) {
    128147         dprintf(("App called DefMDIChildProcA for non-MDI window %x", hwnd));
    129          return window->DefWindowProcA(Msg, wParam, lParam);
     148         result = window->DefWindowProcA(Msg, wParam, lParam);
    130149    }
    131     else return window->DefMDIChildProcA(Msg, wParam, lParam);
    132    
     150    else result = window->DefMDIChildProcA(Msg, wParam, lParam);
     151    RELEASE_WNDOBJ(window);
     152    return result;
    133153}
    134154//******************************************************************************
     
    137157{
    138158  Win32MDIChildWindow *window;
     159  LRESULT result;
    139160
    140161    window = (Win32MDIChildWindow *)Win32BaseWindow::GetWindowFromHandle(hwnd);
     
    145166    if(!window->isMDIChild()) {
    146167         dprintf(("App called DefMDIChildProcA for non-MDI window %x", hwnd));
    147          return window->DefWindowProcW(Msg, wParam, lParam);
     168         result = window->DefWindowProcW(Msg, wParam, lParam);
    148169    }
    149     else return window->DefMDIChildProcW(Msg, wParam, lParam);
     170    else result = window->DefMDIChildProcW(Msg, wParam, lParam);
     171    RELEASE_WNDOBJ(window);
     172    return result;
    150173}
    151174//******************************************************************************
  • trunk/src/user32/gen_object.cpp

    r5083 r5935  
    1 /* $Id: gen_object.cpp,v 1.7 2001-02-10 10:31:31 sandervl Exp $ */
     1/* $Id: gen_object.cpp,v 1.8 2001-06-09 14:50:17 sandervl Exp $ */
    22/*
    33 * Generic Object Class for OS/2
     
    1616#include <win32type.h>
    1717#include <gen_object.h>
    18 #include <vmutex.h>
    1918
    2019#define DBG_LOCALLOG    DBG_gen_object
    2120#include "dbglocal.h"
    2221
    23 VMutex genMutex[OBJTYPE_MAX];
    24 
    2522//******************************************************************************
    2623//******************************************************************************
    27 GenericObject::GenericObject(GenericObject **head, DWORD objType)
     24GenericObject::GenericObject(GenericObject **head, CRITICAL_SECTION *pLock)
    2825{
    29   this->objType = objType;
    30   this->head    = head;
    31   this->next    = NULL;
     26  this->pLock = pLock;
     27  this->head  = head;
     28  this->next  = NULL;
     29  refCount    = 1;
     30 
     31  fLinked     = FALSE;
     32  fDeletePending = FALSE;
    3233
    33   genMutex[objType].enter();
     34  link();
     35}
     36//******************************************************************************
     37//******************************************************************************
     38GenericObject::~GenericObject()
     39{
     40  unlink();
     41}
     42//******************************************************************************
     43//******************************************************************************
     44void GenericObject::link()
     45{
     46  lock();
    3447  if(*head == NULL) {
    3548        *head = this;   
     
    4356        cur->next = this;
    4457  }
    45   genMutex[objType].leave();
     58  fLinked = TRUE;
     59  unlock();
    4660}
    4761//******************************************************************************
    4862//******************************************************************************
    49 GenericObject::~GenericObject()
     63void GenericObject::unlink()
    5064{
     65  if(!fLinked)   return;
     66
    5167  //remove from linked list
    52   genMutex[objType].enter();
     68  lock();
    5369  if(*head == this) {
    5470        *head = next;   
     
    6177                if(cur == NULL) {
    6278                        dprintf(("GenericObject dtor: cur == NULL!!"));
     79                        unlock();
    6380                        DebugInt3();
     81                        return;
    6482                }
    6583        }
    6684        cur->next = next;
    6785  }
    68   genMutex[objType].leave();
     86  unlock();
     87}
     88//******************************************************************************
     89//******************************************************************************
     90LONG GenericObject::release()
     91{
     92////  dprintf(("release -> refcount %x", refCount));
     93#ifdef DEBUG
     94  if(refCount-1 < 0) {
     95      DebugInt3();
     96  }
     97#endif
     98  if(InterlockedDecrement(&refCount) == 0 && fDeletePending) {
     99      delete this;
     100      return 0;
     101  }
     102  return refCount;
    69103}
    70104//******************************************************************************
     
    77111  while(cur) {
    78112        next = cur->next;
     113        if(cur->getRefCount() != 0) {
     114            dprintf(("Refcount %d for object %x", cur->getRefCount(), cur));
     115        }
    79116        delete cur;
    80117        cur = next;
     
    83120//******************************************************************************
    84121//******************************************************************************
    85 void GenericObject::enterMutex()
    86 {
    87   genMutex[objType].enter();
    88 }
    89 //******************************************************************************
    90 //******************************************************************************
    91 void GenericObject::leaveMutex()
    92 {
    93   genMutex[objType].leave();
    94 }
    95 //******************************************************************************
    96 //******************************************************************************
    97 void GenericObject::enterMutex(DWORD objType)
    98 {
    99   genMutex[objType].enter();
    100 }
    101 //******************************************************************************
    102 //******************************************************************************
    103 void GenericObject::leaveMutex(DWORD objType)
    104 {
    105   genMutex[objType].leave();
    106 }
    107 //******************************************************************************
    108 //******************************************************************************
  • trunk/src/user32/gen_object.h

    r2469 r5935  
    1 /* $Id: gen_object.h,v 1.5 2000-01-18 20:08:09 sandervl Exp $ */
     1/* $Id: gen_object.h,v 1.6 2001-06-09 14:50:17 sandervl Exp $ */
    22/*
    33 * Generic Object Class for OS/2
     
    1010
    1111#include <heapshared.h>
    12 
    13 #define OBJTYPE_WINDOW          0
    14 #define OBJTYPE_DIALOG          1
    15 #define OBJTYPE_CLASS           2
    16 #define OBJTYPE_BITMAP          3
    17 #define OBJTYPE_ICON            4
    18 #define OBJTYPE_CURSOR          5
    19 #define OBJTYPE_MENU            6
    20 
    21 #define OBJTYPE_MAX             7
    22 //......
     12#ifdef OS2_INCLUDED
     13#include <win32api.h>
     14#endif
    2315
    2416class GenericObject
    2517{
    2618public:
    27          GenericObject(GenericObject **head, DWORD objType);
     19         GenericObject(GenericObject **head, CRITICAL_SECTION *pLock);
    2820virtual ~GenericObject();
    29 
    30          DWORD getObjectType()                  { return objType; };
    31          void  setObjectType(DWORD objType)     { this->objType = objType; };
    3221
    3322GenericObject *GetHead()        { return *head; };
    3423GenericObject *GetNext()        { return next;  };
    3524
    36          void  enterMutex();
    37          void  leaveMutex();
     25         void  lock()           { EnterCriticalSection(pLock); };
     26         void  unlock()         { LeaveCriticalSection(pLock); };
    3827
    39 static   void  enterMutex(DWORD objType);
    40 static   void  leaveMutex(DWORD objType);
     28         void  link();
     29         void  unlink();
     30
     31         LONG  addRef()         { return InterlockedIncrement(&refCount); };
     32         LONG  getRefCount()    { return refCount; };
     33         LONG  release();
     34
     35         void  markDeleted()    { fDeletePending = TRUE; };
     36
     37static   void  lock(CRITICAL_SECTION *pLock)           { EnterCriticalSection(pLock); };
     38static   void  unlock(CRITICAL_SECTION *pLock)         { LeaveCriticalSection(pLock); };
    4139
    4240static   void  DestroyAll(GenericObject *head);
     
    6462private:
    6563
    66          DWORD objType;
    67 
    6864protected:
    6965
    70          GenericObject **head;
    71          GenericObject  *next;   
     66         CRITICAL_SECTION *pLock;
     67         LONG              refCount;
     68         ULONG             fLinked        : 1,
     69                           fDeletePending : 1;
     70
     71         GenericObject   **head;
     72         GenericObject    *next;         
    7273};
    7374
  • trunk/src/user32/icontitle.cpp

    r5496 r5935  
    1 /* $Id: icontitle.cpp,v 1.6 2001-04-12 14:04:32 sandervl Exp $ */
     1/* $Id: icontitle.cpp,v 1.7 2001-06-09 14:50:17 sandervl Exp $ */
    22/*
    33 * Icontitle window class.
     
    5252                                  WS_CLIPSIBLINGS, 0, 0, 1, 1,
    5353                                  parent->getWindowHandle(),0,parent->getInstance(), NULL );
     54
    5455    win32wnd = Win32BaseWindow::GetWindowFromHandle(hWnd);
    5556    if (win32wnd)
     
    5859        win32wnd->setStyle(win32wnd->getStyle() & ~(WS_CAPTION | WS_BORDER));
    5960        if (parent->getStyle() & WS_DISABLED ) win32wnd->setStyle(win32wnd->getStyle() | WS_DISABLED);
     61        RELEASE_WNDOBJ(win32wnd);
    6062        return hWnd;
    6163    }
     
    245247             }
    246248    }
    247 
    248249    retvalue = DefWindowProcA( hWnd, msg, wParam, lParam );
    249250END:
     251    if(wnd) RELEASE_WNDOBJ(wnd);
    250252    return retvalue;
    251253}
  • trunk/src/user32/menu.cpp

    r5766 r5935  
    1 /* $Id: menu.cpp,v 1.31 2001-05-20 08:49:49 sandervl Exp $*/
     1/* $Id: menu.cpp,v 1.32 2001-06-09 14:50:18 sandervl Exp $*/
    22/*
    33 * Menu functions
     
    298298{
    299299  Win32BaseWindow *win32wnd = Win32BaseWindow::GetWindowFromHandle(hwnd);
    300 
    301   return win32wnd ? win32wnd->GetMenu():(HMENU)0;
     300 
     301  if(win32wnd) {
     302      HMENU hmenu = win32wnd->GetMenu();
     303      RELEASE_WNDOBJ(win32wnd);
     304      return hmenu;
     305  }
     306  return (HMENU)0;
    302307}
    303308
     
    306311  Win32BaseWindow *win32wnd = Win32BaseWindow::GetWindowFromHandle(hwnd);
    307312
    308   if (win32wnd) win32wnd->SetMenu(hMenu);
     313  if (win32wnd) {
     314      win32wnd->SetMenu(hMenu);
     315      RELEASE_WNDOBJ(win32wnd);
     316  }
    309317}
    310318
     
    313321  Win32BaseWindow *win32wnd = Win32BaseWindow::GetWindowFromHandle(hwnd);
    314322
    315   return win32wnd ? win32wnd->GetSysMenu():(HMENU)0;
     323  if(win32wnd) {
     324      HMENU hmenu = win32wnd->GetSysMenu();
     325      RELEASE_WNDOBJ(win32wnd);
     326      return hmenu;
     327  }
     328  return (HMENU)0;
    316329}
    317330
     
    320333  Win32BaseWindow *win32wnd = Win32BaseWindow::GetWindowFromHandle(hwnd);
    321334
    322   win32wnd->SetSysMenu(hMenu);
     335  if(win32wnd) {
     336      win32wnd->SetSysMenu(hMenu);
     337      RELEASE_WNDOBJ(win32wnd);
     338  }
    323339}
    324340
     
    21742190          rect.bottom = GetSystemMetrics(SM_CYSIZE);
    21752191        }
     2192        if(win32wnd) RELEASE_WNDOBJ(win32wnd);
    21762193    }
    21772194    else
     
    22322249
    22332250        ht = win32wnd->HandleNCHitTest(pt);
     2251        RELEASE_WNDOBJ(win32wnd);
    22342252        if( menu->wFlags & MF_POPUP )
    22352253            ht =  (ht != (UINT)HTNOWHERE &&
     
    39954013{
    39964014    HMENU retvalue = 0;
    3997     Win32BaseWindow *win32wnd = Win32BaseWindow::GetWindowFromHandle(hWnd);
    3998 
    3999     dprintf(("USER32: GetSystemMenu"));
    4000 
    4001     if (win32wnd)
     4015
     4016    dprintf(("USER32: GetSystemMenu %x %d", hWnd, bRevert));
     4017
     4018    if (IsWindow(hWnd))
    40024019    {
    40034020        HMENU hSysMenu = getSysMenu(hWnd);
     
    40634080        if (win32wnd->GetSysMenu()) DestroyMenu(win32wnd->GetSysMenu());
    40644081        win32wnd->SetSysMenu(MENU_GetSysMenu( hwnd, hMenu ));
     4082        RELEASE_WNDOBJ(win32wnd);
    40654083        return TRUE;
    40664084    }
  • trunk/src/user32/oslibmsgtranslate.cpp

    r5805 r5935  
    1 /* $Id: oslibmsgtranslate.cpp,v 1.52 2001-05-25 19:59:29 sandervl Exp $ */
     1/* $Id: oslibmsgtranslate.cpp,v 1.53 2001-06-09 14:50:18 sandervl Exp $ */
    22/*
    33 * Window message translation functions for OS/2
     
    225225            winMsg->lParam  = packet->lParam;
    226226            if(fMsgRemoved == MSG_REMOVE) free(packet); //free the shared memory here
     227            if(win32wnd) RELEASE_WNDOBJ(win32wnd);
    227228            return TRUE;
    228229        }
     
    231232            winMsg->wParam  = (UINT)os2Msg->mp1;
    232233            winMsg->lParam  = (DWORD)os2Msg->mp2;
     234            if(win32wnd) RELEASE_WNDOBJ(win32wnd);
    233235            return TRUE;
    234236        }
     
    247249
    248250        win32wnd = (Win32BaseWindow *)teb->o.odin.newWindow;
     251        win32wnd->addRef();
    249252
    250253        winMsg->message = WINWM_CREATE;
     
    311314                {
    312315                        Win32BaseWindow *wndAfter = Win32BaseWindow::GetWindowFromOS2Handle(pswp->hwndInsertBehind);
    313                         if(wndAfter)
     316                        if(wndAfter) {
    314317                              teb->o.odin.wp.hwndInsertAfter = wndAfter->getWindowHandle();
     318                              RELEASE_WNDOBJ(wndAfter);
     319                        }
    315320                        else  teb->o.odin.wp.hwndInsertAfter = HWND_TOP_W;
    316321                }
     
    388393            hwnd = WindowFromPoint(winMsg->pt);
    389394            if(win32wnd->getWindowHandle() != hwnd) {
     395                RELEASE_WNDOBJ(win32wnd);
    390396                win32wnd = Win32BaseWindow::GetWindowFromHandle(hwnd);
    391397                if(win32wnd == NULL) {
     
    401407        if(!IsWindowEnabled(win32wnd->getWindowHandle())) {
    402408            if(win32wnd->getParent()) {
    403                 win32wnd = win32wnd->getParent();
     409                Win32BaseWindow *parent = win32wnd->getParent();;
     410                if(parent) parent->addRef();
     411                RELEASE_WNDOBJ(win32wnd);
     412                win32wnd = parent;
    404413            }
    405414            fWasDisabled = TRUE;
     
    463472            hwnd = WindowFromPoint(winMsg->pt);
    464473            if(win32wnd->getWindowHandle() != hwnd) {
     474                RELEASE_WNDOBJ(win32wnd);
    465475                win32wnd = Win32BaseWindow::GetWindowFromHandle(hwnd);
    466476                if(win32wnd == NULL) {
     
    476486        if(!IsWindowEnabled(win32wnd->getWindowHandle())) {
    477487            if(win32wnd->getParent()) {
    478                 win32wnd = win32wnd->getParent();
     488                Win32BaseWindow *parent = win32wnd->getParent();;
     489                if(parent) parent->addRef();
     490                RELEASE_WNDOBJ(win32wnd);
     491                win32wnd = parent;
    479492            }
    480493            fWasDisabled = TRUE;
     
    793806        winMsg->wParam  = 0;
    794807        winMsg->lParam  = 0;
     808        if(win32wnd) RELEASE_WNDOBJ(win32wnd);
    795809        return FALSE;
    796810    }
     811    if(win32wnd) RELEASE_WNDOBJ(win32wnd);
    797812    return TRUE;
    798813}
  • trunk/src/user32/oslibwin.cpp

    r5777 r5935  
    1 /* $Id: oslibwin.cpp,v 1.95 2001-05-22 09:33:10 sandervl Exp $ */
     1/* $Id: oslibwin.cpp,v 1.96 2001-06-09 14:50:19 sandervl Exp $ */
    22/*
    33 * Window API wrappers for OS/2
     
    1919
    2020#include <misc.h>
    21 #include "win32type.h"
     21#include <win32type.h>
    2222#include <winconst.h>
    2323#include "oslibwin.h"
  • trunk/src/user32/pmwindow.cpp

    r5805 r5935  
    1 /* $Id: pmwindow.cpp,v 1.132 2001-05-25 19:59:29 sandervl Exp $ */
     1/* $Id: pmwindow.cpp,v 1.133 2001-06-09 14:50:19 sandervl Exp $ */
    22/*
    33 * Win32 Window Managment Code for OS/2
     
    214214            rc = (MRESULT)win32wnd->DispatchMsgA(pWinMsg);
    215215        }
     216        RELEASE_WNDOBJ(win32wnd);
    216217        RestoreOS2TIB();
    217218        return rc;
     
    229230        dprintf(("OS2: WM_CREATE %x", hwnd));
    230231        win32wnd = (Win32BaseWindow *)teb->o.odin.newWindow;
     232        win32wnd->addRef();
    231233        teb->o.odin.newWindow = 0;
    232234        if(win32wnd->MsgCreate(hwnd) == FALSE)
     
    302304                WinSetWindowPos( hwnd, HWND_TOP, 0, 0, 0, 0, SWP_ZORDER );
    303305            }
     306            if(topwindow) RELEASE_WNDOBJ(topwindow);
    304307
    305308            win32wnd->setComingToTop(FALSE);
     
    319322        dprintf(("USER32: Delayed SetFocus %x %x %x call!", teb->o.odin.hwndFocus, mp1, mp2));
    320323        if(teb->o.odin.hwndFocus) {
     324            RELEASE_WNDOBJ(win32wnd);
    321325            win32wnd = Win32BaseWindow::GetWindowFromHandle(teb->o.odin.hwndFocus);
    322326            if(win32wnd) {
     
    373377    case WM_BUTTON3DBLCLK:
    374378        if(win32wnd->getWindowHandle() != pWinMsg->hwnd) {
     379            RELEASE_WNDOBJ(win32wnd);
    375380            win32wnd = Win32BaseWindow::GetWindowFromHandle(pWinMsg->hwnd);
    376381        }
     
    396401    {
    397402        if(win32wnd->getWindowHandle() != pWinMsg->hwnd) {
     403            RELEASE_WNDOBJ(win32wnd);
    398404            win32wnd = Win32BaseWindow::GetWindowFromHandle(pWinMsg->hwnd);
    399405        }
     
    525531        goto RunDefWndProc;
    526532    }
     533    if(win32wnd) RELEASE_WNDOBJ(win32wnd);
    527534    RestoreOS2TIB();
    528535    return (MRESULT)rc;
     
    530537RunDefWndProc:
    531538//  dprintf(("OS2: RunDefWndProc msg %x for %x", msg, hwnd));
     539    if(win32wnd) RELEASE_WNDOBJ(win32wnd);
    532540    RestoreOS2TIB();
    533541    return WinDefWindowProc( hwnd, msg, mp1, mp2 );
     
    622630    {
    623631        dprintf(("PMFRAME:WM_ERASEBACKGROUND %x", win32wnd->getWindowHandle()));
    624         RestoreOS2TIB();
    625         return (MRESULT)FALSE;
     632        rc = (MRESULT)FALSE;
     633        break;
    626634    }
    627635
     
    640648    case WM_BUTTON3DBLCLK:
    641649        if(win32wnd->getWindowHandle() != pWinMsg->hwnd) {
     650            RELEASE_WNDOBJ(win32wnd);
    642651            win32wnd = Win32BaseWindow::GetWindowFromHandle(pWinMsg->hwnd);
    643652        }
     
    663672    {
    664673        if(win32wnd->getWindowHandle() != pWinMsg->hwnd) {
     674            RELEASE_WNDOBJ(win32wnd);
    665675            win32wnd = Win32BaseWindow::GetWindowFromHandle(pWinMsg->hwnd);
    666676        }
     
    724734           if(wndAfter) {
    725735                wp.hwndInsertAfter = wndAfter->getWindowHandle();
     736                RELEASE_WNDOBJ(wndAfter);
    726737           }
    727738           else wp.hwndInsertAfter = HWND_TOP_W;
     
    760771            pswp->hwnd = hwnd;
    761772
    762             RestoreOS2TIB();
    763             return (MRESULT)0xf;
    764         }
    765         RestoreOS2TIB();
    766         return (MRESULT)0;
     773            rc = (MRESULT)0xf;
     774            break;
     775        }
     776        rc = 0;
     777        break;
    767778    }
    768779
     
    835846            if(wndAfter) {
    836847                 wp.hwndInsertAfter = wndAfter->getWindowHandle();
     848                 RELEASE_WNDOBJ(wndAfter);
    837849            }
    838850            else wp.hwndInsertAfter = HWND_TOP_W;
     
    959971
    960972PosChangedEnd:
    961         RestoreOS2TIB();
    962         return (MRESULT)FALSE;
     973        rc = (MRESULT)FALSE;
     974        break;
    963975    }
    964976
     
    9941006            if(wndAfter) {
    9951007                 wp.hwndInsertAfter = wndAfter->getWindowHandle();
     1008                 RELEASE_WNDOBJ(wndAfter);
    9961009            }
    9971010            else wp.hwndInsertAfter = HWND_TOP_W;
     
    10461059            newRect->yBottom += newClientRect.yBottom;
    10471060        }
    1048         RestoreOS2TIB();
    1049         return (MRESULT)res;
     1061        rc = res;
     1062        break;
    10501063    }
    10511064#else
    10521065        dprintf(("PMWINDOW: WM_CALCVALIDRECTS %x", win32wnd->getWindowHandle()));
    1053         RestoreOS2TIB();
    1054         return (MRESULT)(CVR_ALIGNLEFT | CVR_ALIGNTOP);
     1066        rc = (MRESULT)(CVR_ALIGNLEFT | CVR_ALIGNTOP);
     1067        break;
    10551068#endif
    10561069
     
    10781091#endif
    10791092
    1080 #if 0
    1081     //is sent to both windows gaining and loosing the focus
    1082     case WM_FOCUSCHANGE:
    1083     {
    1084      HWND   hwndFocus = (HWND)mp1;
    1085      HWND   hwndLoseFocus, hwndGainFocus;
    1086      USHORT usSetFocus = SHORT1FROMMP(mp2);
    1087      USHORT fsFocusChange = SHORT2FROMMP(mp2);
    1088 
    1089         rc = 0;
    1090         dprintf(("PMFRAME:WM_FOCUSCHANGE (start) %x %x %x %x", win32wnd->getWindowHandle(), hwndFocus, usSetFocus, fsFocusChange));
    1091         if(usSetFocus) {
    1092             hwndGainFocus = hwnd;
    1093             hwndLoseFocus = hwndFocus;
    1094         }
    1095         else {
    1096             hwndGainFocus = hwndFocus;
    1097             hwndLoseFocus = hwnd;
    1098         }
    1099 
    1100         if(usSetFocus)
    1101         {
    1102           Win32BaseWindow *winfocus = Win32BaseWindow::GetWindowFromOS2Handle(hwndLoseFocus);
    1103           if(!(fsFocusChange & FC_NOSETACTIVE))
    1104           {
    1105             if(!winfocus || (winfocus->GetTopParent() != win32wnd->GetTopParent()))
    1106             {
    1107               if(winfocus)
    1108                 WinSendMsg(winfocus->GetTopParent()->getOS2WindowHandle(), WM_ACTIVATE, (MPARAM)0, (MPARAM)hwndGainFocus);
    1109               else
    1110                 WinSendMsg(hwndLoseFocus, WM_ACTIVATE, (MPARAM)0, (MPARAM)hwndGainFocus);
    1111             }
    1112           }
    1113           //SvL: Check if window is still valid
    1114           win32wnd = Win32BaseWindow::GetWindowFromOS2Handle(hwnd);
    1115           if(win32wnd == NULL) {
    1116             RestoreOS2TIB();
    1117             return (MRESULT)rc;
    1118           }
    1119           if(!(fsFocusChange & FC_NOSETACTIVE))
    1120           {
    1121             Win32BaseWindow *topparent = win32wnd->GetTopParent();
    1122             if(!winfocus || (winfocus->GetTopParent() != topparent))
    1123             {
    1124               if(!(fsFocusChange & FC_NOBRINGTOTOP))
    1125               {
    1126                 if(topparent) {
    1127                   //put window at the top of z order
    1128                   WinSetWindowPos(topparent->getOS2WindowHandle(), HWND_TOP, 0, 0, 0, 0, SWP_ZORDER);
    1129                 }
    1130               }
    1131 
    1132               // PH 2000/09/01 Netscape 4.7
    1133               // check if topparent is valid
    1134               if (topparent)
    1135                 WinSendMsg(topparent->getOS2WindowHandle(), WM_ACTIVATE, (MPARAM)1, (MPARAM)hwndLoseFocus);
    1136             }
    1137           }
    1138           //SvL: Check if window is still valid
    1139           win32wnd = Win32BaseWindow::GetWindowFromOS2Handle(hwnd);
    1140           if(win32wnd == NULL) {
    1141             break;
    1142           }
    1143 
    1144       //TODO: Don't send WM_SETSELECTION to child window if frame already has selection
    1145       if(!(fsFocusChange & FC_NOSETSELECTION)) {
    1146             WinSendMsg(hwndGainFocus, WM_SETSELECTION, (MPARAM)1, (MPARAM)0);
    1147       }
    1148 
    1149       if(!(fsFocusChange & FC_NOSETFOCUS)) {
    1150             WinSendMsg(hwndGainFocus, WM_SETFOCUS, (MPARAM)hwndLoseFocus, (MPARAM)1);
    1151       }
    1152         }
    1153         else /* no usSetFocus */
    1154         {
    1155       if(!(fsFocusChange & FC_NOLOSEFOCUS)) {
    1156             WinSendMsg(hwndLoseFocus, WM_SETFOCUS, (MPARAM)hwndGainFocus, (MPARAM)0);
    1157       }
    1158       //TODO: Don't send WM_SETSELECTION to child window if frame already has selection
    1159       if(!(fsFocusChange & FC_NOLOSESELECTION)) {
    1160             WinSendMsg(hwndLoseFocus, WM_SETSELECTION, (MPARAM)0, (MPARAM)0);
    1161       }
    1162           //SvL: Check if window is still valid
    1163           win32wnd = Win32BaseWindow::GetWindowFromOS2Handle(hwnd);
    1164           if(win32wnd == NULL) {
    1165             break;
    1166           }
    1167 
    1168           Win32BaseWindow *winfocus = Win32BaseWindow::GetWindowFromOS2Handle(hwndGainFocus);
    1169           if(!(fsFocusChange & FC_NOLOSEACTIVE))
    1170           {
    1171             Win32BaseWindow *topparent = win32wnd->GetTopParent();
    1172 
    1173             if(!winfocus || (winfocus->GetTopParent() != topparent))
    1174             {
    1175               // PH 2000/09/01 Netscape 4.7
    1176               // check if topparent is valid
    1177               if (topparent)
    1178                 WinSendMsg(topparent->getOS2WindowHandle(), WM_ACTIVATE, (MPARAM)0, (MPARAM)hwndGainFocus);
    1179             }
    1180           }
    1181           //SvL: Check if window is still valid
    1182           win32wnd = Win32BaseWindow::GetWindowFromOS2Handle(hwnd);
    1183           if(win32wnd == NULL)
    1184             break;
    1185 
    1186           if(!(fsFocusChange & FC_NOSETACTIVE))
    1187           {
    1188             if(!winfocus || (winfocus->GetTopParent() != win32wnd->GetTopParent()))
    1189             {
    1190               if(winfocus)
    1191               {
    1192                 // PH 2000/09/01 Netscape 4.7
    1193                 // check if topparent is valid
    1194                 Win32BaseWindow *topparent = winfocus->GetTopParent();
    1195                 if (topparent)
    1196                   WinSendMsg(topparent->getOS2WindowHandle(), WM_ACTIVATE, (MPARAM)1, (MPARAM)hwndLoseFocus);
    1197               }
    1198               else
    1199                 WinSendMsg(hwndGainFocus, WM_ACTIVATE, (MPARAM)1, (MPARAM)hwndLoseFocus);
    1200             }
    1201           }
    1202         }
    1203 
    1204 
    1205 #ifdef DEBUG
    1206         dprintf(("PMFRAME:WM_FOCUSCHANGE (end) %x %x %x", win32wnd->getWindowHandle(), mp1, mp2));
    1207 #endif
    1208         break;
    1209     }
    1210 #endif
    1211 
    12121093#ifdef DEBUG
    12131094    case WM_FOCUSCHANGE:
     
    12371118            if (win32wnd->IsModalDialog())
    12381119            {
    1239                 Win32BaseWindow *topOwner = win32wnd->getOwner()->GetTopParent();
    1240 
    1241                 if (topOwner) WinSetWindowPos(topOwner->getOS2FrameWindowHandle(),hwnd,0,0,0,0,SWP_ZORDER);
     1120                if(win32wnd->getOwner()) {
     1121                    Win32BaseWindow *topOwner = Win32BaseWindow::GetWindowFromHandle(win32wnd->getOwner()->GetTopParent());
     1122 
     1123                    if (topOwner) {
     1124                        WinSetWindowPos(topOwner->getOS2FrameWindowHandle(),hwnd,0,0,0,0,SWP_ZORDER);
     1125                        RELEASE_WNDOBJ(topOwner);
     1126                    }
     1127                }
    12421128            }
    12431129        }
     
    13561242    }
    13571243    RestoreOS2TIB();
     1244    if(win32wnd) RELEASE_WNDOBJ(win32wnd);
    13581245    return (MRESULT)rc;
    13591246
    13601247RunDefFrameWndProc:
     1248    if(win32wnd) RELEASE_WNDOBJ(win32wnd);
    13611249    RestoreOS2TIB();
    13621250    return pfnFrameWndProc(hwnd, msg, mp1, mp2);
    13631251
    13641252RunDefWndProc:
     1253    if(win32wnd) RELEASE_WNDOBJ(win32wnd);
    13651254    RestoreOS2TIB();
    13661255    //calling WinDefWindowProc here breaks Opera hotlist window (WM_ADJUSTWINDOWPOS)
  • trunk/src/user32/pmwindow.h

    r3662 r5935  
    1 /* $Id: pmwindow.h,v 1.9 2000-06-07 14:51:27 sandervl Exp $ */
     1/* $Id: pmwindow.h,v 1.10 2001-06-09 14:50:19 sandervl Exp $ */
    22/*
    33 * Win32 Window Managment Code for OS/2
     
    88#ifndef __PMWINDOW_H__
    99#define __PMWINDOW_H__
     10
     11#include <win32wbase.h>
    1012
    1113#define WIN32_STDCLASS      "Win32WindowClass"
     
    2123extern ULONG ScreenBitsPerPel;
    2224
     25#define TFOS_LEFT                    0x0001
     26#define TFOS_TOP                     0x0002
     27#define TFOS_RIGHT                   0x0004
     28#define TFOS_BOTTOM                  0x0008
     29/* TF_MOVE = TF_LEFT | TF_TOP | TF_RIGHT | TF_BOTTOM */
     30#define TFOS_MOVE                    0x000F
     31
     32VOID FrameTrackFrame(Win32BaseWindow *win32wnd,DWORD flags);
     33
    2334#endif
  • trunk/src/user32/scroll.cpp

    r5769 r5935  
    1 /* $Id: scroll.cpp,v 1.38 2001-05-20 10:44:04 sandervl Exp $ */
     1/* $Id: scroll.cpp,v 1.39 2001-06-09 14:50:19 sandervl Exp $ */
    22/*
    33 * Scrollbar control
     
    2121#include "oslibwin.h"
    2222#include "initterm.h"
    23 #include "pmframe.h"
    2423
    2524#define DBG_LOCALLOG    DBG_scroll
     
    8483        case SB_HORZ:
    8584        case SB_VERT:
    86           win32wnd = Win32BaseWindow::GetWindowFromHandle(hwnd);
    87           if (!win32wnd) return NULL;
    88           return win32wnd->getScrollInfo(nBar);
     85        {
     86            SCROLLBAR_INFO *pInfo;
     87            win32wnd = Win32BaseWindow::GetWindowFromHandle(hwnd);
     88
     89            if (!win32wnd) return NULL;
     90            pInfo = win32wnd->getScrollInfo(nBar);
     91            RELEASE_WNDOBJ(win32wnd);
     92            return pInfo;
     93        }
    8994
    9095        case SB_CTL:
     
    133138          lprect->left--;
    134139          lprect->right++;
    135         } else if (win32wnd->getStyle() & WS_VSCROLL)
     140        }
     141        else
     142        if (win32wnd->getStyle() & WS_VSCROLL)
    136143            lprect->right++;
     144        RELEASE_WNDOBJ(win32wnd);
    137145        vertical = FALSE;
    138146        break;
     
    154162          lprect->top--;
    155163          lprect->bottom++;
    156         } else if (win32wnd->getStyle() & WS_HSCROLL)
     164        }
     165        else
     166        if (win32wnd->getStyle() & WS_HSCROLL)
    157167          lprect->bottom++;
     168        RELEASE_WNDOBJ(win32wnd);
    158169        vertical = TRUE;
    159170        break;
     
    14921503                    BOOL fShow  /* [I] TRUE = show, FALSE = hide  */)
    14931504{
    1494     Win32BaseWindow *win32wnd = Win32BaseWindow::GetWindowFromHandle(hwnd);
    14951505    BOOL fShowH = (nBar == SB_HORZ) ? fShow : 0;
    14961506    BOOL fShowV = (nBar == SB_VERT) ? fShow : 0;
     1507    DWORD dwStyle;
    14971508
    14981509    dprintf(("ShowScrollBar %04x %d %d\n", hwnd, nBar, fShow));
    1499     if (!win32wnd) return FALSE;
     1510    if (!IsWindow(hwnd)) return FALSE;
     1511
     1512    dwStyle = GetWindowLongA(hwnd, GWL_STYLE);
    15001513
    15011514    //CB: does Win32 send a WM_STYLECHANGED message?
     
    15101523        if (fShow)
    15111524        {
    1512             fShowH = !(win32wnd->getStyle() & WS_HSCROLL);
    1513             win32wnd->setStyle(win32wnd->getStyle() | WS_HSCROLL);
     1525            fShowH = !(dwStyle & WS_HSCROLL);
     1526            SetWindowLongA(hwnd, GWL_STYLE, dwStyle | WS_HSCROLL);
    15141527        }
    15151528        else  /* hide it */
    15161529        {
    1517             fShowH = (win32wnd->getStyle() & WS_HSCROLL);
    1518             win32wnd->setStyle(win32wnd->getStyle() & ~WS_HSCROLL);
     1530            fShowH = (dwStyle & WS_HSCROLL);
     1531            SetWindowLongA(hwnd, GWL_STYLE, dwStyle & ~WS_HSCROLL);
    15191532        }
    15201533        if( nBar == SB_HORZ )
     
    15281541        if (fShow)
    15291542        {
    1530             fShowV = !(win32wnd->getStyle() & WS_VSCROLL);
    1531             win32wnd->setStyle(win32wnd->getStyle() | WS_VSCROLL);
     1543            fShowV = !(dwStyle & WS_VSCROLL);
     1544            SetWindowLongA(hwnd, GWL_STYLE, dwStyle | WS_VSCROLL);
    15321545        }
    15331546        else  /* hide it */
    15341547        {
    1535             fShowV = (win32wnd->getStyle() & WS_VSCROLL);
    1536             win32wnd->setStyle(win32wnd->getStyle() & ~WS_VSCROLL);
     1548            fShowV = (dwStyle & WS_VSCROLL);
     1549            SetWindowLongA(hwnd, GWL_STYLE, dwStyle & ~WS_VSCROLL);
    15371550        }
    15381551        if ( nBar == SB_VERT )
  • trunk/src/user32/timer.cpp

    r3101 r5935  
    1 /* $Id: timer.cpp,v 1.12 2000-03-13 13:10:48 sandervl Exp $ */
     1/* $Id: timer.cpp,v 1.13 2001-06-09 14:50:20 sandervl Exp $ */
    22
    33/*
     
    113113    int i;
    114114    TIMER *pTimer;
     115    HWND hwndOS2;
    115116    Win32BaseWindow *wnd = Win32BaseWindow::GetWindowFromHandle(hwnd);
    116117
    117     if (hwnd && !wnd) return 0;
     118    if (hwnd && !wnd) {
     119        dprintf(("TIMER_SetTimer invalid window handle %x", hwnd));
     120        SetLastError(ERROR_INVALID_WINDOW_HANDLE_W);
     121        return 0;
     122    }
     123
     124    hwndOS2 = hwnd ? wnd->getOS2WindowHandle() : 0;
     125    if(wnd) RELEASE_WNDOBJ(wnd);
     126    wnd = NULL;
    118127
    119128    EnterCriticalSection ();
     
    147156        pTimer->id      = id;
    148157        pTimer->proc    = proc;
    149         pTimer->PMhwnd  = hwnd ? wnd->getOS2WindowHandle() : NULLHANDLE;
     158        pTimer->PMhwnd  = hwnd ? hwndOS2 : NULLHANDLE;
    150159        pTimer->PMid    = WinStartTimer (GetThreadHAB(), pTimer->PMhwnd,
    151160                                         i + 1, timeout);
     
    199208VOID TIMER_KillTimerFromWindow(HWND hwnd)
    200209{
    201     Win32BaseWindow *wnd = Win32BaseWindow::GetWindowFromHandle(hwnd);
    202210    int i;
    203211    TIMER * pTimer;
    204212
    205     if (hwnd && !wnd) return;
     213    if (!IsWindow(hwnd)) return;
    206214
    207215    EnterCriticalSection();
  • trunk/src/user32/win32class.cpp

    r5472 r5935  
    1 /* $Id: win32class.cpp,v 1.24 2001-04-04 09:01:25 sandervl Exp $ */
     1/* $Id: win32class.cpp,v 1.25 2001-06-09 14:50:20 sandervl Exp $ */
    22/*
    33 * Win32 Window Class Managment Code for OS/2
     
    1010 *       Must all be changed if we want to support global app classes
    1111 *       that can be used by other apps. (low priority)
     12 *
     13 * NOTE: To access a class object, you must call FindClass. This method
     14 *       increases the reference count of the object. When you're done
     15 *       with the object, you MUST call the release method!
     16 *       This mechanism prevents premature destruction of objects when there
     17 *       are still clients using it.
    1218 *
    1319 * Project Odin Software License can be found in LICENSE.TXT
     
    3440//Win32WndClass methods:
    3541//******************************************************************************
    36 Win32WndClass::Win32WndClass(WNDCLASSEXA *wndclass, BOOL fUnicode) : GenericObject(&wndclasses, OBJTYPE_CLASS)
     42Win32WndClass::Win32WndClass(WNDCLASSEXA *wndclass, BOOL fUnicode)
     43                  : GenericObject(&wndclasses, &critsect)
    3744{
    3845  isUnicode = fUnicode;
     
    134141  else  userClassBytes = NULL;
    135142
    136   cWindows = 0;
    137143  hIconSm  = wndclass->hIconSm;
    138144}
     
    142148{
    143149  if(classNameA) {
    144     dprintf(("Win32WndClass dtor, destroy class %s\n", classNameA));
     150      dprintf(("Win32WndClass dtor, destroy class %s\n", classNameA));
    145151  }
    146152
    147153  //SvL: Don't delete global classes
    148154  if(classNameA && !(windowStyle & CS_GLOBALCLASS)) {
    149     GlobalDeleteAtom(classAtom);
     155      GlobalDeleteAtom(classAtom);
    150156  }
    151157
     
    156162  if(classNameW)        free(classNameW);
    157163  if(menuNameA && HIWORD(menuNameA)) {
    158         free(menuNameA);
    159         assert(menuNameW);
    160         free(menuNameW);
     164      free(menuNameA);
     165      assert(menuNameW);
     166      free(menuNameW);
    161167  }
    162168}
     
    187193}
    188194//******************************************************************************
     195//Locates class in linked list and increases reference count (if found)
     196//Class object must be unreferenced after usage
    189197//******************************************************************************
    190198Win32WndClass *Win32WndClass::FindClass(HINSTANCE hInstance, LPSTR id)
    191199{
    192   enterMutex(OBJTYPE_CLASS);
     200  lock(&critsect);
    193201
    194202  Win32WndClass *wndclass = (Win32WndClass *)wndclasses;
    195203
    196204  if(wndclass == NULL) {
    197         leaveMutex(OBJTYPE_CLASS);
     205        unlock(&critsect);
    198206        return(NULL);
    199207  }
     
    202210//CB: read comment below!
    203211        if(lstrcmpiA(wndclass->classNameA, id) == 0 && wndclass->hInstance == hInstance) {
    204                 leaveMutex(OBJTYPE_CLASS);
     212                wndclass->addRef();
     213                unlock(&critsect);
    205214                return(wndclass);
    206215        }
     
    214223                                   wndclass->hInstance == hInstance)
    215224                                {
    216                                     leaveMutex(OBJTYPE_CLASS);
     225                                    wndclass->addRef();
     226                                    unlock(&critsect);
    217227                                    return(wndclass);
    218228                                }
     
    226236//CB: need more code to compare instance; convert 0 to exe module handle
    227237        if(wndclass->classAtom == (DWORD)id /*&& wndclass->hInstance == hInstance*/) {
    228                 leaveMutex(OBJTYPE_CLASS);
     238                wndclass->addRef();
     239                unlock(&critsect);
    229240                return(wndclass);
    230241        }
     
    233244                while(wndclass != NULL) {
    234245                        if(wndclass->classAtom == (DWORD)id /* && wndclass->hInstance == hInstance*/) {
    235                                 leaveMutex(OBJTYPE_CLASS);
     246                                wndclass->addRef();
     247                                unlock(&critsect);
    236248                                return(wndclass);
    237249                        }
     
    240252        }
    241253  }
    242   leaveMutex(OBJTYPE_CLASS);
     254  unlock(&critsect);
    243255  dprintf(("Class %X (inst %X) not found!", id, hInstance));
    244256  return(NULL);
    245257}
    246258//******************************************************************************
     259//Locates class in linked list and increases reference count (if found)
     260//Class object must be unreferenced after usage
    247261//******************************************************************************
    248262Win32WndClass *Win32WndClass::FindClass(HINSTANCE hInstance, LPWSTR id)
     
    252266
    253267  if(HIWORD(id)) {
    254     lpszClassName = UnicodeToAsciiString((LPWSTR)id);
    255   }
    256   else  lpszClassName = (LPSTR)id;
     268       lpszClassName = UnicodeToAsciiString((LPWSTR)id);
     269  }
     270  else lpszClassName = (LPSTR)id;
    257271
    258272  winclass = FindClass(hInstance, lpszClassName);
     
    551565  wndclass = FindClass(hinst, id);
    552566  if(wndclass) {
    553         if(wndclass->GetWindowCount() != 0) {
     567        if(wndclass->getRefCount() != 1) {
     568            wndclass->markDeleted();
     569            RELEASE_CLASSOBJ(wndclass);
    554570            dprintf2(("Win32WndClass::UnregisterClassA class %x still has windows!!", id));
    555571            SetLastError(ERROR_CLASS_HAS_WINDOWS);
    556572            return FALSE;
    557573        }
     574        RELEASE_CLASSOBJ(wndclass);
    558575        delete wndclass;
    559576        SetLastError(ERROR_SUCCESS);
     
    566583//******************************************************************************
    567584//******************************************************************************
    568 GenericObject *Win32WndClass::wndclasses = NULL;
     585GenericObject   *Win32WndClass::wndclasses = NULL;
     586CRITICAL_SECTION Win32WndClass::critsect   = {0};
  • trunk/src/user32/win32class.h

    r5242 r5935  
    1 /* $Id: win32class.h,v 1.14 2001-02-22 10:37:30 sandervl Exp $ */
     1/* $Id: win32class.h,v 1.15 2001-06-09 14:50:20 sandervl Exp $ */
    22/*
    33 * Win32 Window Class Managment Code for OS/2
     
    1212
    1313#include <gen_object.h>
     14
     15#define RELEASE_CLASSOBJ(a)       { a->release(); a = NULL; }
    1416
    1517class Win32WndClass : public GenericObject
     
    5759          void  setMenuName(LPSTR newMenuName);
    5860
    59           void  IncreaseWindowCount()   { cWindows++; };
    60           void  DecreaseWindowCount()   { cWindows--; };
    61           DWORD GetWindowCount()        { return cWindows; };
    62 
    6361          BOOL  hasClassName(LPSTR classname, BOOL fUnicode = FALSE);
    6462
     
    6765 static   BOOL  UnregisterClassA(HINSTANCE hinst, LPSTR id);
    6866
     67 //Locates class in linked list and increases reference count (if found)
     68 //Class object must be unreferenced after usage
    6969 static Win32WndClass *FindClass(HINSTANCE hinst, LPSTR id);
    7070 static Win32WndClass *FindClass(HINSTANCE hinst, LPWSTR id);
     
    9797 ULONG          processId;
    9898
    99  //nr of windows created with this class
    100  ULONG          cWindows;
    101 
    10299 static GenericObject *wndclasses;
     100 static CRITICAL_SECTION critsect;
    103101};
    104102
  • trunk/src/user32/win32dlg.cpp

    r5802 r5935  
    1 /* $Id: win32dlg.cpp,v 1.65 2001-05-25 16:59:11 sandervl Exp $ */
     1/* $Id: win32dlg.cpp,v 1.66 2001-06-09 14:50:20 sandervl Exp $ */
    22/*
    33 * Win32 Dialog Code for OS/2
     
    3939Win32Dialog::Win32Dialog(HINSTANCE hInst, LPCSTR dlgTemplate, HWND owner,
    4040                         DLGPROC dlgProc, LPARAM param, BOOL isUnicode)
    41                     : Win32BaseWindow(OBJTYPE_DIALOG)
     41                    : Win32BaseWindow()
    4242{
    4343  RECT rect;
     
    312312    /* Owner must be a top-level window */
    313313    if(getOwner() == NULL) {
     314         windowDesktop->addRef();
    314315         topOwner = windowDesktop;
    315316    }
    316     else topOwner = getOwner()->GetTopParent();
     317    else topOwner = GetWindowFromHandle(getOwner()->GetTopParent());
    317318
    318319    if(topOwner == NULL) {
     
    415416        topOwner->setOS2HwndModalDialog(hwndOldDialog);
    416417        if (!bOldOwner) topOwner->EnableWindow(TRUE);
     418        RELEASE_WNDOBJ(topOwner);
    417419    }
    418420    retval = idResult;
     
    869871                    CONTROLS_IsControl( wndFocus->getParent(), COMBOBOX_CONTROL ))
    870872                    wndFocus->SendMessageA(CB_SHOWDROPDOWN, FALSE, 0 );
     873                RELEASE_WNDOBJ(wndFocus);
    871874            }
    872875        }
  • trunk/src/user32/win32dlg.h

    r4686 r5935  
    1 /* $Id: win32dlg.h,v 1.12 2000-11-24 10:30:36 sandervl Exp $ */
     1/* $Id: win32dlg.h,v 1.13 2001-06-09 14:50:21 sandervl Exp $ */
    22/*
    33 * Win32 Dialog Code for OS/2
     
    6767       LRESULT  DefDlgProcW(UINT Msg, WPARAM wParam, LPARAM lParam);
    6868
    69 Win32BaseWindow *getDlgItem(int id) { return FindWindowById(id); };
     69         HWND   getDlgItem(int id) { return FindWindowById(id); };
    7070
    7171         BOOL   endDialog(int retval);
  • trunk/src/user32/win32wbase.cpp

    r5810 r5935  
    1 /* $Id: win32wbase.cpp,v 1.259 2001-05-27 19:01:35 sandervl Exp $ */
     1/* $Id: win32wbase.cpp,v 1.260 2001-06-09 14:50:21 sandervl Exp $ */
    22/*
    33 * Win32 Window Base Class for OS/2
     
    1414 *
    1515 * TODO: Not thread/process safe
     16 *
     17 * NOTE: To access a window object, you must call GetWindowFromOS2Handle or
     18 *       GetWindowFromHandle. Both these methods increase the reference count
     19 *       of the object. When you're done with the object, you MUST call
     20 *       the release method!
     21 *       This mechanism prevents premature destruction of objects when there
     22 *       are still clients using it.
    1623 *
    1724 * NOTE: Client rectangle always relative to frame window
     
    6673//******************************************************************************
    6774//******************************************************************************
    68 Win32BaseWindow::Win32BaseWindow(DWORD objType) : GenericObject(&windows, objType)
     75Win32BaseWindow::Win32BaseWindow()
     76                     : GenericObject(&windows, &critsect), ChildWindow(&critsect)
    6977{
    7078  Init();
     
    7280//******************************************************************************
    7381//******************************************************************************
    74 Win32BaseWindow::Win32BaseWindow(HWND hwndOS2, ULONG reserved) : GenericObject(&windows, OBJTYPE_WINDOW), ChildWindow()
     82Win32BaseWindow::Win32BaseWindow(HWND hwndOS2, ULONG reserved)
     83                     : GenericObject(&windows, &critsect), ChildWindow(&critsect)
    7584{
    7685  Init();
     
    8089//******************************************************************************
    8190Win32BaseWindow::Win32BaseWindow(CREATESTRUCTA *lpCreateStructA, ATOM classAtom, BOOL isUnicode)
    82                         : GenericObject(&windows, OBJTYPE_WINDOW), ChildWindow()
     91                     : GenericObject(&windows, &critsect), ChildWindow(&critsect)
    8392{
    8493  Init();
     
    115124  nrUserWindowBytes= 0;
    116125
    117   magic            = WIN32PM_MAGIC;
    118126  OS2Hwnd          = 0;
    119127  OS2HwndFrame     = 0;
     
    179187Win32BaseWindow::~Win32BaseWindow()
    180188{
     189    if(getRefCount() < 0) {
     190        DebugInt3();
     191    }
     192
    181193    if(hTaskList) {
    182194        OSLibWinRemoveFromTasklist(hTaskList);
     
    187199    OSLibWinSetWindowULong(OS2Hwnd, OFFSET_WIN32PM_MAGIC, 0);
    188200
    189     if(!fDestroyAll && getParent() && getParent()->getFirstChild() == this && getNextChild() == NULL)
    190     {
    191         //if we're the last child that's being destroyed and our
    192         //parent window was also destroyed, then we delete the parent object
    193         if(getParent()->IsWindowDestroyed())
    194         {
    195             dprintf(("Last Child (%x) destroyed, get rid of our parent window (%x)", getWindowHandle(), getParent()->getWindowHandle()));
    196             delete getParent();
    197             setParent(NULL);  //or else we'll crash in the dtor of the ChildWindow class
    198         }
    199     }
    200     else
    201201    if(fDestroyAll) {
    202202        dprintf(("Destroying window %x %s", getWindowHandle(), windowNameA));
     
    206206    /* Decrement class window counter */
    207207    if(windowClass) {
    208         windowClass->DecreaseWindowCount();
     208        RELEASE_CLASSOBJ(windowClass);
    209209    }
    210210
     
    236236    if(propertyList) {
    237237        removeWindowProps();
     238    }
     239    Win32BaseWindow *wndparent = (Win32BaseWindow *)ChildWindow::getParentOfChild();
     240    if(wndparent) {
     241        RELEASE_WNDOBJ(wndparent);
     242    }
     243    if(windowClass) {
     244        RELEASE_CLASSOBJ(windowClass);
    238245    }
    239246}
     
    287294            if (!window->IsWindow() )
    288295            {
     296                    RELEASE_WNDOBJ(window);
    289297                    dprintf(("Bad parent %04x\n", cs->hwndParent ));
    290298                    SetLastError(ERROR_INVALID_PARAMETER);
    291299                    return FALSE;
    292300            }
     301            RELEASE_WNDOBJ(window);
    293302            /* Windows does this for overlapped windows
    294303             * (I don't know about other styles.) */
     
    314323        return 0;
    315324    }
    316     /* Increment class window counter */
    317     windowClass->IncreaseWindowCount();
    318325
    319326#ifdef DEBUG
     
    417424        else
    418425        {
    419             owner = GetWindowFromHandle(cs->hwndParent)->GetTopParent();
     426            owner = GetWindowFromHandle(GetWindowFromHandle(cs->hwndParent)->GetTopParent());
    420427            if(owner == NULL)
    421428            {
     
    491498    fNoSizeMsg = TRUE;
    492499
    493     if(OSLibWinSetWindowULong(OS2Hwnd, OFFSET_WIN32WNDPTR, (ULONG)this) == FALSE) {
     500    if(OSLibWinSetWindowULong(OS2Hwnd, OFFSET_WIN32WNDPTR, getWindowHandle()) == FALSE) {
    494501        dprintf(("WM_CREATE: WinSetWindowULong %X failed!!", OS2Hwnd));
    495502        SetLastError(ERROR_OUTOFMEMORY); //TODO: Better error
     
    827834    SendInternalMessageA(WM_NCDESTROY, 0, 0);
    828835
    829     TIMER_KillTimerFromWindow(OS2Hwnd);
    830 
    831     if(getFirstChild() == NULL && fCreationFinished) {
     836    TIMER_KillTimerFromWindow(getWindowHandle());
     837
     838    if(getRefCount() == 0 && getFirstChild() == NULL && fCreationFinished) {
    832839        delete this;
    833840    }
    834841    else {
    835842        //make sure no message can ever arrive for this window again (PM or from other win32 windows)
     843        dprintf(("Mark window %x (%x) as deleted", getWindowHandle(), this));
     844        markDeleted();
    836845        OSLibWinSetWindowULong(OS2Hwnd, OFFSET_WIN32WNDPTR, 0);
    837846        OSLibWinSetWindowULong(OS2Hwnd, OFFSET_WIN32PM_MAGIC, 0);
     
    10281037
    10291038        /* Activate the window if needed */
    1030         hwndTop = (GetTopParent()) ? GetTopParent()->getWindowHandle() : 0;
     1039        hwndTop = GetTopParent();
    10311040
    10321041        HWND hwndActive = GetActiveWindow();
     
    16731682        if(wParam == VK_F4) /* try to close the window */
    16741683        {
    1675             Win32BaseWindow *window = GetTopParent();
     1684            Win32BaseWindow *window = GetWindowFromHandle(GetTopParent());
    16761685            if(window && !(window->getClass()->getStyle() & CS_NOCLOSE))
    16771686                PostMessageA(window->getWindowHandle(), WM_SYSCOMMAND, SC_CLOSE, 0);
     1687            if(window) RELEASE_WNDOBJ(window);
    16781688            return 0;
    16791689        }
     
    27492759        OSLibWinSetParent(getOS2FrameWindowHandle(), OSLIB_HWND_DESKTOP);
    27502760
    2751     //TODO: Send WM_STYLECHANGED msg?
     2761        //TODO: Send WM_STYLECHANGED msg?
    27522762        setStyle(getStyle() & ~WS_CHILD);
    27532763        setWindowId(0);
     
    27902800        topwindow = GetWindowFromOS2FrameHandle(hwndTop);
    27912801        if(topwindow) {
    2792             return topwindow->getWindowHandle();
     2802            hwndTop = topwindow->getWindowHandle();
     2803            RELEASE_WNDOBJ(topwindow);
     2804            return hwndTop;
    27932805        }
    27942806        return 0;
     
    27972809        topwindow = GetWindowFromOS2FrameHandle(hwndTop);
    27982810        if(topwindow) {
    2799             return topwindow->getWindowHandle();
     2811            hwndTop = topwindow->getWindowHandle();
     2812            RELEASE_WNDOBJ(topwindow);
     2813            return hwndTop;
    28002814        }
    28012815        hwndTop = OSLibWinQueryWindow(hwndTop, QWOS_NEXT);
     
    28072821// Get the top-level parent for a child window.
    28082822//******************************************************************************
    2809 Win32BaseWindow *Win32BaseWindow::GetTopParent()
     2823HWND Win32BaseWindow::GetTopParent()
    28102824{
    28112825 Win32BaseWindow *window = this;
    2812 
     2826 HWND             hwndTopParent = 0;
     2827
     2828    lock();
    28132829    while(window && (window->getStyle() & WS_CHILD))
    28142830    {
    28152831        window = window->getParent();
    28162832    }
    2817     return window;
     2833    if(window) {
     2834        hwndTopParent = window->getWindowHandle();
     2835    }
     2836    unlock();
     2837    return hwndTopParent;
    28182838}
    28192839//******************************************************************************
     
    29072927//******************************************************************************
    29082928//******************************************************************************
    2909 Win32BaseWindow *Win32BaseWindow::FindWindowById(int id)
    2910 {
     2929HWND Win32BaseWindow::FindWindowById(int id)
     2930{
     2931    lock();
    29112932    for (Win32BaseWindow *child = (Win32BaseWindow *)getFirstChild(); child; child = (Win32BaseWindow *)child->getNextChild())
    29122933    {
    29132934        if (child->getWindowId() == id)
    29142935        {
    2915             return child;
    2916         }
    2917     }
     2936            unlock();
     2937            return child->getWindowHandle();
     2938        }
     2939    }
     2940    unlock();
    29182941    return 0;
    29192942}
     
    29873010                    OSLibWinEndEnumWindows(henum);
    29883011                    dprintf(("FindWindowEx: Found window %x", wnd->getWindowHandle()));
    2989                     return wnd->getWindowHandle();
     3012                    HWND hwndret = wnd->getWindowHandle();
     3013                    RELEASE_WNDOBJ(wnd);
     3014                    return hwndret;
    29903015                }
     3016                RELEASE_WNDOBJ(wnd);
    29913017            }
    29923018            hwnd = OSLibWinGetNextWindow(henum);
     
    30143040            if(window) {
    30153041                 hwndRelated = window->getWindowHandle();
     3042                 RELEASE_WNDOBJ(window);
    30163043            }
    30173044            else hwndRelated = 0;
     
    30313058            if(window) {
    30323059                 hwndRelated = window->getWindowHandle();
     3060                 RELEASE_WNDOBJ(window);
    30333061            }
    30343062            else hwndRelated = 0;
     
    30463074            if(window) {
    30473075                 hwndRelated = window->getWindowHandle();
     3076                 RELEASE_WNDOBJ(window);
    30483077            }
    30493078            else hwndRelated = 0;
     
    30613090            if(window) {
    30623091                 hwndRelated = window->getWindowHandle();
     3092                 RELEASE_WNDOBJ(window);
    30633093            }
    30643094            else hwndRelated = 0;
     
    30813111        if(window) {
    30823112             hwndRelated = window->getWindowHandle();
     3113             RELEASE_WNDOBJ(window);
    30833114        }
    30843115        else hwndRelated = 0;
     
    31743205{
    31753206 HWND          hwndActive;
    3176  Win32BaseWindow  *win32wnd;
    3177  ULONG         magic;
    31783207
    31793208  hwndActive = OSLibWinQueryActiveWindow();
     
    33773406                }
    33783407                oldval = (LONG)WINPROC_GetProc(win32wndproc, (fUnicode) ? WIN_PROC_32W : WIN_PROC_32A);
     3408                dprintf(("SetWindowLong GWL_WNDPROC %x old %x new style %x", getWindowHandle(), oldval, value));
    33793409                WINPROC_SetProc((HWINDOWPROC *)&win32wndproc, (WNDPROC)value, type, WIN_PROC_WINDOW);
    33803410                break;
     
    35003530//******************************************************************************
    35013531//******************************************************************************
    3502 Win32BaseWindow *Win32BaseWindow::GetWindowFromHandle(HWND hwnd)
    3503 {
    3504  Win32BaseWindow *window;
    3505 
    3506     if(HwGetWindowHandleData(hwnd, (DWORD *)&window) == TRUE) {
    3507          return window;
    3508     }
    3509 //    dprintf2(("Win32BaseWindow::GetWindowFromHandle: not a win32 window %x", hwnd));
    3510     return NULL;
    3511 }
    3512 //******************************************************************************
    3513 //******************************************************************************
    3514 Win32BaseWindow *Win32BaseWindow::GetWindowFromOS2Handle(HWND hwnd)
    3515 {
    3516  Win32BaseWindow *win32wnd;
    3517  DWORD        magic;
    3518 
    3519     if(hwnd == OSLIB_HWND_DESKTOP)
    3520     {
    3521         return windowDesktop;
    3522     }
    3523 
    3524     win32wnd = (Win32BaseWindow *)OSLibWinGetWindowULong(hwnd, OFFSET_WIN32WNDPTR);
    3525     magic    = OSLibWinGetWindowULong(hwnd, OFFSET_WIN32PM_MAGIC);
    3526 
    3527     if(win32wnd && CheckMagicDword(magic)) {
    3528         return win32wnd;
    3529     }
    3530 //  dprintf2(("Win32BaseWindow::GetWindowFromOS2Handle: not an Odin os2 window %x", hwnd));
    3531     return 0;
    3532 }
    3533 //******************************************************************************
    3534 //******************************************************************************
    3535 Win32BaseWindow *Win32BaseWindow::GetWindowFromOS2FrameHandle(HWND hwnd)
    3536 {
    3537     return GetWindowFromOS2Handle(OSLibWinWindowFromID(hwnd,OSLIB_FID_CLIENT));
    3538 }
    3539 //******************************************************************************
    3540 //******************************************************************************
    35413532HWND Win32BaseWindow::getNextDlgGroupItem(HWND hwndCtrl, BOOL fPrevious)
    35423533{
     
    36223613    return retvalue;
    36233614}
     3615//******************************************************************************
     3616//Locates window in linked list and increases reference count (if found)
     3617//Window object must be unreferenced after usage
     3618//******************************************************************************
     3619Win32BaseWindow *Win32BaseWindow::GetWindowFromHandle(HWND hwnd)
     3620{
     3621 Win32BaseWindow *window;
     3622
     3623    lock(&critsect);
     3624    if(HwGetWindowHandleData(hwnd, (DWORD *)&window) == TRUE) {
     3625         if(window) {
     3626////             dprintf(("addRef %x; refcount %d", hwnd, window->getRefCount()+1));
     3627             window->addRef();
     3628         }
     3629         unlock(&critsect);
     3630         return window;
     3631    }
     3632    unlock(&critsect);
     3633//    dprintf2(("Win32BaseWindow::GetWindowFromHandle: not a win32 window %x", hwnd));
     3634    return NULL;
     3635}
     3636//******************************************************************************
     3637//Locates window in linked list and increases reference count (if found)
     3638//Window object must be unreferenced after usage
     3639//******************************************************************************
     3640Win32BaseWindow *Win32BaseWindow::GetWindowFromOS2Handle(HWND hwndOS2)
     3641{
     3642 DWORD            magic;
     3643 HWND             hwnd;
     3644
     3645    if(hwndOS2 == OSLIB_HWND_DESKTOP)
     3646    {
     3647        windowDesktop->addRef();
     3648        return windowDesktop;
     3649    }
     3650
     3651    hwnd  = (HWND)OSLibWinGetWindowULong(hwndOS2, OFFSET_WIN32WNDPTR);
     3652    magic = OSLibWinGetWindowULong(hwndOS2, OFFSET_WIN32PM_MAGIC);
     3653
     3654    if(hwnd && CheckMagicDword(magic)) {
     3655        return GetWindowFromHandle(hwnd);
     3656    }
     3657//  dprintf2(("Win32BaseWindow::GetWindowFromOS2Handle: not an Odin os2 window %x", hwndOS2));
     3658    return 0;
     3659}
     3660//******************************************************************************
     3661//Locates window in linked list and increases reference count (if found)
     3662//Window object must be unreferenced after usage
     3663//******************************************************************************
     3664Win32BaseWindow *Win32BaseWindow::GetWindowFromOS2FrameHandle(HWND hwnd)
     3665{
     3666    return GetWindowFromOS2Handle(OSLibWinWindowFromID(hwnd,OSLIB_FID_CLIENT));
     3667}
     3668//******************************************************************************
     3669//******************************************************************************
     3670HWND WIN32API Win32ToOS2Handle(HWND hwnd)
     3671{
     3672    HWND hwndOS2;
     3673
     3674    Win32BaseWindow *window = Win32BaseWindow::GetWindowFromHandle(hwnd);
     3675
     3676    if(window) {
     3677            hwndOS2 = window->getOS2WindowHandle();
     3678            RELEASE_WNDOBJ(window);
     3679            return hwndOS2;
     3680    }
     3681//    dprintf2(("Win32BaseWindow::Win32ToOS2Handle: not a win32 window %x", hwnd));
     3682    return hwnd;
     3683}
     3684//******************************************************************************
     3685//******************************************************************************
     3686HWND WIN32API OS2ToWin32Handle(HWND hwnd)
     3687{
     3688    Win32BaseWindow *window = Win32BaseWindow::GetWindowFromOS2Handle(hwnd);
     3689    HWND hwndWin32;
     3690
     3691    if(window) {
     3692            hwndWin32 = window->getWindowHandle();
     3693            RELEASE_WNDOBJ(window);
     3694            return hwndWin32;
     3695    }
     3696    window = Win32BaseWindow::GetWindowFromOS2FrameHandle(hwnd);
     3697    if(window) {
     3698            hwndWin32 = window->getWindowHandle();
     3699            RELEASE_WNDOBJ(window);
     3700            return hwndWin32;
     3701    }
     3702
     3703//    dprintf2(("Win32BaseWindow::OS2ToWin32Handle: not a win32 window %x", hwnd));
     3704    return 0;
     3705//    else    return hwnd;    //OS/2 window handle
     3706}
     3707//******************************************************************************
     3708//******************************************************************************
     3709GenericObject   *Win32BaseWindow::windows  = NULL;
     3710CRITICAL_SECTION Win32BaseWindow::critsect = {0};
     3711
    36243712//******************************************************************************
    36253713//******************************************************************************
     
    37183806//******************************************************************************
    37193807//******************************************************************************
    3720 HWND WIN32API Win32ToOS2Handle(HWND hwnd)
    3721 {
    3722     Win32BaseWindow *window = Win32BaseWindow::GetWindowFromHandle(hwnd);
    3723 
    3724     if(window) {
    3725             return window->getOS2WindowHandle();
    3726     }
    3727 //    dprintf2(("Win32BaseWindow::Win32ToOS2Handle: not a win32 window %x", hwnd));
    3728     return hwnd;
    3729 }
    3730 //******************************************************************************
    3731 //******************************************************************************
    3732 HWND WIN32API OS2ToWin32Handle(HWND hwnd)
    3733 {
    3734     Win32BaseWindow *window = Win32BaseWindow::GetWindowFromOS2Handle(hwnd);
    3735 
    3736     if(window) {
    3737             return window->getWindowHandle();
    3738     }
    3739     window = Win32BaseWindow::GetWindowFromOS2FrameHandle(hwnd);
    3740     if(window) {
    3741             return window->getWindowHandle();
    3742     }
    3743 
    3744 //    dprintf2(("Win32BaseWindow::OS2ToWin32Handle: not a win32 window %x", hwnd));
    3745     return 0;
    3746 //    else    return hwnd;    //OS/2 window handle
    3747 }
    3748 //******************************************************************************
    3749 //******************************************************************************
    3750 
    3751 GenericObject *Win32BaseWindow::windows  = NULL;
  • trunk/src/user32/win32wbase.h

    r5805 r5935  
    1 /* $Id: win32wbase.h,v 1.117 2001-05-25 19:59:30 sandervl Exp $ */
     1/* $Id: win32wbase.h,v 1.118 2001-06-09 14:50:21 sandervl Exp $ */
    22/*
    33 * Win32 Window Base Class for OS/2
     
    3535#define CheckMagicDword(a)      (a==WIN32PM_MAGIC)
    3636
     37#define RELEASE_WNDOBJ(a)       { a->release(); a = NULL; }
     38
    3739typedef struct {
    3840        USHORT           cb;
     
    109111{
    110112public:
    111         DWORD   magic;
    112 
    113                 Win32BaseWindow(DWORD objType);
     113                Win32BaseWindow();
    114114                Win32BaseWindow(CREATESTRUCTA *lpCreateStructA, ATOM classAtom, BOOL isUnicode);
    115115                Win32BaseWindow(HWND hwndOS2, ULONG reserved);
     
    227227         BOOL   GetWindowPlacement(LPWINDOWPLACEMENT winpos);
    228228         BOOL   ScrollWindow(int dx, int dy);
    229          BOOL   DestroyWindow();
     229virtual  BOOL   DestroyWindow();
    230230         HWND   SetActiveWindow();
    231231         BOOL   DeactivateChildWindow();
     
    236236
    237237         HWND   GetTopWindow();
    238 Win32BaseWindow *GetTopParent();
     238         HWND   GetTopParent();
    239239
    240240         HWND   GetWindow(UINT uCmd);
     
    295295         void   NotifyParent(UINT Msg, WPARAM wParam, LPARAM lParam);
    296296
    297 Win32BaseWindow *FindWindowById(int id);
     297           HWND FindWindowById(int id);
    298298
    299299    static HWND FindWindowEx(HWND hwndParent, HWND hwndChildAfter, ATOM atom, LPSTR lpszWindow);
     
    316316         INT    enumPropsExW(PROPENUMPROCEXW func, LPARAM lParam);
    317317
     318//Locates window in linked list and increases reference count (if found)
     319//Window object must be unreferenced after usage
    318320static Win32BaseWindow *GetWindowFromHandle(HWND hwnd);
    319321static Win32BaseWindow *GetWindowFromOS2Handle(HWND hwnd);
     
    351353        ULONG   dwIDMenu;               //GWL_ID
    352354        ULONG   userData;               //GWL_USERDATA
     355
    353356
    354357         HWND   hwndLinkAfter;
     
    416419
    417420static GenericObject *windows;
     421static CRITICAL_SECTION  critsect;
    418422
    419423private:
  • trunk/src/user32/win32wbasenonclient.cpp

    r5404 r5935  
    1 /* $Id: win32wbasenonclient.cpp,v 1.30 2001-03-30 11:14:36 sandervl Exp $ */
     1/* $Id: win32wbasenonclient.cpp,v 1.31 2001-06-09 14:50:22 sandervl Exp $ */
    22/*
    33 * Win32 Window Base Class for OS/2 (non-client methods)
     
    2525#include <win32wbase.h>
    2626#include "wndmsg.h"
    27 #include "pmframe.h"
    2827#include "oslibwin.h"
    2928#include "oslibmsg.h"
     
    3736#include "win32wdesktop.h"
    3837#include "controls.h"
     38#include "pmwindow.h"
    3939#include <menu.h>
    4040
     
    262262    case HTCAPTION:
    263263    {
    264       Win32BaseWindow *topparent = GetTopParent();
     264      HWND hwndTopParent = GetTopParent();
    265265
    266266        if((getStyle() & WS_CHILD) && !(getExStyle() & WS_EX_MDICHILD))
    267267        {
    268             if (GetActiveWindow() != topparent->getWindowHandle())
     268            if (GetActiveWindow() != hwndTopParent)
    269269            {
    270270                //SvL: Calling topparent->SetActiveWindow() causes focus problems
    271                 topparent->SetActiveWindow();
     271                ::SetActiveWindow(hwndTopParent);
    272272////            OSLibWinSetFocus(topparent->getOS2WindowHandle());
    273273            }
    274             if (GetActiveWindow() == topparent->getWindowHandle())
     274            if (GetActiveWindow() == hwndTopParent)
    275275                 SendInternalMessageA(WM_SYSCOMMAND,SC_MOVE+HTCAPTION,lParam);
    276             else dprintf(("ACtive window (%x) != toplevel wnd %x", OSLibWinQueryActiveWindow(), topparent->getWindowHandle()));
     276            else dprintf(("ACtive window (%x) != toplevel wnd %x", OSLibWinQueryActiveWindow(), hwndTopParent));
    277277        }
    278278        else {
    279279            SetActiveWindow();
    280             if (GetActiveWindow() == topparent->getWindowHandle())
     280            if (GetActiveWindow() == hwndTopParent)
    281281                 SendInternalMessageA(WM_SYSCOMMAND,SC_MOVE+HTCAPTION,lParam);
    282282            else dprintf(("ACtive window (%x) != wnd %x", OSLibWinQueryActiveWindow(), getWindowHandle()));
  • trunk/src/user32/win32wbasepos.cpp

    r5777 r5935  
    1 /* $Id: win32wbasepos.cpp,v 1.25 2001-05-22 09:33:16 sandervl Exp $ */
     1/* $Id: win32wbasepos.cpp,v 1.26 2001-06-09 14:50:22 sandervl Exp $ */
    22/*
    33 * Win32 Window Base Class for OS/2 (nonclient/position methods)
     
    3535#include "win32wndhandle.h"
    3636#include "dc.h"
    37 #include "pmframe.h"
    3837#include "win32wdesktop.h"
    3938#include <win\hook.h>
     
    256255                        break;  /* There's a window in there */
    257256                }
     257                RELEASE_WNDOBJ(child);
    258258                hwndChild = GetWindow(hwndChild, GW_HWNDNEXT);
    259259            }
  • trunk/src/user32/win32wdesktop.cpp

    r5685 r5935  
    1 /* $Id: win32wdesktop.cpp,v 1.16 2001-05-11 08:39:46 sandervl Exp $ */
     1/* $Id: win32wdesktop.cpp,v 1.17 2001-06-09 14:50:22 sandervl Exp $ */
    22/*
    33 * Win32 Desktop Window for OS/2
     
    4444//******************************************************************************
    4545//******************************************************************************
    46 Win32Desktop::Win32Desktop() : Win32BaseWindow(OBJTYPE_WINDOW)
     46Win32Desktop::Win32Desktop() : Win32BaseWindow()
    4747{
    4848  rectWindow.left   = 0;
     
    8686{
    8787  return TRUE; //of course we succeeded
     88}
     89//******************************************************************************
     90//******************************************************************************
     91BOOL Win32Desktop::DestroyWindow()
     92{
     93  dprintf(("WARNING: can't destroy desktop window!!"));
     94  return FALSE;
    8895}
    8996//******************************************************************************
  • trunk/src/user32/win32wdesktop.h

    r3663 r5935  
    1 /* $Id: win32wdesktop.h,v 1.7 2000-06-07 21:45:52 sandervl Exp $ */
     1/* $Id: win32wdesktop.h,v 1.8 2001-06-09 14:50:22 sandervl Exp $ */
    22/*
    33 * Win32 Desktop Window for OS/2
     
    2424
    2525 virtual BOOL   EnableWindow(BOOL fEnable);
    26 
     26 virtual BOOL   DestroyWindow();
    2727virtual  BOOL   isDesktopWindow();
    2828
  • trunk/src/user32/win32wmdichild.cpp

    r4573 r5935  
    1 /* $Id: win32wmdichild.cpp,v 1.25 2000-11-09 18:15:22 sandervl Exp $ */
     1/* $Id: win32wmdichild.cpp,v 1.26 2001-06-09 14:50:23 sandervl Exp $ */
    22/*
    33 * Win32 MDI Child Window Class for OS/2
     
    4646//******************************************************************************
    4747Win32MDIChildWindow::Win32MDIChildWindow(CREATESTRUCTA *lpCreateStructA, ATOM classAtom, BOOL fUnicode)
    48                     : Win32BaseWindow(OBJTYPE_WINDOW)
     48                    : Win32BaseWindow()
    4949{
    5050    isUnicode = fUnicode;
     
    7373        DefWindowProcA(Msg, wParam, lParam);
    7474        menuModifyItem();
    75         if( client->getMaximizedChild() == this )
     75        if( client->getMaximizedChild() == getWindowHandle() )
    7676                client->updateFrameText(MDI_REPAINTFRAME, NULL);
    7777        return 0;
     
    9393
    9494    case WM_SETFOCUS:
    95         if(client->getActiveChild() != this )
     95        if(client->getActiveChild() != getWindowHandle() )
    9696            client->childActivate(this);
    9797        break;
     
    108108        {
    109109        case SC_MOVE:
    110             if( client->getMaximizedChild() == this)
     110            if( client->getMaximizedChild() == getWindowHandle())
    111111            {
    112112                return 0;
     
    119119
    120120        case SC_MAXIMIZE:
    121             if( client->getMaximizedChild() == this)
     121            if( client->getMaximizedChild() == getWindowHandle())
    122122            {
    123123                  return client->SendMessageA(Msg, wParam, lParam);
     
    145145    case WM_SIZE:
    146146        /* do not change */
    147         if( client->getActiveChild() == this && wParam != SIZE_MAXIMIZED )
     147        if( client->getActiveChild() == getWindowHandle() && wParam != SIZE_MAXIMIZED )
    148148        {
    149149            client->setMaximizedChild(NULL);
    150             client->restoreFrameMenu(this);
     150            client->restoreFrameMenu(getWindowHandle());
    151151            client->updateFrameText(MDI_REPAINTFRAME, NULL );
    152152        }
     
    154154        if( wParam == SIZE_MAXIMIZED )
    155155        {
    156             Win32MDIChildWindow *maxChild = client->getMaximizedChild();
    157 
    158             if( maxChild == this ) break;
     156            HWND maxChild = client->getMaximizedChild();
     157
     158            if( maxChild == getWindowHandle() ) break;
    159159
    160160            if( maxChild)
    161161            {
    162                 maxChild->SendMessageA(WM_SETREDRAW, FALSE, 0L );
     162                ::SendMessageA(maxChild, WM_SETREDRAW, FALSE, 0L );
    163163                client->restoreFrameMenu(maxChild);
    164                 maxChild->ShowWindow(SW_SHOWNOACTIVATE);
    165 
    166                 maxChild->SendMessageA(WM_SETREDRAW, TRUE, 0L );
     164                ::ShowWindow(maxChild, SW_SHOWNOACTIVATE);
     165
     166                ::SendMessageA(maxChild, WM_SETREDRAW, TRUE, 0L );
    167167            }
    168168
    169             client->setMaximizedChild(this);
    170             client->setActiveChild(this);
    171 
    172             client->augmentFrameMenu(this);
     169            client->setMaximizedChild(getWindowHandle());
     170            client->setActiveChild(getWindowHandle());
     171
     172            client->augmentFrameMenu(getWindowHandle());
    173173
    174174            client->updateFrameText(MDI_REPAINTFRAME, NULL );
     
    221221        DefWindowProcW(Msg, wParam, lParam);
    222222        menuModifyItem();
    223         if( client->getMaximizedChild() == this )
     223        if( client->getMaximizedChild() == getWindowHandle() )
    224224                client->updateFrameText(MDI_REPAINTFRAME, NULL );
    225225
     
    257257  WORD         wIDmenu = client->getFirstChildId() + client->getNrOfChildren();
    258258  char         lpstrDef[]="junk!";
    259   Win32MDIChildWindow *maximizedChild, *newchild;
     259  Win32MDIChildWindow *newchild;
     260  HWND         maximizedChild;
    260261  CREATESTRUCTA createstruct;
    261262  ATOM         classAtom;
     
    287288        maximizedChild = client->getMaximizedChild();
    288289
    289         maximizedChild->ShowWindow( SW_SHOWNOACTIVATE );
     290        ::ShowWindow(maximizedChild, SW_SHOWNOACTIVATE );
    290291
    291292        if( style & WS_MAXIMIZE )
     
    379380                if((newchild->getStyle() & WS_MAXIMIZE) && !client->getMaximizedChild() )
    380381                {
    381                     client->setMaximizedChild(newchild);
    382 
    383                     client->augmentFrameMenu(newchild);
     382                    client->setMaximizedChild(newchild->getWindowHandle());
     383
     384                    client->augmentFrameMenu(newchild->getWindowHandle());
    384385
    385386                    client->updateFrameText(MDI_REPAINTFRAME, NULL );
     
    400401
    401402        maximizedChild = client->getMaximizedChild();
    402         if( maximizedChild && maximizedChild->IsWindow() )
    403             maximizedChild->ShowWindow(SW_SHOWMAXIMIZED);
     403        if( ::IsWindow(maximizedChild) )
     404            ::ShowWindow(maximizedChild, SW_SHOWMAXIMIZED);
    404405
    405406        dprintf(("MDI child creation failed!!"));
     
    456457     * sequence and in the menu child list */
    457458
     459    lock();
    458460    for( index = id+1; index <= client->getNrOfChildren() +
    459461         client->getFirstChildId(); index++ )
    460462    {
    461         Win32MDIChildWindow *tmpWnd = client->getChildByID(index);
     463        Win32MDIChildWindow *tmpWnd = (Win32MDIChildWindow *)GetWindowFromHandle(client->getChildByID(index));
    462464        if( !tmpWnd )
    463465        {
    464           dprintf(("no window for id=%i\n",index));
    465           continue;
     466            dprintf(("no window for id=%i\n",index));
     467            continue;
    466468        }
    467469
     
    473475            lstrcpynA(buffer + n, tmpWnd->getWindowNameA(), sizeof(buffer) - n );
    474476
     477        RELEASE_WNDOBJ(tmpWnd);
     478
     479        unlock();
    475480        /* change menu */
    476481        ModifyMenuA(client->getMDIMenu(), index ,MF_BYCOMMAND | MF_STRING,
    477482                    index - 1 , buffer );
    478     }
     483        lock();
     484    }
     485    unlock();
    479486    return TRUE;
    480487}
  • trunk/src/user32/win32wmdiclient.cpp

    r5258 r5935  
    1 /* $Id: win32wmdiclient.cpp,v 1.34 2001-02-23 14:52:42 sandervl Exp $ */
     1/* $Id: win32wmdiclient.cpp,v 1.35 2001-06-09 14:50:23 sandervl Exp $ */
    22/*
    33 * Win32 MDI Client Window Class for OS/2
     
    4646                  frameTitle(NULL), mdiFlags(0), idFirstChild(0), hWindowMenu(0),
    4747                  sbRecalc(0),
    48                   Win32BaseWindow(OBJTYPE_WINDOW)
     48                  Win32BaseWindow()
    4949{
    5050  Init();
     
    125125
    126126    case WM_MDIACTIVATE:
    127         if( activeChild && activeChild->getWindowHandle() != (HWND)wParam )
     127        if(activeChild != (HWND)wParam )
    128128        {
    129129            mdichild = (Win32MDIChildWindow *)GetWindowFromHandle((HWND)wParam);
    130130            if(mdichild) {
    131131                mdichild->SetWindowPos(0,0,0,0,0, SWP_NOSIZE | SWP_NOMOVE);
     132                RELEASE_WNDOBJ(mdichild);
    132133            }
    133134        }
     
    150151        if(mdichild) {
    151152            retvalue = destroyChild(mdichild, TRUE );
     153            RELEASE_WNDOBJ(mdichild);
    152154        }
    153155        goto END;
    154156
    155157    case WM_MDIGETACTIVE:
    156         dprintf(("WM_MDIGETACTIVE: %x %x", this, (activeChild) ? activeChild->getWindowHandle() : 0));
     158        dprintf(("WM_MDIGETACTIVE: %x %x", this, activeChild));
    157159        if (lParam)
    158160            *(BOOL *)lParam = (maximizedChild != 0);
    159161
    160         retvalue = (activeChild) ? activeChild->getWindowHandle() : 0;
     162        retvalue = activeChild;
    161163        goto END;
    162164
     
    178180        if(mdichild) {
    179181            switchActiveChild(mdichild, (lParam)? FALSE : TRUE );
     182            RELEASE_WNDOBJ(mdichild);
    180183        }
    181184        break;
     
    212215        if( activeChild )
    213216        {
    214             if( !(activeChild->getStyle() & WS_MINIMIZE) )
    215                 ::SetFocus(activeChild->getWindowHandle());
     217            if( !(GetWindowLongA(activeChild, GWL_STYLE) & WS_MINIMIZE) )
     218                ::SetFocus(activeChild);
    216219        }
    217220        retvalue = 0;
     
    220223    case WM_NCACTIVATE:
    221224        if( activeChild )
    222             activeChild->SendInternalMessageA(message, wParam, lParam);
     225            ::SendMessageA(activeChild, message, wParam, lParam);
    223226        break;
    224227
     
    234237            HWND child = ChildWindowFromPoint(getWindowHandle(), point);
    235238
    236             if( child && child != getWindowHandle() && (!activeChild || activeChild->getWindowHandle() != child) )
     239            if( child && child != getWindowHandle() && (activeChild != child) )
    237240                ::SetWindowPos(child, 0,0,0,0,0, SWP_NOSIZE | SWP_NOMOVE );
    238241        }
     
    241244
    242245    case WM_SIZE:
    243         if( maximizedChild && maximizedChild->IsWindow() )
     246        if( ::IsWindow(maximizedChild) )
    244247        {
    245248            RECT    rect;
     
    250253            rect.bottom = HIWORD(lParam);
    251254
    252             AdjustWindowRectEx(&rect, maximizedChild->getStyle(), 0, maximizedChild->getExStyle());
    253             ::MoveWindow(maximizedChild->getWindowHandle(), rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, 1);
     255            AdjustWindowRectEx(&rect, GetWindowLongA(maximizedChild, GWL_STYLE), 0, GetWindowLongA(maximizedChild, GWL_EXSTYLE));
     256            ::MoveWindow(maximizedChild, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, 1);
    254257        }
    255258        else postUpdate(SB_BOTH+1);
     
    285288        return 0;
    286289    }
    287     return window->MDIClientWndProc(message, wParam, lParam);
     290    LRESULT ret = window->MDIClientWndProc(message, wParam, lParam);
     291    RELEASE_WNDOBJ(window);
     292    return ret;
    288293}
    289294/**********************************************************************
     
    299304    dwStyleMask |= WS_DISABLED | WS_VISIBLE;
    300305
    301     if( !actchild ) actchild = getActiveChild();
     306    if( !actchild ) {
     307         actchild = (Win32MDIChildWindow *)GetWindowFromHandle(getActiveChild());
     308    }
     309    else actchild->addRef();
     310
    302311    if( !actchild)  return 0;
    303312
     313    lock();
    304314    for ( curchild = (Win32MDIChildWindow *)actchild->getNextChild(); ; curchild = (Win32MDIChildWindow *)curchild->getNextChild())
    305315    {
     
    314324        }
    315325    }
     326    unlock();
     327    RELEASE_WNDOBJ(actchild);
    316328    return lastchild;
    317329}
     
    325337    BOOL                  isActiveFrameWnd = 0;
    326338    LONG                  retvalue;
    327     Win32MDIChildWindow  *prevActive = activeChild;
     339    Win32MDIChildWindow  *prevActive = (Win32MDIChildWindow *)GetWindowFromHandle(activeChild);
    328340
    329341    if( child && child->getStyle() & WS_DISABLED )
    330342    {
     343        if(prevActive) RELEASE_WNDOBJ(prevActive);
    331344        return 0;
    332345    }
     
    334347    /* Don't activate if it is already active. Might happen
    335348       since ShowWindow DOES activate MDI children */
    336     if(activeChild == child)
    337     {
     349    if(activeChild == child->getWindowHandle())
     350    {
     351        if(prevActive) RELEASE_WNDOBJ(prevActive);
    338352        return 0;
    339353    }
     
    358372    if( maximizedChild)
    359373    {
    360         if( maximizedChild != child) {
     374        if( maximizedChild != child->getWindowHandle()) {
    361375            if( child ) {
    362                 activeChild = child;
     376                activeChild = child->getWindowHandle();
    363377                child->ShowWindow(SW_SHOWMAXIMIZED);
    364378            }
    365379            else
    366             if(activeChild) activeChild->ShowWindow( SW_SHOWNORMAL );
     380            if(activeChild) ::ShowWindow(activeChild, SW_SHOWNORMAL );
    367381        }
    368382    }
    369383
    370384    dprintf(("childActivate: %x %x", this, (child) ? child->getWindowHandle() : 0));
    371     activeChild = child;
     385    activeChild = child->getWindowHandle();
    372386
    373387    /* check if we have any children left */
     
    377391            SetFocus(getWindowHandle());
    378392
     393        if(prevActive) RELEASE_WNDOBJ(prevActive);
    379394        return 0;
    380395    }
     
    400415                         prevActive ? (WPARAM)prevActive->getWindowHandle() : 0,
    401416                         child->getWindowHandle());
     417
     418    if(prevActive) RELEASE_WNDOBJ(prevActive);
    402419    return TRUE;
    403420}
     
    410427void Win32MDIClientWindow::switchActiveChild(Win32MDIChildWindow *nextActiveChild, BOOL bNextWindow )
    411428{
    412     Win32MDIChildWindow *prevActiveChild  = 0;
     429    HWND prevActiveChild  = 0;
    413430
    414431    if ( !nextActiveChild) return; /* no window to switch to */
     
    416433    prevActiveChild = getActiveChild();
    417434
    418     if ( prevActiveChild !=  nextActiveChild)
     435    if ( prevActiveChild !=  nextActiveChild->getWindowHandle())
    419436    {
    420437        BOOL bOptimize = 0;
     
    429446
    430447        if( bNextWindow && prevActiveChild )
    431             prevActiveChild->SetWindowPos(HWND_BOTTOM, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE );
     448            ::SetWindowPos(prevActiveChild, HWND_BOTTOM, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE );
    432449
    433450        if( bOptimize )
     
    442459LRESULT Win32MDIClientWindow::destroyChild(Win32MDIChildWindow *child, BOOL flagDestroy )
    443460{
    444     if( child == getActiveChild())
     461    if( child->getWindowHandle() == getActiveChild())
    445462    {
    446463        switchActiveChild(child, TRUE);
    447464
    448         if( child == getActiveChild() )
     465        if( child->getWindowHandle() == getActiveChild() )
    449466        {
    450467            ::ShowWindow(child->getWindowHandle(),SW_HIDE);
    451             if( child == getMaximizedChild() )
     468            if( child->getWindowHandle() == getMaximizedChild() )
    452469            {
    453470                restoreFrameMenu(child);
     
    492509    if (frameTitle)
    493510    {
    494         Win32MDIChildWindow *childWnd = getMaximizedChild();
     511        Win32MDIChildWindow *childWnd = (Win32MDIChildWindow *)GetWindowFromHandle(getMaximizedChild());
    495512
    496513        if( childWnd && childWnd->getWindowNameA() )
     
    526543            lpBuffer[MDI_MAXTITLELENGTH]='\0';
    527544        }
     545        if(childWnd) RELEASE_WNDOBJ(childWnd);
    528546    }
    529547    else
     
    800818
    801819  if (getMaximizedChild())
    802     SendInternalMessageA(WM_MDIRESTORE, (WPARAM)getMaximizedChild()->getWindowHandle(), 0);
     820    SendInternalMessageA(WM_MDIRESTORE, (WPARAM)getMaximizedChild(), 0);
    803821
    804822  if (nActiveChildren == 0) return 0;
     
    845863
    846864  if (getMaximizedChild())
    847     SendInternalMessageA(WM_MDIRESTORE, (WPARAM)getMaximizedChild()->getWindowHandle(), 0);
     865    SendInternalMessageA(WM_MDIRESTORE, (WPARAM)getMaximizedChild(), 0);
    848866
    849867  if (nActiveChildren == 0) return TRUE;
     
    914932 *                  MDI_AugmentFrameMenu
    915933 */
    916 BOOL Win32MDIClientWindow::augmentFrameMenu(Win32MDIChildWindow *child)
    917 {
     934BOOL Win32MDIClientWindow::augmentFrameMenu(HWND hwndChild)
     935{
     936  Win32MDIChildWindow *child = (Win32MDIChildWindow *)GetWindowFromHandle(hwndChild);
    918937  HMENU   hSysPopup = 0,hFrameMenu = ::GetMenu(getParent()->getWindowHandle()),hSysMenu = ::GetSystemMenu(child->getWindowHandle(),FALSE);
    919938  HBITMAP hSysMenuBitmap = 0;
    920939
    921   if (!hFrameMenu || !hSysMenu)
     940  if (!hFrameMenu || !hSysMenu) {
     941    RELEASE_WNDOBJ(child);
    922942    return 0;
    923 
     943  }
    924944  // create a copy of sysmenu popup and insert it into frame menu bar
    925945
    926   if (!(hSysPopup = LoadMenuA(GetModuleHandleA("USER32"), "SYSMENU")))
     946  if (!(hSysPopup = LoadMenuA(GetModuleHandleA("USER32"), "SYSMENU"))) {
     947    RELEASE_WNDOBJ(child);
    927948    return 0;
     949  }
    928950
    929951  //TRACE("\tgot popup %04x in sysmenu %04x\n",
     
    936958
    937959  // In Win 95 look, the system menu is replaced by the child icon
    938 
     960 
    939961  /* Find icon */
    940962  HICON hIcon = child->IconForWindow(ICON_SMALL);
     
    966988    }
    967989  }
     990  RELEASE_WNDOBJ(child);
    968991
    969992  if( !InsertMenuA(hFrameMenu,0,MF_BYPOSITION | MF_BITMAP | MF_POPUP,
     
    9941017 *                  MDI_RestoreFrameMenu
    9951018 */
    996 BOOL Win32MDIClientWindow::restoreFrameMenu(Win32MDIChildWindow *child)
     1019BOOL Win32MDIClientWindow::restoreFrameMenu(HWND hwndChild)
    9971020{
    9981021    MENUITEMINFOA menuInfo;
     
    10041027
    10051028    if(!(iId == SC_RESTORE || iId == SC_CLOSE) )
    1006     return 0;
     1029        return 0;
    10071030
    10081031    /*
     
    10491072{
    10501073    Win32BaseWindow *win32wnd = Win32BaseWindow::GetWindowFromHandle(hwnd);
     1074    Win32BaseWindow *child;
    10511075    SCROLLINFO info;
    10521076    RECT childRect, clientRect;
     
    10591083
    10601084    //TODO: Check if this goes correctly
    1061     for (win32wnd = (Win32BaseWindow*)win32wnd->getFirstChild();win32wnd;win32wnd = (Win32BaseWindow*)win32wnd->getNextChild())
    1062     {
    1063           if( win32wnd->getStyle() & WS_MAXIMIZE )
     1085    win32wnd->lock();
     1086    for (child = (Win32BaseWindow*)win32wnd->getFirstChild();child;child = (Win32BaseWindow*)child->getNextChild())
     1087    {
     1088          if( child->getStyle() & WS_MAXIMIZE )
    10641089          {
     1090              win32wnd->unlock();
     1091              RELEASE_WNDOBJ(win32wnd);
    10651092              ShowScrollBar(hwnd, SB_BOTH, FALSE);
    10661093              return;
    10671094          }
    1068           UnionRect(&childRect,win32wnd->getWindowRect(),&childRect);
    1069     }
     1095          UnionRect(&childRect,child->getWindowRect(),&childRect);
     1096    }
     1097    win32wnd->unlock();
     1098    RELEASE_WNDOBJ(win32wnd);
     1099
    10701100    UnionRect( &childRect, &clientRect, &childRect );
    10711101
     
    11211151    length = win32wnd->getClientWidth()/2;
    11221152    shift = GetSystemMetrics(SM_CYHSCROLL);
    1123   } else if (uMsg == WM_VSCROLL)
     1153  }
     1154  else if (uMsg == WM_VSCROLL)
    11241155  {
    11251156    GetScrollRange(hWnd,SB_VERT,&minPos,&maxPos);
     
    11271158    length = win32wnd->getClientHeight()/2;
    11281159    shift = GetSystemMetrics(SM_CXVSCROLL);
    1129   } else return;
     1160  }
     1161  else
     1162  {
     1163    RELEASE_WNDOBJ(win32wnd);
     1164    return;
     1165  }
     1166  RELEASE_WNDOBJ(win32wnd);
    11301167
    11311168  switch( wParam )
     
    12921329}
    12931330
    1294 /* -------- Miscellaneous service functions ----------
    1295  *
    1296  *          MDI_GetChildByID
    1297  */
    1298 Win32MDIChildWindow *Win32MDIClientWindow::getChildByID(INT id)
    1299 {
    1300  Win32MDIChildWindow *child;
    1301 
    1302     for (child = (Win32MDIChildWindow *)getFirstChild() ; child; child = (Win32MDIChildWindow *)child->getNextChild())
    1303         if (child->getWindowId() == id) return child;
    1304 
    1305     return 0;
    1306 }
     1331/* -------- Miscellaneous service functions ---------- */
    13071332
    13081333void Win32MDIClientWindow::postUpdate(WORD recalc)
  • trunk/src/user32/win32wmdiclient.h

    r2469 r5935  
    1 /* $Id: win32wmdiclient.h,v 1.8 2000-01-18 20:08:17 sandervl Exp $ */
     1/* $Id: win32wmdiclient.h,v 1.9 2001-06-09 14:50:23 sandervl Exp $ */
    22/*
    33 * Win32 MDI Client Window Class for OS/2
     
    3535           HWND getMDIMenu()                     { return hWindowMenu;     };
    3636
    37 Win32MDIChildWindow *getMaximizedChild()         { return maximizedChild;  };
    38                void  setMaximizedChild(Win32MDIChildWindow *newchild) { maximizedChild = newchild; };
     37           HWND getMaximizedChild()              { return maximizedChild;  };
     38           void setMaximizedChild(HWND newchild) { maximizedChild = newchild; };
    3939
    40 Win32MDIChildWindow *getActiveChild()            { return activeChild;     };
    41                void  setActiveChild(Win32MDIChildWindow *newchild) { activeChild = newchild; };
     40           HWND getActiveChild()                 { return activeChild;     };
     41           void setActiveChild(HWND newchild)    { activeChild = newchild; };
    4242
    4343Win32MDIChildWindow *getWindow(Win32MDIChildWindow *actchild, BOOL bNext, DWORD dwStyleMask);
    4444
    45 Win32MDIChildWindow *getChildByID(INT id);
    46                void postUpdate(WORD recalc);
     45           HWND getChildByID(INT id)             { return FindWindowById(id); };
     46           void postUpdate(WORD recalc);
    4747
    4848           int  getNrOfChildren()                { return nActiveChildren; };
     
    7070        BOOL    cascade(UINT fuCascade);
    7171        BOOL    tile(UINT fuTile);
    72         BOOL    augmentFrameMenu(Win32MDIChildWindow *child);
    73         BOOL    restoreFrameMenu(Win32MDIChildWindow *child);
     72        BOOL    augmentFrameMenu(HWND hwndChild);
     73        BOOL    restoreFrameMenu(HWND hwndChild);
    7474
    7575private:
    76   Win32MDIChildWindow *maximizedChild;
    77   Win32MDIChildWindow *activeChild;
     76        HWND    maximizedChild;
     77        HWND    activeChild;
    7878
    7979        HWND    hWindowMenu;
  • trunk/src/user32/win32wnd.cpp

    r3625 r5935  
    1 /* $Id: win32wnd.cpp,v 1.9 2000-05-28 16:43:48 sandervl Exp $ */
     1/* $Id: win32wnd.cpp,v 1.10 2001-06-09 14:50:23 sandervl Exp $ */
    22/*
    33 * Win32 Window Class for OS/2
     
    5454{
    5555 Win32MDIClientWindow *window = NULL;
    56  Win32MDIChildWindow *child;
     56 HWND                  hwndChild;
    5757
    5858    if(hwndMDIClient)
     
    8989                case SC_CLOSE:
    9090                case SC_RESTORE:
    91                     child = window->getMaximizedChild();
    92                     if (child)
    93                     return ::SendMessageA(child->getWindowHandle(),WM_SYSCOMMAND,wParam,lParam);
     91                    hwndChild = window->getMaximizedChild();
     92                    RELEASE_WNDOBJ(window);
     93                    if (hwndChild)
     94                        return ::SendMessageA(hwndChild, WM_SYSCOMMAND, wParam, lParam);
    9495                }
    9596            }
    9697            else
    9798            {
    98                 child = window->getChildByID(wParam);
    99                 if (child)
    100                     ::SendMessageA(window->getWindowHandle(),WM_MDIACTIVATE,(WPARAM)child->getWindowHandle(),0L);
     99                hwndChild = window->getChildByID(wParam);
     100                if (hwndChild)
     101                    ::SendMessageA(window->getWindowHandle(),WM_MDIACTIVATE,(WPARAM)hwndChild,0L);
    101102            }
    102103            break;
     
    136137        }
    137138    }
     139    if(window) RELEASE_WNDOBJ(window);
    138140    return DefWindowProcA(Msg, wParam, lParam);
    139141}
     
    142144LRESULT Win32Window::DefFrameProcW(HWND hwndMDIClient, UINT Msg, WPARAM wParam, LPARAM lParam)
    143145{
    144  Win32Window *window = NULL;
    145 
    146     if(hwndMDIClient)
    147         window = (Win32Window *)GetWindowFromHandle(hwndMDIClient);
    148 
    149     if(window)
     146    switch(Msg)
    150147    {
    151         switch(Msg)
    152         {
    153148        case WM_NCACTIVATE:
    154             window->SendMessageW(Msg, wParam, lParam);
     149            ::SendMessageW(hwndMDIClient, Msg, wParam, lParam);
    155150            break;
    156151
     
    166161        case WM_SIZE:
    167162            return DefFrameProcA(hwndMDIClient, Msg, wParam, lParam );
    168         }
    169163    }
    170164    return DefWindowProcW(Msg, wParam, lParam);
  • trunk/src/user32/win32wndchild.cpp

    r3663 r5935  
    1 /* $Id: win32wndchild.cpp,v 1.6 2000-06-07 21:45:52 sandervl Exp $ */
     1/* $Id: win32wndchild.cpp,v 1.7 2001-06-09 14:50:24 sandervl Exp $ */
    22/*
    33 * Win32 Child/Parent window class for OS/2
     
    1919//******************************************************************************
    2020//******************************************************************************
    21 ChildWindow::ChildWindow()
     21ChildWindow::ChildWindow(CRITICAL_SECTION *pLock)
    2222{
    23   parent           = 0;
    24   nextchild        = 0;
    25   children         = 0;
     23  parent     = 0;
     24  nextchild  = 0;
     25  children   = 0;
     26  pLockChild = pLock;
    2627}
    2728//******************************************************************************
     
    4748 ChildWindow *curchild;
    4849
    49    mutex.enter();
     50   Lock();
    5051
    5152   curchild = children;
     
    6162   child->setNextChild(NULL);
    6263
    63    mutex.leave();
     64   Unlock();
    6465   return TRUE;
    6566}
     
    7172 ChildWindow *curchild = children;
    7273
    73    mutex.enter();
     74   Lock();
    7475
    7576   if(curchild == child) {
     
    8081                dprintf(("ChildWindow::RemoveChild, children == NULL"));
    8182                DebugInt3();
    82                 mutex.leave();
     83                Unlock();
    8384                return FALSE;
    8485        }
     
    8889                        dprintf(("ChildWindow::RemoveChild, curchild == NULL"));
    8990                        DebugInt3();
    90                         mutex.leave();
     91                        Unlock();
    9192                        return FALSE;
    9293                }       
     
    9495        curchild->setNextChild(child->getNextChild());
    9596   }
    96    mutex.leave();
     97   Unlock();
    9798   return TRUE;
    9899}
  • trunk/src/user32/win32wndchild.h

    r3663 r5935  
    1 /* $Id: win32wndchild.h,v 1.5 2000-06-07 21:45:52 sandervl Exp $ */
     1/* $Id: win32wndchild.h,v 1.6 2001-06-09 14:50:24 sandervl Exp $ */
    22/*
    33 * Win32 Child/Parent window class for OS/2
     
    1313#define __WIN32WNDCHILD_H__
    1414
    15 #include <vmutex.h>
     15#ifdef OS2_INCLUDED
     16#include <win32api.h>
     17#endif
    1618
    1719#ifdef __cplusplus
     
    2022{
    2123public:
    22          ChildWindow();
     24         ChildWindow(CRITICAL_SECTION *pLock);
    2325virtual ~ChildWindow();
    2426
     
    4547
    4648private:
    47         VMutex mutex;
     49         void  Lock()           { EnterCriticalSection(pLockChild); };
     50         void  Unlock()         { LeaveCriticalSection(pLockChild); };
     51 
     52   CRITICAL_SECTION *pLockChild;
    4853
    4954   ChildWindow *parent;         //GWL_HWNDPARENT
  • trunk/src/user32/winaccel.cpp

    r2846 r5935  
    1 /* $Id: winaccel.cpp,v 1.7 2000-02-21 14:25:23 sandervl Exp $ */
     1/* $Id: winaccel.cpp,v 1.8 2001-06-09 14:50:24 sandervl Exp $ */
    22/*
    33 * Win32 accelerator key functions for OS/2
     
    8585                else
    8686                {
    87                    Win32BaseWindow *window;
     87                    Win32BaseWindow *window;
    8888
    8989                    window = Win32BaseWindow::GetWindowFromHandle(hWnd);
     
    123123                            mesg=WM_COMMAND;
    124124                    }
     125                    RELEASE_WNDOBJ(window);
    125126                }
    126127                if ( mesg==WM_COMMAND || mesg==WM_SYSCOMMAND )
     
    165166    /* YES, Accel16! */
    166167    LPACCEL lpAccelTbl;
    167     Win32BaseWindow *window;
    168168    int i;
    169169
     
    181181          return 0;
    182182    }
    183     window = Win32BaseWindow::GetWindowFromHandle(hWnd);
    184     if(!window) {
     183    if(!IsWindow(hWnd)) {
    185184          dprintf(("TranslateAccelerator, window %x not found", hWnd));
    186185          SetLastError(ERROR_INVALID_WINDOW_HANDLE);
     
    233232        }
    234233
    235         mdichild = clientWnd->getActiveChild();
    236         if(!mdichild) {
     234        hwndChild = clientWnd->getActiveChild();
     235        RELEASE_WNDOBJ(clientWnd);
     236        if(!hwndChild) {
    237237            dprintf(("TranslateMDISysAccel NO active MDI child!!"));
    238238            return FALSE;
    239239        }
    240         hwndChild = mdichild->getWindowHandle();
    241240
    242241        if(IsWindow(hwndChild) && !(GetWindowLongA(hwndChild,GWL_STYLE) & WS_DISABLED) )
  • trunk/src/user32/windlg.cpp

    r5258 r5935  
    1 /* $Id: windlg.cpp,v 1.22 2001-02-23 14:52:42 sandervl Exp $ */
     1/* $Id: windlg.cpp,v 1.23 2001-06-09 14:50:25 sandervl Exp $ */
    22/*
    33 * Win32 dialog apis for OS/2
     
    8787    {
    8888        dprintf(("Win32Dialog error found (%0x)!!", GetLastError()));
     89        RELEASE_WNDOBJ(dialog);
    8990        delete dialog;
    9091        return 0;
    9192    }
    92     return dialog->getWindowHandle();
     93    HWND hwnd = dialog->getWindowHandle();
     94    RELEASE_WNDOBJ(dialog);
     95    return hwnd;
    9396}
    9497//******************************************************************************
     
    115118    {
    116119        dprintf(("Win32Dialog error found!!"));
     120        RELEASE_WNDOBJ(dialog);
    117121        delete dialog;
    118122        return 0;
    119123    }
    120     return dialog->getWindowHandle();
     124    HWND hwnd = dialog->getWindowHandle();
     125    RELEASE_WNDOBJ(dialog);
     126    return hwnd;
    121127}
    122128//******************************************************************************
     
    127133                      LPARAM lParamInit)
    128134{
     135    INT result;
    129136    HWND hwnd = CreateDialogIndirectParamA(hInst, dlgtemplate, hwndParent, dlgproc,
    130137                                           lParamInit);
     
    136143        if(!dialog || !dialog->IsDialog()) {
    137144            dprintf(("DialogBoxIndirectParamA, dialog %x not found", hwnd));
     145            if(dialog) RELEASE_WNDOBJ(dialog);
    138146            SetLastError(ERROR_INVALID_WINDOW_HANDLE);
    139147            return 0;
    140148        }
    141         return dialog->doDialogBox();
     149        result = dialog->doDialogBox();
     150        RELEASE_WNDOBJ(dialog);
     151        return result;
    142152    }
    143153    return -1;
     
    149159                                      LPARAM lParamInit)
    150160{
     161    INT result;
    151162    HWND hwnd = CreateDialogIndirectParamW(hInst, dlgtemplate, hwndParent, dlgproc,
    152163                                           lParamInit);
     
    158169        if(!dialog || !dialog->IsDialog()) {
    159170            dprintf(("DialogBoxIndirectParamW, dialog %x not found", hwnd));
     171            if(dialog) RELEASE_WNDOBJ(dialog);
    160172            SetLastError(ERROR_INVALID_WINDOW_HANDLE);
    161173            return 0;
    162174        }
    163         return dialog->doDialogBox();
     175        result = dialog->doDialogBox();
     176        RELEASE_WNDOBJ(dialog);
     177        return result;
    164178    }
    165179    return -1;
     
    170184                     DLGPROC dlgproc, LPARAM  lParamInit)
    171185{
     186    INT result;
    172187    HWND hwnd = CreateDialogParamA( hInst, lpszTemplate, hwndOwner, dlgproc, lParamInit);
    173188
     
    179194        if(!dialog || !dialog->IsDialog()) {
    180195            dprintf(("DialogBoxParamA, dialog %x not found", hwnd));
     196            if(dialog) RELEASE_WNDOBJ(dialog);
    181197            SetLastError(ERROR_INVALID_WINDOW_HANDLE);
    182198            return 0;
    183199        }
    184         return dialog->doDialogBox();
     200        result = dialog->doDialogBox();
     201        RELEASE_WNDOBJ(dialog);
     202        return result;
    185203    }
    186204    return -1;
     
    191209                             DLGPROC dlgproc, LPARAM lParamInit)
    192210{
     211    INT result;
    193212    HWND hwnd = CreateDialogParamW( hInst, lpszTemplate, hwndOwner, dlgproc, lParamInit);
    194213
     
    200219        if(!dialog || !dialog->IsDialog()) {
    201220            dprintf(("DialogBoxParamW, dialog %x not found", hwnd));
     221            if(dialog) RELEASE_WNDOBJ(dialog);
    202222            SetLastError(ERROR_INVALID_WINDOW_HANDLE);
    203223            return 0;
    204224        }
    205         return dialog->doDialogBox();
     225        result = dialog->doDialogBox();
     226        RELEASE_WNDOBJ(dialog);
     227        return result;
    206228    }
    207229    return -1;
     
    213235{
    214236  Win32Dialog *dialog;
     237  BOOL rc;
    215238#ifdef DEBUG
    216   BOOL rc;
    217239  RECT dlgRect = *rect;
    218240#endif
     
    222244        dprintf(("MapDialogRect, window %x not found", hwndDlg));
    223245        SetLastError(ERROR_INVALID_WINDOW_HANDLE);
    224         return 0;
    225     }
    226 #ifdef DEBUG
     246        if(dialog) RELEASE_WNDOBJ(dialog);
     247        return 0;
     248    }
    227249    rc = dialog->MapDialogRect(rect);
    228250    dprintf(("USER32: MapDialogRect %x (%d,%d)(%d,%d) -> (%d,%d)(%d,%d)", hwndDlg, dlgRect.left, dlgRect.top, dlgRect.right, dlgRect.bottom, rect->left, rect->top, rect->right, rect->bottom));
     251    RELEASE_WNDOBJ(dialog);
    229252    return rc;
    230 #else
    231     dprintf(("USER32: MapDialogRect %x (%d,%d)(%d,%d)", hwndDlg, rect->left, rect->top, rect->right, rect->bottom));
    232     return dialog->MapDialogRect(rect);
    233 #endif
    234253}
    235254//******************************************************************************
     
    334353HWND WIN32API GetNextDlgTabItem(HWND hwndDlg, HWND hwndCtrl, BOOL fPrevious)
    335354{
    336   Win32BaseWindow *window;
    337 
    338     window = (Win32BaseWindow*)Win32BaseWindow::GetWindowFromHandle(hwndDlg);
    339     if(!window) {
     355    if(!IsWindow(hwndDlg)) {
    340356        dprintf(("GetNextDlgTabItem, window %x not found", hwndDlg));
    341357        SetLastError(ERROR_INVALID_WINDOW_HANDLE);
     
    352368HWND WIN32API GetDlgItem(HWND hwnd, int id)
    353369{
    354   Win32BaseWindow *dlgcontrol, *window;
     370  Win32BaseWindow *window;
     371  HWND             hwndDlgItem;
    355372
    356373    window = (Win32Dialog *)Win32BaseWindow::GetWindowFromHandle(hwnd);
     
    360377        return 0;
    361378    }
    362     dlgcontrol = window->FindWindowById(id);
    363     if(dlgcontrol) {
    364         dprintf(("USER32: GetDlgItem %x %d returned %x\n", hwnd, id, dlgcontrol->getWindowHandle()));
    365         return dlgcontrol->getWindowHandle();
     379    hwndDlgItem = window->FindWindowById(id);
     380    RELEASE_WNDOBJ(window);
     381    if(hwndDlgItem) {
     382        dprintf(("USER32: GetDlgItem %x %d returned %x\n", hwnd, id, hwndDlgItem));
     383        return hwndDlgItem;
    366384    }
    367385    dprintf(("USER32: GetDlgItem %x %d NOT FOUND!\n", hwnd, id));
  • trunk/src/user32/windlgmsg.cpp

    r5496 r5935  
    1 /* $Id: windlgmsg.cpp,v 1.8 2001-04-12 14:04:33 sandervl Exp $ */
     1/* $Id: windlgmsg.cpp,v 1.9 2001-06-09 14:50:25 sandervl Exp $ */
    22/*
    33 * Win32 dialog message APIs for OS/2
     
    3030{
    3131  Win32Dialog *dialog;
    32   Win32BaseWindow *dlgcontrol;
     32  HWND hwndDlgItem;
    3333
    3434    dialog = (Win32Dialog *)Win32BaseWindow::GetWindowFromHandle(hwnd);
     
    3737        return 0;
    3838    }
    39     dlgcontrol = dialog->getDlgItem(id);
    40     if(dlgcontrol) {
    41         return dlgcontrol->SendMessageA(Msg, wParam, lParam);
     39    hwndDlgItem = dialog->getDlgItem(id);
     40    RELEASE_WNDOBJ(dialog);
     41    if(hwndDlgItem) {
     42        return SendMessageA(hwndDlgItem, Msg, wParam, lParam);
    4243    }
    4344    return 0;
     
    4849{
    4950  Win32Dialog *dialog;
    50   Win32BaseWindow *dlgcontrol;
     51  HWND hwndDlgItem;
    5152
    5253    dialog = (Win32Dialog *)Win32BaseWindow::GetWindowFromHandle(hwnd);
     
    5556        return 0;
    5657    }
    57     dlgcontrol = dialog->getDlgItem(id);
    58     if(dlgcontrol) {
    59         return dlgcontrol->SendMessageW(Msg, wParam, lParam);
     58    hwndDlgItem = dialog->getDlgItem(id);
     59    RELEASE_WNDOBJ(dialog);
     60    if(hwndDlgItem) {
     61        return SendMessageW(hwndDlgItem, Msg, wParam, lParam);
    6062    }
    6163    return 0;
     
    9092                 ((win32wnd->getStyle() & (WS_VISIBLE | WS_DISABLED)) == WS_VISIBLE) )
    9193            {
    92               dlgCode = SendMessageA( hwndControl, WM_GETDLGCODE, 0, 0 );
    93               if (dlgCode & (DLGC_BUTTON | DLGC_STATIC))
    94               {
    95                 INT textLen = win32wnd->GetWindowTextLengthA();
    96 
    97                 if (textLen > 0)
    98                 {
    99                     /* find the accelerator key */
    100                     char* text;
    101                     LPSTR p;
    102 
    103                     text = (char*)malloc(textLen+1);
    104                     win32wnd->GetWindowTextA(text,textLen);
    105                     p = text - 2;
    106                     do
     94                dlgCode = SendMessageA( hwndControl, WM_GETDLGCODE, 0, 0 );
     95                if (dlgCode & (DLGC_BUTTON | DLGC_STATIC))
     96                {
     97                    INT textLen = win32wnd->GetWindowTextLengthA();
     98
     99                    if (textLen > 0)
    107100                    {
    108                         p = strchr( p + 2, '&' );
     101                        /* find the accelerator key */
     102                        char* text;
     103                        LPSTR p;
     104
     105                        text = (char*)malloc(textLen+1);
     106                        win32wnd->GetWindowTextA(text,textLen);
     107                        p = text - 2;
     108                        do
     109                        {
     110                            p = strchr( p + 2, '&' );
     111                        }
     112                        while (p != NULL && p[1] == '&');
     113
     114                        /* and check if it's the one we're looking for */
     115                        if (p != NULL && toupper( p[1] ) == toupper( vKey ) )
     116                        {
     117                            if ((dlgCode & DLGC_STATIC) ||
     118                                (win32wnd->getStyle() & 0x0f) == BS_GROUPBOX )
     119                            {
     120                                /* set focus to the control */
     121                                SendMessageA( hwndDlg, WM_NEXTDLGCTL,
     122                                              hwndControl, 1);
     123                                /* and bump it on to next */
     124                                SendMessageA( hwndDlg, WM_NEXTDLGCTL, 0, 0);
     125                            }
     126                            else
     127                            //TODO: this else part was removed in Wine and above if rules out this possibility (if (dlgCode & (DLGC_BUTTON | DLGC_STATIC)))
     128                            if (dlgCode & (DLGC_DEFPUSHBUTTON | DLGC_UNDEFPUSHBUTTON))
     129                            {
     130                                /* send command message as from the control */
     131                                SendMessageA( hwndDlg, WM_COMMAND, MAKEWPARAM( LOWORD(win32wnd->getWindowId()), BN_CLICKED ),
     132                                              (LPARAM)hwndControl );
     133                            }
     134                            else if (dlgCode & DLGC_BUTTON)
     135                            {
     136                                /* send BM_CLICK message to the control */
     137                                SendMessageA( hwndControl, BM_CLICK, 0, 0 );
     138                            }
     139                            RetVal = TRUE;
     140                            free(text);
     141                            RELEASE_WNDOBJ(win32wnd);
     142                            break;
     143                        }
     144                        free(text);
    109145                    }
    110                     while (p != NULL && p[1] == '&');
    111 
    112                     /* and check if it's the one we're looking for */
    113                     if (p != NULL && toupper( p[1] ) == toupper( vKey ) )
    114                     {
    115                         if ((dlgCode & DLGC_STATIC) ||
    116                             (win32wnd->getStyle() & 0x0f) == BS_GROUPBOX )
    117                         {
    118                             /* set focus to the control */
    119                             SendMessageA( hwndDlg, WM_NEXTDLGCTL,
    120                                     hwndControl, 1);
    121                             /* and bump it on to next */
    122                             SendMessageA( hwndDlg, WM_NEXTDLGCTL, 0, 0);
    123                         }
    124                         else if (dlgCode &
    125                 (DLGC_DEFPUSHBUTTON | DLGC_UNDEFPUSHBUTTON))
    126                         {
    127                             /* send command message as from the control */
    128                             SendMessageA( hwndDlg, WM_COMMAND,
    129                                 MAKEWPARAM( LOWORD(win32wnd->getWindowId()),
    130                                     BN_CLICKED ),
    131                                 (LPARAM)hwndControl );
    132                         }
    133                         else
    134                         {
    135                             /* click the control */
    136                             SendMessageA( hwndControl, WM_LBUTTONDOWN, 0, 0);
    137                             SendMessageA( hwndControl, WM_LBUTTONUP, 0, 0);
    138                         }
    139                         RetVal = TRUE;
    140                         free(text);
     146                }
     147                hwndNext = GetWindow( hwndControl, GW_CHILD );
     148            }
     149            else
     150            {
     151                hwndNext = 0;
     152            }
     153            if(win32wnd) RELEASE_WNDOBJ(win32wnd);
     154
     155            if (!hwndNext)
     156            {
     157                hwndNext = GetWindow( hwndControl, GW_HWNDNEXT );
     158            }
     159            while (!hwndNext)
     160            {
     161                hwndControl = GetParent( hwndControl );
     162                if (hwndControl == hwndDlg)
     163                {
     164                    if(hwnd==hwndDlg){  /* prevent endless loop */
     165                        hwndNext=hwnd;
    141166                        break;
    142167                    }
    143                     free(text);
    144                 }
    145               }
    146         hwndNext = GetWindow( hwndControl, GW_CHILD );
    147             }
    148         else
    149         {
    150         hwndNext = 0;
    151         }
    152         if (!hwndNext)
    153         {
    154             hwndNext = GetWindow( hwndControl, GW_HWNDNEXT );
    155         }
    156         while (!hwndNext)
    157         {
    158         hwndControl = GetParent( hwndControl );
    159         if (hwndControl == hwndDlg)
    160         {
    161             if(hwnd==hwndDlg){  /* prevent endless loop */
    162                 hwndNext=hwnd;
    163             break;
    164             }
    165             hwndNext = GetWindow( hwndDlg, GW_CHILD );
    166         }
    167         else
    168         {
    169             hwndNext = GetWindow( hwndControl, GW_HWNDNEXT );
    170         }
    171         }
     168                    hwndNext = GetWindow( hwndDlg, GW_CHILD );
     169                }
     170                else
     171                {
     172                    hwndNext = GetWindow( hwndControl, GW_HWNDNEXT );
     173                }
     174            }
    172175            hwndControl = hwndNext;
    173176        }
     
    184187 * We propagate up until we hit a that does not have DS_CONTROL, or
    185188 * whose parent is not a dialog.
     189 *
     190 * This is undocumented behaviour.
    186191 */
    187192static HWND DIALOG_FindMsgDestination( HWND hwndDlg )
     
    196201        if (!pParent) break;
    197202
    198         if (!pParent->IsDialog())
    199           break;
    200 
     203        if (!pParent->IsDialog()) {
     204            RELEASE_WNDOBJ(pParent);
     205            break;
     206        }
     207        RELEASE_WNDOBJ(pParent);
    201208        hwndDlg = hParent;
    202209    }
  • trunk/src/user32/window.cpp

    r5713 r5935  
    1 /* $Id: window.cpp,v 1.98 2001-05-15 14:31:40 sandervl Exp $ */
     1/* $Id: window.cpp,v 1.99 2001-06-09 14:50:25 sandervl Exp $ */
    22/*
    33 * Win32 window apis for OS/2
     
    129129    {
    130130        dprintf(("Win32BaseWindow error found!!"));
     131        RELEASE_WNDOBJ(window);
    131132        delete window;
    132133        return 0;
    133134    }
    134     return window->getWindowHandle();
     135    HWND hwnd = window->getWindowHandle();
     136    RELEASE_WNDOBJ(window);
     137    return hwnd;
    135138}
    136139//******************************************************************************
     
    220223    {
    221224        dprintf(("Win32BaseWindow error found!!"));
     225        RELEASE_WNDOBJ(window);
    222226        delete window;
    223227        return 0;
    224228    }
    225     return window->getWindowHandle();
     229    HWND hwnd = window->getWindowHandle();
     230    RELEASE_WNDOBJ(window);
     231    return hwnd;
    226232}
    227233//******************************************************************************
     
    237243        return 0;
    238244    }
    239     return window->getWindowHandle();
     245    HWND hwnd = window->getWindowHandle();
     246    RELEASE_WNDOBJ(window);
     247    return hwnd;
    240248}
    241249//******************************************************************************
     
    271279    else dprintf(("CreateMDIWindowA: class %d parent %x (%d,%d) (%d,%d), %x %x lParam=%x", lpszClassName, hwndParent, x, y, nWidth, nHeight, dwStyle, lParam));
    272280
    273     return window->SendMessageA(WM_MDICREATE, 0, (LPARAM)&cs);
     281    hwnd = window->SendMessageA(WM_MDICREATE, 0, (LPARAM)&cs);
     282    RELEASE_WNDOBJ(window);
     283    return hwnd;
    274284}
    275285//******************************************************************************
     
    306316    else dprintf(("CreateMDIWindowW: class %d parent %x (%d,%d) (%d,%d), %x %x lParam=%x", lpszClassName, hwndParent, x, y, nWidth, nHeight, dwStyle, lParam));
    307317
    308     return window->SendMessageW(WM_MDICREATE, 0, (LPARAM)&cs);
     318    hwnd = window->SendMessageW(WM_MDICREATE, 0, (LPARAM)&cs);
     319    RELEASE_WNDOBJ(window);
     320    return hwnd;
    309321}
    310322//******************************************************************************
     
    313325{
    314326  Win32BaseWindow *window;
     327  BOOL             ret;
    315328
    316329    window = Win32BaseWindow::GetWindowFromHandle(hwnd);
     
    320333        return 0;
    321334    }
    322     if(window->isDesktopWindow()) {
    323     dprintf(("WARNING: Trying to destroy desktop window!"));
    324     return FALSE;
    325     }
    326     return window->DestroyWindow();
     335    ret = window->DestroyWindow();
     336    RELEASE_WNDOBJ(window);
     337    return ret;
    327338}
    328339//******************************************************************************
     
    331342{
    332343  Win32BaseWindow *window;
     344  HWND             hwndActive;
    333345
    334346    window = Win32BaseWindow::GetWindowFromHandle(hwnd);
     
    338350        return 0;
    339351    }
    340     return window->SetActiveWindow();
     352    hwndActive = window->SetActiveWindow();
     353    RELEASE_WNDOBJ(window);
     354    return hwndActive;
    341355}
    342356//******************************************************************************
     
    346360{
    347361  Win32BaseWindow *window;
     362  HWND             hwndParent;
    348363
    349364    window = Win32BaseWindow::GetWindowFromHandle(hwnd);
     
    354369    }
    355370    dprintf2(("GetParent %x", hwnd));
    356     return window->GetParent();
     371    hwndParent = window->GetParent();
     372    RELEASE_WNDOBJ(window);
     373    return hwndParent;
    357374}
    358375//******************************************************************************
     
    360377HWND WIN32API SetParent( HWND hwndChild, HWND hwndNewParent)
    361378{
    362   Win32BaseWindow *window, *parent;
     379  Win32BaseWindow *window;
     380  HWND             hwndOldParent;
    363381
    364382    window = Win32BaseWindow::GetWindowFromHandle(hwndChild);
     
    372390    }
    373391    else {
    374         parent = Win32BaseWindow::GetWindowFromHandle(hwndNewParent);
    375         if(!window) {
     392        if(!IsWindow(hwndNewParent)) {
     393            RELEASE_WNDOBJ(window);
    376394            dprintf(("SetParent, parent %x not found", hwndNewParent));
    377395            SetLastError(ERROR_INVALID_WINDOW_HANDLE);
     
    380398    }
    381399    dprintf(("SetParent %x %x", hwndChild, hwndNewParent));
    382     return window->SetParent(hwndNewParent);
     400    hwndOldParent = window->SetParent(hwndNewParent);
     401    RELEASE_WNDOBJ(window);
     402    return hwndOldParent;
    383403}
    384404//******************************************************************************
     
    387407{
    388408  Win32BaseWindow *window;
     409  BOOL             fIsChild;
    389410
    390411    window = Win32BaseWindow::GetWindowFromHandle(hwnd);
     
    395416    }
    396417    dprintf(("IsChild %x %x", hwndParent, hwnd));
    397     return window->IsChild(hwndParent);
     418    fIsChild = window->IsChild(hwndParent);
     419    RELEASE_WNDOBJ(window);
     420    return fIsChild;
    398421}
    399422//******************************************************************************
     
    405428
    406429    if(hwnd == HWND_DESKTOP) {
     430        windowDesktop->addRef();
    407431        window = windowDesktop;
    408432    }
     
    417441    hwndTop = window->GetTopWindow();
    418442    dprintf2(("GetTopWindow %x returned %x", hwnd, hwndTop));
     443    RELEASE_WNDOBJ(window);
    419444    return hwndTop;
    420445}
     
    424449{
    425450  Win32BaseWindow *window;
    426   BOOL rc;
     451  BOOL fIsIconic;
    427452
    428453    window = Win32BaseWindow::GetWindowFromHandle(hwnd);
     
    432457        return FALSE;
    433458    }
    434     rc = window->IsWindowIconic();
    435     dprintf(("IsIconic %x returned %d", hwnd, rc));
    436     return rc;
     459    fIsIconic = window->IsWindowIconic();
     460    dprintf(("IsIconic %x returned %d", hwnd, fIsIconic));
     461    RELEASE_WNDOBJ(window);
     462    return fIsIconic;
    437463}
    438464//******************************************************************************
     
    441467{
    442468  Win32BaseWindow *window;
    443   HWND rc;
     469  HWND hwndRelated;
    444470
    445471    window = Win32BaseWindow::GetWindowFromHandle(hwnd);
     
    449475        return 0;
    450476    }
    451     return window->GetWindow(uCmd);
     477    hwndRelated = window->GetWindow(uCmd);
     478    RELEASE_WNDOBJ(window);
     479    return hwndRelated;
    452480}
    453481//******************************************************************************
     
    456484{
    457485  Win32BaseWindow *window;
     486  BOOL             fEnabled;
    458487
    459488    window = Win32BaseWindow::GetWindowFromHandle(hwnd);
     
    464493    }
    465494    dprintf(("EnableWindow %x %d", hwnd, fEnable));
    466     return window->EnableWindow(fEnable);
     495    fEnabled = window->EnableWindow(fEnable);
     496    RELEASE_WNDOBJ(window);
     497    return fEnabled;
    467498}
    468499//******************************************************************************
     
    539570{
    540571  Win32BaseWindow *window;
     572  BOOL             ret;
    541573
    542574    window = Win32BaseWindow::GetWindowFromHandle(hwnd);
     
    546578        return 0;
    547579    }
    548     return window->ShowWindow(nCmdShow);
     580    ret = window->ShowWindow(nCmdShow);
     581    RELEASE_WNDOBJ(window);
     582    return ret;
    549583}
    550584/*****************************************************************************
     
    589623    }
    590624    dprintf(("SetWindowPos %x %x x=%d y=%d cx=%d cy=%d %x", hwnd, hwndInsertAfter, x, y, cx, cy, fuFlags));
    591     return window->SetWindowPos(hwndInsertAfter, x, y, cx, cy, fuFlags);
     625    BOOL ret = window->SetWindowPos(hwndInsertAfter, x, y, cx, cy, fuFlags);
     626    RELEASE_WNDOBJ(window);
     627    return ret;
    592628}
    593629//******************************************************************************
     
    598634  Win32BaseWindow *window;
    599635
    600     window = Win32BaseWindow::GetWindowFromHandle(hwnd);
    601     if(!window) {
    602         dprintf(("SetWindowPlacement, window %x not found", hwnd));
    603         SetLastError(ERROR_INVALID_WINDOW_HANDLE);
    604         return FALSE;
    605     }
    606636    if(!winpos || winpos->length != sizeof(WINDOWPLACEMENT)) {
    607637        dprintf(("SetWindowPlacement %x invalid parameter", hwnd));
     
    609639        return FALSE;
    610640    }
     641    window = Win32BaseWindow::GetWindowFromHandle(hwnd);
     642    if(!window) {
     643        dprintf(("SetWindowPlacement, window %x not found", hwnd));
     644        SetLastError(ERROR_INVALID_WINDOW_HANDLE);
     645        return FALSE;
     646    }
    611647    dprintf(("USER32: SetWindowPlacement %x %x", hwnd, winpos));
    612     return window->SetWindowPlacement((WINDOWPLACEMENT *)winpos);
     648    BOOL ret = window->SetWindowPlacement((WINDOWPLACEMENT *)winpos);
     649    RELEASE_WNDOBJ(window);
     650    return ret;
    613651}
    614652//******************************************************************************
     
    620658  Win32BaseWindow *window;
    621659
    622     window = Win32BaseWindow::GetWindowFromHandle(hwnd);
    623     if(!window) {
    624         dprintf(("GetWindowPlacement, window %x not found", hwnd));
    625         SetLastError(ERROR_INVALID_WINDOW_HANDLE);
    626         return FALSE;
    627     }
    628660    if(!winpos) {
    629661        dprintf(("GetWindowPlacement %x invalid parameter", hwnd));
     
    631663        return FALSE;
    632664    }
     665    window = Win32BaseWindow::GetWindowFromHandle(hwnd);
     666    if(!window) {
     667        dprintf(("GetWindowPlacement, window %x not found", hwnd));
     668        SetLastError(ERROR_INVALID_WINDOW_HANDLE);
     669        return FALSE;
     670    }
    633671    dprintf(("USER32: GetWindowPlacement %x %x", hwnd, winpos));
    634     return window->GetWindowPlacement(winpos);
     672    BOOL ret = window->GetWindowPlacement(winpos);
     673    RELEASE_WNDOBJ(window);
     674    return ret;
    635675}
    636676//******************************************************************************
     
    647687    }
    648688    dprintf2(("IsWindow %x", hwnd));
    649     return window->IsWindow();
     689    BOOL fIsWindow = window->IsWindow();
     690    RELEASE_WNDOBJ(window);
     691    return fIsWindow;
    650692}
    651693//******************************************************************************
     
    653695BOOL WIN32API IsWindowEnabled( HWND hwnd)
    654696{
    655   Win32BaseWindow *window;
    656697  DWORD            dwStyle;
    657698
    658     window = Win32BaseWindow::GetWindowFromHandle(hwnd);
    659     if(!window) {
     699    if(!IsWindow(hwnd)) {
    660700        dprintf(("IsWindowEnabled, window %x not found", hwnd));
    661701        SetLastError(ERROR_INVALID_WINDOW_HANDLE);
     
    673713BOOL WIN32API IsWindowVisible(HWND hwnd)
    674714{
    675   Win32BaseWindow *window;
    676715  BOOL             ret;
    677716  HWND             hwndParent;
    678717  DWORD            dwStyle;
    679718
    680     if(!hwnd) {//TODO: verify in NT!
     719    if(hwnd == HWND_DESKTOP) {//TODO: verify in NT!
    681720        dprintf(("IsWindowVisible DESKTOP returned TRUE"));
    682721        return TRUE;    //desktop is always visible
    683722    }
    684     window = Win32BaseWindow::GetWindowFromHandle(hwnd);
    685 
    686     if(!window) {
     723    if(!IsWindow(hwnd)) {
    687724        dprintf(("IsWindowVisible, window %x not found", hwnd));
    688725        SetLastError(ERROR_INVALID_WINDOW_HANDLE);
     
    716753HWND WIN32API SetFocus(HWND hwnd)
    717754{
    718  Win32BaseWindow *window, *topparent;
     755 Win32BaseWindow *window;
    719756 Win32BaseWindow *oldfocuswnd;
    720  HWND lastFocus, lastFocus_W, hwnd_O;
     757 HWND lastFocus, lastFocus_W, hwnd_O, hwndTopParent;
    721758 BOOL activate;
    722759 TEB *teb;
     
    741778    else lastFocus = OSLibWinQueryFocus (OSLIB_HWND_DESKTOP);
    742779
    743     topparent = window->GetTopParent();
     780    hwndTopParent = window->GetTopParent();
    744781    activate = FALSE;
    745     lastFocus_W = OS2ToWin32Handle (lastFocus);
     782    lastFocus_W = OS2ToWin32Handle(lastFocus);
    746783    if(lastFocus_W) {
    747784         oldfocuswnd = Win32BaseWindow::GetWindowFromHandle(lastFocus_W);
    748          if(lastFocus_W != hwnd && topparent != oldfocuswnd->GetTopParent()) {
     785         if(lastFocus_W != hwnd && hwndTopParent != oldfocuswnd->GetTopParent()) {
    749786            activate = TRUE;
    750787         }
     788         RELEASE_WNDOBJ(oldfocuswnd);
    751789    }
    752790    else activate = TRUE;
     
    766804        //mp1 = win32 window handle
    767805        //mp2 = top parent if activation required
    768         OSLibPostMessageDirect(hwnd_O, WIN32APP_SETFOCUSMSG, hwnd, (activate) ? topparent->getWindowHandle() : 0);
     806        OSLibPostMessageDirect(hwnd_O, WIN32APP_SETFOCUSMSG, hwnd, (activate) ? hwndTopParent : 0);
    769807        return lastFocus_W;
    770808    }
    771809    teb->o.odin.hwndFocus = 0;
    772810    if(activate) {
    773         SetActiveWindow(topparent->getWindowHandle());
     811        SetActiveWindow(hwndTopParent);
    774812    }
    775813    if(!IsWindow(hwnd)) return FALSE;       //abort if window destroyed
     
    827865  Win32BaseWindow *window;
    828866
    829     if (hwnd)
    830       window = Win32BaseWindow::GetWindowFromHandle(hwnd);
    831     else
    832       window = windowDesktop;
    833 
     867    if(pRect == NULL) {
     868        dprintf(("GetWindowRect %x invalid parameter!", hwnd));
     869        SetLastError(ERROR_INVALID_PARAMETER);
     870        return FALSE;
     871    }
     872
     873    if(hwnd == HWND_DESKTOP) {
     874         windowDesktop->addRef();
     875         window = windowDesktop;
     876    }     
     877    else window = Win32BaseWindow::GetWindowFromHandle(hwnd);
     878     
    834879    if(!window) {
    835880        dprintf(("GetWindowRect, window %x not found", hwnd));
    836881        SetLastError(ERROR_INVALID_WINDOW_HANDLE);
    837         return FALSE;
    838     }
    839     if(pRect == NULL) {
    840         SetLastError(ERROR_INVALID_PARAMETER);
    841882        return FALSE;
    842883    }
     
    847888         MapWindowPoints(window->getParent()->getWindowHandle(), 0, (PPOINT)pRect, 2);
    848889    }
    849 
     890    RELEASE_WNDOBJ(window);
    850891    dprintf(("GetWindowRect %x (%d,%d) (%d,%d)", hwnd, pRect->left, pRect->top, pRect->right, pRect->bottom));
    851892    return TRUE;
     
    864905    }
    865906    dprintf(("GetWindowTextLengthA %x", hwnd));
    866     return window->GetWindowTextLengthA();
     907    int ret = window->GetWindowTextLengthA();
     908    RELEASE_WNDOBJ(window);
     909    return ret;
    867910}
    868911//******************************************************************************
     
    881924    rc = window->GetWindowTextA(lpsz, cch);
    882925    dprintf(("GetWindowTextA %x %s", hwnd, lpsz));
     926    RELEASE_WNDOBJ(window);
    883927    return rc;
    884928}
     
    896940    }
    897941    dprintf(("GetWindowTextLengthW %x", hwnd));
    898     return window->GetWindowTextLengthW();
     942    int ret = window->GetWindowTextLengthW();
     943    RELEASE_WNDOBJ(window);
     944    return ret;
    899945}
    900946//******************************************************************************
     
    910956        return 0;
    911957    }
    912 #ifdef DEBUG
    913958    int rc = window->GetWindowTextW(lpsz, cch);
     959    RELEASE_WNDOBJ(window);
    914960    dprintf(("GetWindowTextW %x %ls", hwnd, lpsz));
    915961    return rc;
    916 #else
    917     return window->GetWindowTextW(lpsz, cch);
    918 #endif
    919962}
    920963//******************************************************************************
     
    931974    }
    932975    dprintf(("SetWindowTextA %x %s", hwnd, lpsz));
    933     return window->SetWindowTextA((LPSTR)lpsz);
     976    BOOL ret = window->SetWindowTextA((LPSTR)lpsz);
     977    RELEASE_WNDOBJ(window);
     978    return ret;
    934979}
    935980//******************************************************************************
     
    946991    }
    947992    dprintf(("SetWindowTextW %x %ls", hwnd, lpsz));
    948     return window->SetWindowTextW((LPWSTR)lpsz);
     993    BOOL ret = window->SetWindowTextW((LPWSTR)lpsz);
     994    RELEASE_WNDOBJ(window);
     995    return ret;
    949996}
    950997/*******************************************************************
     
    9911038    window->getClientRect(pRect);
    9921039    dprintf(("GetClientRect of %X returned (%d,%d) (%d,%d)\n", hwndWin32, pRect->left, pRect->top, pRect->right, pRect->bottom));
     1040    RELEASE_WNDOBJ(window);
    9931041    return TRUE;
    9941042}
     
    11141162        return 0;
    11151163    }
    1116     if(hwndFrom)
    1117     {
     1164    if(hwndTo == hwndFrom)
     1165        return 0; //nothing to do
     1166
     1167    if(hwndFrom == HWND_DESKTOP)
     1168    {
     1169        windowDesktop->addRef();
     1170        wndfrom = windowDesktop;
     1171    }
     1172    else {
    11181173        wndfrom = Win32BaseWindow::GetWindowFromHandle(hwndFrom);
    11191174        if(!wndfrom) {
     
    11231178        }
    11241179    }
    1125     else wndfrom = windowDesktop;
    1126 
    1127     if(hwndTo)
    1128     {
     1180
     1181    if(hwndTo == HWND_DESKTOP)
     1182    {
     1183        windowDesktop->addRef();
     1184        wndto = windowDesktop;
     1185    }
     1186    else {
    11291187        wndto = Win32BaseWindow::GetWindowFromHandle(hwndTo);
    11301188        if(!wndto) {
     
    11341192        }
    11351193    }
    1136     else wndto = windowDesktop;
    1137 
    1138     if(wndto == wndfrom)
    1139         return 0; //nothing to do
    11401194
    11411195    dprintf2(("USER32: MapWindowPoints %x to %x (%d,%d) (%d)", hwndFrom, hwndTo, lpPoints->x, lpPoints->y, cPoints));
    11421196    WINPOS_GetWinOffset(wndfrom, wndto, &offset);
    11431197
     1198    RELEASE_WNDOBJ(wndto);
     1199    RELEASE_WNDOBJ(wndfrom);
    11441200    for(int i=0;i<cPoints;i++)
    11451201    {
     
    11541210BOOL WIN32API ScreenToClient(HWND hwnd, LPPOINT pt)
    11551211{
    1156     Win32BaseWindow *wnd;
    11571212    PRECT rcl;
    11581213    BOOL rc;
    11591214
    1160     if(!hwnd) {
    1161     return (TRUE);
    1162     }
    1163     wnd = Win32BaseWindow::GetWindowFromHandle (hwnd);
    1164     if (!wnd) {
     1215    if(hwnd == HWND_DESKTOP) {
     1216        return (TRUE); //nothing to do
     1217    }
     1218    if (!IsWindow(hwnd)) {
    11651219        dprintf(("warning: ScreenToClient: window %x not found!", hwnd));
    11661220        SetLastError(ERROR_INVALID_WINDOW_HANDLE);
     
    12801334BOOL WIN32API ClientToScreen (HWND hwnd, PPOINT pt)
    12811335{
    1282     Win32BaseWindow *wnd;
    12831336    PRECT rcl;
    12841337
    1285     if (!hwnd) {
    1286         SetLastError(ERROR_INVALID_PARAMETER);
    1287         return (FALSE);
    1288     }
    1289     wnd = Win32BaseWindow::GetWindowFromHandle (hwnd);
    1290     if (!wnd) {
     1338    if(hwnd == HWND_DESKTOP) {
     1339        return(TRUE); //nothing to do
     1340    }
     1341    if(!IsWindow(hwnd)) {
    12911342        dprintf(("warning: ClientToScreen window %x not found!", hwnd));
    12921343        SetLastError(ERROR_INVALID_WINDOW_HANDLE);
     
    13441395  int i;
    13451396  HDWP newhdwp = hdwp,retvalue;
    1346   Win32BaseWindow *window;
    13471397
    13481398    pDWP = (DWP *)hdwp;
     
    13551405        return 0;
    13561406
    1357     window = Win32BaseWindow::GetWindowFromHandle(hwnd);
    1358     if(!window) {
     1407    if(!IsWindow(hwnd)) {
    13591408        dprintf(("DeferWindowPos, window %x not found", hwnd));
    13601409        SetLastError(ERROR_INVALID_WINDOW_HANDLE);
     
    15501599    }
    15511600    dprintf(("CloseWindow %x\n", hwnd));
    1552     return window->CloseWindow();
     1601    BOOL ret = window->CloseWindow();
     1602    RELEASE_WNDOBJ(window);
     1603    return ret;
    15531604}
    15541605//******************************************************************************
     
    16421693        return 0;
    16431694    }
    1644     return window->IsWindowUnicode();
     1695    BOOL ret = window->IsWindowUnicode();
     1696    RELEASE_WNDOBJ(window);
     1697    return ret;
    16451698}
    16461699/***********************************************************************
     
    16551708BOOL WIN32API EnumThreadWindows(DWORD dwThreadId, WNDENUMPROC lpfn, LPARAM lParam)
    16561709{
    1657   return windowDesktop->EnumThreadWindows(dwThreadId, lpfn, lParam);
     1710    return windowDesktop->EnumThreadWindows(dwThreadId, lpfn, lParam);
    16581711}
    16591712//******************************************************************************
     
    16611714BOOL WIN32API EnumChildWindows(HWND hwnd, WNDENUMPROC lpfn, LPARAM lParam)
    16621715{
    1663  Win32BaseWindow *window;
    1664  BOOL   rc = TRUE;
    1665  ULONG  henum;
    1666  HWND   hwndNext;
    1667 
    1668   if(lpfn == NULL) {
    1669     dprintf(("EnumChildWindows invalid parameter %x %x\n", hwnd, lParam));
     1716    Win32BaseWindow *window;
     1717    BOOL   ret = TRUE;
     1718    ULONG  henum;
     1719    HWND   hwndNext;
     1720
     1721    if(lpfn == NULL) {
     1722        dprintf(("EnumChildWindows invalid parameter %x %x\n", hwnd, lParam));
    16701723        SetLastError(ERROR_INVALID_PARAMETER);
    16711724        return FALSE;
    1672   }
    1673   window = Win32BaseWindow::GetWindowFromHandle(hwnd);
    1674   if(!window) {
     1725    }
     1726    window = Win32BaseWindow::GetWindowFromHandle(hwnd);
     1727    if(!window) {
    16751728        dprintf(("EnumChildWindows, window %x not found", hwnd));
    16761729        SetLastError(ERROR_INVALID_WINDOW_HANDLE);
    16771730        return FALSE;
    1678   }
    1679   return window->EnumChildWindows(lpfn, lParam);
     1731    }
     1732    ret = window->EnumChildWindows(lpfn, lParam);
     1733    RELEASE_WNDOBJ(window);
     1734    return ret;
    16801735}
    16811736//******************************************************************************
     
    16831738BOOL WIN32API EnumWindows(WNDENUMPROC lpfn, LPARAM lParam)
    16841739{
    1685   return windowDesktop->EnumWindows(lpfn, lParam);
     1740    return windowDesktop->EnumWindows(lpfn, lParam);
    16861741}
    16871742//******************************************************************************
     
    16971752BOOL WIN32API OpenIcon(HWND hwnd)
    16981753{
    1699   dprintf(("USER32: OpenIcon %x", hwnd));
    1700 
    1701   if(!IsIconic(hwnd))
     1754    dprintf(("USER32: OpenIcon %x", hwnd));
     1755
     1756    if(!IsIconic(hwnd))
    17021757        return FALSE;
    1703   ShowWindow(hwnd, SW_SHOWNORMAL);
    1704   return TRUE;
     1758    ShowWindow(hwnd, SW_SHOWNORMAL);
     1759    return TRUE;
    17051760}
    17061761//******************************************************************************
     
    17111766BOOL WIN32API ShowOwnedPopups(HWND hwndOwner, BOOL fShow)
    17121767{
    1713   Win32BaseWindow *window, *owner;
    1714   HWND hwnd;
    1715 
    1716   owner = Win32BaseWindow::GetWindowFromHandle(hwndOwner);
    1717   if(!owner) {
     1768    Win32BaseWindow *window, *owner;
     1769    HWND hwnd;
     1770
     1771    owner = Win32BaseWindow::GetWindowFromHandle(hwndOwner);
     1772    if(!owner) {
    17181773        dprintf(("ShowOwnedPopups, window %x not found", hwndOwner));
    17191774        SetLastError(ERROR_INVALID_WINDOW_HANDLE);
    17201775        return FALSE;
    1721   }
    1722   dprintf(("USER32: ShowOwnedPopups %x %d", hwndOwner, fShow));
    1723 
    1724   hwnd = GetWindow(GetDesktopWindow(), GW_CHILD);
    1725   while(hwnd) {
     1776    }
     1777    dprintf(("USER32: ShowOwnedPopups %x %d", hwndOwner, fShow));
     1778
     1779    hwnd = GetWindow(GetDesktopWindow(), GW_CHILD);
     1780    while(hwnd) {
    17261781        window = Win32BaseWindow::GetWindowFromHandle(hwnd);
    17271782        if(window) {
     
    17521807                }
    17531808            }
     1809            RELEASE_WNDOBJ(window);
    17541810        }
    1755         else    dprintf(("WARNING: window %x is not valid", hwnd));
     1811        else dprintf(("WARNING: window %x is not valid", hwnd));
    17561812
    17571813        hwnd = GetWindow(hwnd, GW_HWNDNEXT);
    1758   }
    1759   return TRUE;
     1814    }
     1815    RELEASE_WNDOBJ(owner);
     1816    return TRUE;
    17601817}
    17611818//******************************************************************************
     
    18031860    }
    18041861    dprintf(("GetWindowContextHelpId %x", hwnd));
    1805     return window->getWindowContextHelpId();
     1862    DWORD ret = window->getWindowContextHelpId();
     1863    RELEASE_WNDOBJ(window);
     1864    return ret;
    18061865}
    18071866//******************************************************************************
     
    18191878    dprintf(("SetWindowContextHelpId %x %d", hwnd, dwContextHelpId));
    18201879    window->setWindowContextHelpId(dwContextHelpId);
     1880    RELEASE_WNDOBJ(window);
    18211881    return(TRUE);
    18221882}
     
    18331893        return 0;
    18341894    }
    1835     return window->getProp(str);
     1895    HANDLE ret = window->getProp(str);
     1896    RELEASE_WNDOBJ(window);
     1897    return ret;
    18361898}
    18371899//******************************************************************************
     
    18601922        return FALSE;
    18611923    }
    1862     return window->setProp(str, handle);
     1924    BOOL ret = window->setProp(str, handle);
     1925    RELEASE_WNDOBJ(window);
     1926    return ret;
    18631927}
    18641928//******************************************************************************
     
    18881952        return 0;
    18891953    }
    1890     return window->removeProp(str);
     1954    HANDLE ret = window->removeProp(str);
     1955    RELEASE_WNDOBJ(window);
     1956    return ret;
    18911957}
    18921958//******************************************************************************
     
    19281994        return -1;
    19291995    }
    1930     return window->enumPropsExA(func, lParam);
     1996    INT ret = window->enumPropsExA(func, lParam);
     1997    RELEASE_WNDOBJ(window);
     1998    return ret;
    19311999}
    19322000//******************************************************************************
     
    19422010        return -1;
    19432011    }
    1944     return window->enumPropsExW(func, lParam);
    1945 }
    1946 //******************************************************************************
    1947 //******************************************************************************
     2012    INT ret = window->enumPropsExW(func, lParam);
     2013    RELEASE_WNDOBJ(window);
     2014    return ret;
     2015}
     2016//******************************************************************************
     2017//******************************************************************************
  • trunk/src/user32/windowclass.cpp

    r5472 r5935  
    1 /* $Id: windowclass.cpp,v 1.20 2001-04-04 09:01:25 sandervl Exp $ */
     1/* $Id: windowclass.cpp,v 1.21 2001-06-09 14:50:26 sandervl Exp $ */
    22/*
    33 * Win32 Window Class Code for OS/2
     
    5252    wc.hIconSm = 0;
    5353 
    54     if(Win32WndClass::FindClass(wc.hInstance, (LPSTR)wc.lpszClassName)) {
     54    wclass = Win32WndClass::FindClass(wc.hInstance, (LPSTR)wc.lpszClassName);
     55    if(wclass) {
     56        RELEASE_CLASSOBJ(wclass);
    5557        if(HIWORD(wc.lpszClassName)) {
    5658                dprintf(("RegisterClassA %x %s already exists", wc.hInstance, wc.lpszClassName));
     
    7577        return(0);
    7678    }
    77     return(wclass->getAtom());
     79    ATOM atom = wclass->getAtom();
     80    RELEASE_CLASSOBJ(wclass);
     81    return atom;
    7882}
    7983//******************************************************************************
     
    8488 Win32WndClass *wclass;
    8589
    86     if(Win32WndClass::FindClass(lpWndClass->hInstance, (LPSTR)lpWndClass->lpszClassName)) {
     90    wclass = Win32WndClass::FindClass(lpWndClass->hInstance, (LPSTR)lpWndClass->lpszClassName);
     91    if(wclass) {
     92        RELEASE_CLASSOBJ(wclass);
    8793        if(HIWORD(lpWndClass->lpszClassName)) {
    8894                dprintf(("RegisterClassExA %x %s already exists", lpWndClass->hInstance, lpWndClass->lpszClassName));
     
    100106        return(0);
    101107    }
    102     return(wclass->getAtom());
     108    ATOM atom = wclass->getAtom();
     109    RELEASE_CLASSOBJ(wclass);
     110    return atom;
    103111}
    104112//******************************************************************************
     
    115123    memcpy(&wc.style, lpwc, sizeof(WNDCLASSA));
    116124
    117     if(Win32WndClass::FindClass(wc.hInstance, (LPWSTR)wc.lpszClassName)) {
     125    winclass = Win32WndClass::FindClass(wc.hInstance, (LPWSTR)wc.lpszClassName);
     126    if(winclass) {
     127        RELEASE_CLASSOBJ(winclass);
    118128        if(HIWORD(wc.lpszClassName)) {
    119129                dprintf(("RegisterClassW %x %ls already exists", wc.hInstance, wc.lpszClassName));
     
    139149    }
    140150    rc = winclass->getAtom();
    141 
     151    RELEASE_CLASSOBJ(winclass);
    142152    return(rc);
    143153}
     
    153163    memcpy(&wc, lpwc, sizeof(WNDCLASSEXA));
    154164
    155     if(Win32WndClass::FindClass(wc.hInstance, (LPWSTR)wc.lpszClassName)) {
     165    winclass = Win32WndClass::FindClass(wc.hInstance, (LPWSTR)wc.lpszClassName);
     166    if(winclass) {
     167        RELEASE_CLASSOBJ(winclass);
    156168        if(HIWORD(wc.lpszClassName)) {
    157169                dprintf(("RegisterClassExW %x %ls already exists", wc.hInstance, wc.lpszClassName));
     
    170182    }
    171183    rc = winclass->getAtom();
     184    RELEASE_CLASSOBJ(winclass);
    172185
    173186    return(rc);
     
    180193
    181194   ret = Win32WndClass::UnregisterClassA(hinst, (LPSTR)lpszClassName);
    182 #if 1
    183195   return ret;
    184 #else
    185   //Spintest returns FALSE in dll termination, so pretend it succeeded
    186 //  return(TRUE);
    187 #endif
    188196}
    189197//******************************************************************************
     
    204212        FreeAsciiString((char *)astring);
    205213
    206 #if 1
    207214  return ret;
    208 #else
    209   //Spintest returns FALSE in dll termination, so pretend it succeeded
    210 //  return(TRUE);
    211 #endif
    212215}
    213216//******************************************************************************
     
    227230  if(wndclass) {
    228231        wndclass->getClassInfo(&wc);
     232        RELEASE_CLASSOBJ(wndclass);
    229233        memcpy(lpwc, &wc.style, sizeof(WNDCLASSA));
    230234        SetLastError(ERROR_SUCCESS);
     
    256260  if(wndclass) {
    257261        wndclass->getClassInfo(&wc);
     262        RELEASE_CLASSOBJ(wndclass);
    258263        memcpy(lpwc, &wc.style, sizeof(WNDCLASSW));
    259264        SetLastError(ERROR_SUCCESS);
     
    295300  if(wndclass) {
    296301        wndclass->getClassInfo(lpwcx);
     302        RELEASE_CLASSOBJ(wndclass);
    297303        lpwcx->cbSize = sizeof(WNDCLASSEXA);
    298304        SetLastError(ERROR_SUCCESS);
     
    344350  if(wndclass) {
    345351        wndclass->getClassInfo(lpwcx);
     352        RELEASE_CLASSOBJ(wndclass);
    346353        lpwcx->cbSize = sizeof(WNDCLASSEXW);
    347354        SetLastError(ERROR_SUCCESS);
     
    365372    *lpszClassName = 0;
    366373    rc = (wnd->getClass())->getClassName(lpszClassName, cchClassName);
     374    RELEASE_WNDOBJ(wnd);
    367375    dprintf(("USER32: GetClassNameA %x %s (%d)", hwnd, lpszClassName, rc));
    368376    return rc;
     
    373381{
    374382 Win32BaseWindow *wnd;
     383 int              ret;
    375384
    376385    dprintf(("USER32: GetClassNameW\n"));
     
    380389        return(0);
    381390    }
    382     return (wnd->getClass())->getClassName(lpszClassName, cchClassName);
     391    ret = (wnd->getClass())->getClassName(lpszClassName, cchClassName);
     392    RELEASE_WNDOBJ(wnd);
     393    return ret;
    383394}
    384395//******************************************************************************
     
    387398{
    388399 Win32BaseWindow *wnd;
     400 LONG             ret;
    389401
    390402    wnd = Win32BaseWindow::GetWindowFromHandle(hwnd);
     
    393405        return(0);
    394406    }
    395     return (wnd->getClass())->setClassLongA(nIndex, lNewVal);
     407    ret = (wnd->getClass())->setClassLongA(nIndex, lNewVal);
     408    RELEASE_WNDOBJ(wnd);
     409    return ret;
    396410}
    397411//******************************************************************************
     
    400414{
    401415 Win32BaseWindow *wnd;
     416 LONG             ret;
    402417
    403418    wnd = Win32BaseWindow::GetWindowFromHandle(hwnd);
     
    406421        return(0);
    407422    }
    408     return (wnd->getClass())->setClassLongW(nIndex, lNewVal);
     423    ret = (wnd->getClass())->setClassLongW(nIndex, lNewVal);
     424    RELEASE_WNDOBJ(wnd);
     425    return ret;
    409426}
    410427//******************************************************************************
     
    413430{
    414431 Win32BaseWindow *wnd;
     432 LONG             ret;
    415433
    416434    dprintf(("USER32: SetClassWord %x %d %x", hwnd, nIndex, (ULONG)wNewVal));
     
    420438        return(0);
    421439    }
    422     return (wnd->getClass())->setClassWord(nIndex, wNewVal);
     440    ret = (wnd->getClass())->setClassWord(nIndex, wNewVal);
     441    RELEASE_WNDOBJ(wnd);
     442    return ret;
    423443}
    424444//******************************************************************************
     
    435455    }
    436456    ret = (wnd->getClass())->getClassWord(nIndex);
     457    RELEASE_WNDOBJ(wnd);
    437458    dprintf(("USER32: GetClassWord %x %d returned %x", hwnd, nIndex, (ULONG)ret));
    438459    return ret;
     
    451472    }
    452473    ret = (wnd->getClass())->getClassLongA(nIndex);
     474    RELEASE_WNDOBJ(wnd);
    453475    dprintf(("USER32: GetClassLongA %x %d returned %x", hwnd, nIndex, ret));
    454476    return ret;
     
    467489    }
    468490    ret = (wnd->getClass())->getClassLongW(nIndex);
     491    RELEASE_WNDOBJ(wnd);
    469492    dprintf(("USER32: GetClassLongW %x %d returned %x", hwnd, nIndex, ret));
    470493    return ret;
  • trunk/src/user32/windowmsg.cpp

    r5805 r5935  
    1 /* $Id: windowmsg.cpp,v 1.25 2001-05-25 19:59:30 sandervl Exp $ */
     1/* $Id: windowmsg.cpp,v 1.26 2001-06-09 14:50:26 sandervl Exp $ */
    22/*
    33 * Win32 window message APIs for OS/2
     
    146146{
    147147  Win32BaseWindow *window;
     148  LRESULT result;
    148149
    149150    if (hwnd == HWND_BROADCAST|| hwnd == HWND_TOPMOST)
     
    158159        return 0;
    159160    }
    160     return window->SendMessageA(msg, wParam, lParam);
     161    result = window->SendMessageA(msg, wParam, lParam);
     162    RELEASE_WNDOBJ(window);
     163    return result;
    161164}
    162165//******************************************************************************
     
    165168{
    166169  Win32BaseWindow *window;
     170  LRESULT result;
    167171
    168172    if (hwnd == HWND_BROADCAST|| hwnd == HWND_TOPMOST)
     
    177181        return 0;
    178182    }
    179     return window->SendMessageW(msg, wParam, lParam);
     183    result = window->SendMessageW(msg, wParam, lParam);
     184    RELEASE_WNDOBJ(window);
     185    return result;
    180186}
    181187//******************************************************************************
     
    184190{
    185191  Win32BaseWindow *window;
     192  HWND hwndOS2;
    186193
    187194    if (hwnd == HWND_BROADCAST) //Not HWND_TOPMOST???
     
    199206        return 0;
    200207    }
     208    hwndOS2 = window->getOS2WindowHandle();
     209    RELEASE_WNDOBJ(window);
    201210    dprintf(("PostMessageA, %x %x %x %x", hwnd, msg, wParam, lParam));
    202     return OSLibPostMessage(window->getOS2WindowHandle(), msg, wParam, lParam, FALSE);
     211    return OSLibPostMessage(hwndOS2, msg, wParam, lParam, FALSE);
    203212}
    204213//******************************************************************************
     
    207216{
    208217  Win32BaseWindow *window;
     218  HWND hwndOS2;
    209219
    210220    if (hwnd == HWND_BROADCAST) //Not HWND_TOPMOST???
     
    222232        return 0;
    223233    }
     234    hwndOS2 = window->getOS2WindowHandle();
     235    RELEASE_WNDOBJ(window);
    224236    dprintf(("PostMessageW, %x %x %x %x", hwnd, msg, wParam, lParam));
    225     return OSLibPostMessage(window->getOS2WindowHandle(), msg, wParam, lParam, TRUE);
     237    return OSLibPostMessage(hwndOS2, msg, wParam, lParam, TRUE);
    226238}
    227239//******************************************************************************
  • trunk/src/user32/windowword.cpp

    r5060 r5935  
    1 /* $Id: windowword.cpp,v 1.10 2001-02-03 18:52:03 sandervl Exp $ */
     1/* $Id: windowword.cpp,v 1.11 2001-06-09 14:50:26 sandervl Exp $ */
    22
    33/*
     
    2323{
    2424 Win32BaseWindow *window;
     25 LONG ret;
    2526
    2627    window = Win32BaseWindow::GetWindowFromHandle(hwnd);
    2728    if(window)
    2829    {
    29         return window->SetWindowLongA(nIndex,lNewLong);
     30        ret = window->SetWindowLongA(nIndex,lNewLong);
     31        RELEASE_WNDOBJ(window);
     32        return ret;
    3033    }
    3134    else {
     
    4043{
    4144 Win32BaseWindow *window;
     45 LONG ret;
    4246
    4347    window = Win32BaseWindow::GetWindowFromHandle(hwnd);
    4448    if(window)
    4549    {
    46         return window->SetWindowLongA(nIndex,lNewLong, TRUE);
     50        ret = window->SetWindowLongA(nIndex,lNewLong, TRUE);
     51        RELEASE_WNDOBJ(window);
     52        return ret;
    4753    }
    4854    else {
     
    5763{
    5864 Win32BaseWindow *window;
     65 LONG ret;
    5966
    6067    window = Win32BaseWindow::GetWindowFromHandle(hwnd);
    6168    if(window)
    6269    {
    63         return window->GetWindowWord(nIndex);
     70        ret = window->GetWindowWord(nIndex);
     71        RELEASE_WNDOBJ(window);
     72        return ret;
    6473    }
    6574    else
     
    7584{
    7685 Win32BaseWindow *window;
     86 LONG ret;
    7787
    7888    window = Win32BaseWindow::GetWindowFromHandle(hwnd);
    7989    if(window)
    8090    {
    81         return window->SetWindowWord(nIndex, arg3);
     91        ret = window->SetWindowWord(nIndex, arg3);
     92        RELEASE_WNDOBJ(window);
     93        return ret;
    8294    }
    8395    else
     
    93105{
    94106 Win32BaseWindow *window;
     107 LONG ret;
    95108
    96109    window = Win32BaseWindow::GetWindowFromHandle(hwnd);
    97110    if(window)
    98111    {
    99         return window->GetWindowLongA(nIndex);
     112        ret = window->GetWindowLongA(nIndex);
     113        RELEASE_WNDOBJ(window);
     114        return ret;
    100115    }
    101116    else
     
    111126{
    112127 Win32BaseWindow *window;
     128 LONG ret;
    113129
    114130    window = Win32BaseWindow::GetWindowFromHandle(hwnd);
    115131    if(window)
    116132    {
    117         return window->GetWindowLongA(nIndex, TRUE);
     133        ret = window->GetWindowLongA(nIndex, TRUE);
     134        RELEASE_WNDOBJ(window);
     135        return ret;
    118136    }
    119137    else
  • trunk/src/user32/winproc.cpp

    r4194 r5935  
    1 /* $Id: winproc.cpp,v 1.6 2000-09-05 19:20:38 sandervl Exp $ */
     1/* $Id: winproc.cpp,v 1.7 2001-06-09 14:50:26 sandervl Exp $ */
    22/*
    33 * Window procedure callbacks
     
    307307    else  dprintf2(("CallWindowProcA %x %x %x %x %x (unknown proc)", func, hwnd, msg, wParam, lParam));
    308308   
    309     Win32BaseWindow *window = Win32BaseWindow::GetWindowFromHandle(hwnd);
    310     if(!window) {
     309    if(!IsWindow(hwnd)) {
    311310        dprintf(("CallWindowProcA, window %x not found", hwnd));
    312311        // return func( hwnd, msg, wParam, lParam );
     
    342341    else  dprintf2(("CallWindowProcW %x %x %x %x %x (unknown proc)", func, hwnd, msg, wParam, lParam));
    343342
    344     Win32BaseWindow *window = Win32BaseWindow::GetWindowFromHandle(hwnd);
    345     if(!window) {
     343    if(!IsWindow(hwnd)) {
    346344        dprintf(("CallWindowProcW, window %x not found", hwnd));
    347345        // return func( hwnd, msg, wParam, lParam );
Note: See TracChangeset for help on using the changeset viewer.