Ignore:
Timestamp:
May 7, 2002, 3:28:13 PM (23 years ago)
Author:
sandervl
Message:

PF: SetParent mustn't change WS_CHILD; experimental getParent change; listbox/combobox fixes for MFC applications

File:
1 edited

Legend:

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

    r8301 r8377  
    1 /* $Id: win32wbase.cpp,v 1.323 2002-04-24 08:56:17 sandervl Exp $ */
     1/* $Id: win32wbase.cpp,v 1.324 2002-05-07 13:28:13 sandervl Exp $ */
    22/*
    33 * Win32 Window Base Class for OS/2
     
    27352735Win32BaseWindow *Win32BaseWindow::getParent()
    27362736{
     2737    Win32BaseWindow *wndparent = (Win32BaseWindow *)ChildWindow::getParentOfChild();
     2738    //experiment
     2739#if 0
     2740    return ((ULONG)wndparent == (ULONG)windowDesktop) ? NULL : wndparent;
     2741#else
     2742    return wndparent;
     2743#endif
     2744}
     2745//******************************************************************************
     2746//Note: does not set last error if no parent (verified in NT4, SP6)
     2747//******************************************************************************
     2748HWND Win32BaseWindow::GetParent()
     2749{
    27372750  Win32BaseWindow *wndparent = (Win32BaseWindow *)ChildWindow::getParentOfChild();
    2738   return ((ULONG)wndparent == (ULONG)windowDesktop) ? NULL : wndparent;
    2739 }
    2740 //******************************************************************************
    2741 //Note: does not set last error if no parent (verified in NT4, SP6)
    2742 //******************************************************************************
    2743 HWND Win32BaseWindow::GetParent()
    2744 {
    2745   Win32BaseWindow *wndparent = (Win32BaseWindow *)ChildWindow::getParentOfChild();
    2746 
    2747   if(getStyle() & WS_CHILD) {
    2748       if(wndparent) {
    2749           return wndparent->getWindowHandle();
    2750       }
    2751       dprintf(("WARNING: GetParent: WS_CHILD but no parent!!"));
    2752       DebugInt3();
    2753       return 0;
    2754   }
    2755   else
    2756   if(getStyle() & WS_POPUP)
    2757        return (getOwner()) ? getOwner()->getWindowHandle() : 0;
    2758   else return 0;
     2751
     2752    if(getStyle() & WS_CHILD)
     2753    {
     2754        if(wndparent) {
     2755            return wndparent->getWindowHandle();
     2756        }
     2757        dprintf(("WARNING: GetParent: WS_CHILD but no parent!!"));
     2758        DebugInt3();
     2759        return 0;
     2760    }
     2761    else
     2762    if(getStyle() & WS_POPUP)
     2763         return (getOwner()) ? getOwner()->getWindowHandle() : 0;
     2764    else return 0;
    27592765}
    27602766//******************************************************************************
     
    27622768HWND Win32BaseWindow::SetParent(HWND hwndNewParent)
    27632769{
    2764  HWND oldhwnd;
    2765  Win32BaseWindow *newparent;
    2766  Win32BaseWindow *oldparent = (Win32BaseWindow *)ChildWindow::getParentOfChild();
    2767  BOOL fShow = FALSE;
    2768 
    2769    if(oldparent) {
     2770    HWND oldhwnd;
     2771    Win32BaseWindow *newparent;
     2772    Win32BaseWindow *oldparent = (Win32BaseWindow *)ChildWindow::getParentOfChild();
     2773    BOOL fShow = FALSE;
     2774
     2775    if(oldparent) {
    27702776        oldhwnd = oldparent->getWindowHandle();
    27712777        oldparent->removeChild(this);
    2772    }
    2773    else oldhwnd = 0;
    2774 
    2775    /* Windows hides the window first, then shows it again
    2776     * including the WM_SHOWWINDOW messages and all */
    2777    if(IsWindowCreated() && (getStyle() & WS_VISIBLE)) {
     2778    }
     2779    else oldhwnd = 0;
     2780
     2781    /* Windows hides the window first, then shows it again
     2782     * including the WM_SHOWWINDOW messages and all */
     2783    if(IsWindowCreated() && (getStyle() & WS_VISIBLE)) {
    27782784        ShowWindow(SW_HIDE);
    27792785        fShow = TRUE;
    2780    }
    2781    if(oldparent) {
     2786    }
     2787    if(oldparent) {
    27822788        //release parent here (increased refcount during creation)
    27832789        RELEASE_WNDOBJ(oldparent);
    2784    }
    2785    newparent = GetWindowFromHandle(hwndNewParent);
    2786    if(newparent && !newparent->isDesktopWindow())
    2787    {
     2790    }
     2791    newparent = GetWindowFromHandle(hwndNewParent);
     2792    if(newparent && !newparent->isDesktopWindow())
     2793    {
    27882794        setParent(newparent);
    27892795        getParent()->addChild(this);
     
    27932799        if(!(getStyle() & WS_CHILD))
    27942800        {
    2795             //TODO: Send WM_STYLECHANGED msg?
    2796             setStyle(getStyle() | WS_CHILD);
    27972801            if(getWindowId())
    27982802            {
     
    28072811                     SWP_NOACTIVATE|SWP_NOSIZE);
    28082812        fParentChange = FALSE;
    2809    }
    2810    else {
     2813    }
     2814    else {
    28112815        if(newparent) RELEASE_WNDOBJ(newparent);
    28122816
     
    28162820        OSLibWinSetParent(getOS2FrameWindowHandle(), OSLIB_HWND_DESKTOP);
    28172821
    2818         //TODO: Send WM_STYLECHANGED msg?
    2819         setStyle(getStyle() & ~WS_CHILD);
    28202822        setWindowId(0);
    2821    }
    2822    /* SetParent additionally needs to make hwndChild the topmost window
    2823       in the x-order and send the expected WM_WINDOWPOSCHANGING and
    2824       WM_WINDOWPOSCHANGED notification messages.
    2825    */
    2826    if(state >= STATE_PRE_WMNCCREATE) {
     2823    }
     2824    /* SetParent additionally needs to make hwndChild the topmost window
     2825       in the x-order and send the expected WM_WINDOWPOSCHANGING and
     2826       WM_WINDOWPOSCHANGED notification messages.
     2827     */
     2828    if(state >= STATE_PRE_WMNCCREATE) {
    28272829        SetWindowPos(HWND_TOPMOST, 0, 0, 0, 0,
    28282830                     SWP_NOACTIVATE|SWP_NOMOVE|SWP_NOSIZE|(fShow? SWP_SHOWWINDOW : 0));
    28292831
    2830    /* FIXME: a WM_MOVE is also generated (in the DefWindowProc handler
    2831     * for WM_WINDOWPOSCHANGED) in Windows, should probably remove SWP_NOMOVE */
    2832    }
    2833    return oldhwnd;
     2832        /* FIXME: a WM_MOVE is also generated (in the DefWindowProc handler
     2833         * for WM_WINDOWPOSCHANGED) in Windows, should probably remove SWP_NOMOVE */
     2834    }
     2835    return oldhwnd;
    28342836}
    28352837//******************************************************************************
     
    28372839BOOL Win32BaseWindow::IsChild(HWND hwndParent)
    28382840{
    2839   // PH: Optimizer won't unroll calls to getParent() even
    2840   // in release build.
    2841   Win32BaseWindow *_parent = getParent();
     2841    // PH: Optimizer won't unroll calls to getParent() even
     2842    // in release build.
     2843    Win32BaseWindow *_parent = getParent();
    28422844   
    2843   if(_parent)
    2844   {
    2845     if(_parent->getWindowHandle() == hwndParent)
    2846       return TRUE;
    2847 
    2848     return _parent->IsChild(hwndParent);
    2849   }
    2850   else
    2851     return 0;
     2845    if(_parent)
     2846    {
     2847        if(_parent->getWindowHandle() == hwndParent)
     2848            return TRUE;
     2849   
     2850        return _parent->IsChild(hwndParent);
     2851    }
     2852    else
     2853        return 0;
    28522854}
    28532855//******************************************************************************
     
    28552857HWND Win32BaseWindow::GetTopWindow()
    28562858{
    2857  HWND             hwndTop;
    2858  Win32BaseWindow *topwindow;
     2859    HWND             hwndTop;
     2860    Win32BaseWindow *topwindow;
    28592861
    28602862    hwndTop = OSLibWinQueryWindow(getOS2WindowHandle(), QWOS_TOP);
     
    28982900HWND Win32BaseWindow::GetTopParent()
    28992901{
    2900  Win32BaseWindow *window = this;
    2901  HWND             hwndTopParent = 0;
     2902    Win32BaseWindow *window = this;
     2903    HWND             hwndTopParent = 0;
    29022904
    29032905    lock();
     
    29182920BOOL Win32BaseWindow::EnumChildWindows(WNDENUMPROC lpfn, LPARAM lParam)
    29192921{
    2920  BOOL rc = TRUE;
    2921  HWND hwnd;
    2922  Win32BaseWindow *prevchild = 0, *child = 0;
     2922    BOOL rc = TRUE;
     2923    HWND hwnd;
     2924    Win32BaseWindow *prevchild = 0, *child = 0;
    29232925
    29242926    dprintf(("EnumChildWindows of %x parameter %x %x (%x)", getWindowHandle(), lpfn, lParam, getFirstChild()));
     
    29702972BOOL Win32BaseWindow::EnumThreadWindows(DWORD dwThreadId, WNDENUMPROC lpfn, LPARAM lParam)
    29712973{
    2972  Win32BaseWindow *child = 0;
    2973  ULONG  tid, pid;
    2974  BOOL   rc;
    2975  HWND   hwnd;
     2974    Win32BaseWindow *child = 0;
     2975    ULONG  tid, pid;
     2976    BOOL   rc;
     2977    HWND   hwnd;
    29762978
    29772979    dprintf(("EnumThreadWindows %x %x %x", dwThreadId, lpfn, lParam));
     
    29952997BOOL Win32BaseWindow::EnumWindows(WNDENUMPROC lpfn, LPARAM lParam)
    29962998{
    2997  Win32BaseWindow *window;
    2998  BOOL             rc;
    2999  HWND             hwnd = WNDHANDLE_MAGIC_HIGHWORD;
    3000  DWORD            dwStyle;
     2999    Win32BaseWindow *window;
     3000    BOOL             rc;
     3001    HWND             hwnd = WNDHANDLE_MAGIC_HIGHWORD;
     3002    DWORD            dwStyle;
    30013003
    30023004    dprintf(("EnumWindows %x %x", lpfn, lParam));
     
    30493051HWND Win32BaseWindow::FindWindowEx(HWND hwndParent, HWND hwndChildAfter, ATOM atom, LPSTR lpszWindow)
    30503052{
    3051  Win32BaseWindow *parent = GetWindowFromHandle(hwndParent);
    3052  Win32BaseWindow *child  = GetWindowFromHandle(hwndChildAfter);
    3053  Win32BaseWindow *firstchild = child;
     3053    Win32BaseWindow *parent = GetWindowFromHandle(hwndParent);
     3054    Win32BaseWindow *child  = GetWindowFromHandle(hwndChildAfter);
     3055    Win32BaseWindow *firstchild = child;
    30543056
    30553057    dprintf(("FindWindowEx %x %x %x %s", hwndParent, hwndChildAfter, atom, lpszWindow));
Note: See TracChangeset for help on using the changeset viewer.