Changeset 8377 for trunk/src


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

Location:
trunk/src/user32
Files:
2 edited

Legend:

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

    r8301 r8377  
    1 /* $Id: listbox.cpp,v 1.28 2002-04-24 08:56:16 sandervl Exp $ */
     1/* $Id: listbox.cpp,v 1.29 2002-05-07 13:28:12 sandervl Exp $ */
    22/*
    33 * Listbox controls
     
    17711771
    17721772    if (descr->style & LBS_MULTICOLUMN) return 0;
     1773    dprintf(("We are handling scroll"));
    17731774    switch(LOWORD(wParam))
    17741775    {
     
    20382039      if (!PtInRect(&screenRect,screenMousePos))
    20392040      {
     2041        dprintf(("Scrollbar hittest - plain branch"));
    20402042        ReleaseCapture();
     2043        LISTBOX_SetCaretIndex( hwnd, pDescr, pDescr->lphc->droppedIndex, FALSE );
    20412044        LISTBOX_SetSelection( hwnd, pDescr, pDescr->lphc->droppedIndex, FALSE, FALSE );
    20422045#ifdef __WIN32OS2__
    20432046        COMBO_RollupListbox(pDescr->lphc);
    20442047 
    2045        /* @@PF Previous code is all wrong here. Here we are supposed to close
     2048         /* @@PF Previous code is all wrong here. Here we are supposed to close
    20462049         and only close dropdown, instead flip, flips it. This happens because
    20472050         previous code did not pay attention to the fact that combobox can be
     
    20522055#endif
    20532056        return 0;
    2054       } else
     2057      }
     2058      else
    20552059      {
    2056         /* Check to see the NC is a scrollbar */
    2057         INT nHitTestType = SendMessageA(hwnd,WM_NCHITTEST,0,MAKELONG(screenMousePos.x,screenMousePos.y));
    2058 
    2059         /* Windows sends this message when a scrollbar is clicked
    2060          */
    2061         if (nHitTestType != HTCLIENT)
    2062         {
    2063           SendMessageA(hwnd,(msg == WM_LBUTTONDOWN) ? WM_NCLBUTTONDOWN:WM_NCLBUTTONDBLCLK,nHitTestType,MAKELONG(screenMousePos.x,screenMousePos.y));
    2064         }
    2065 
    2066         /* Resume the Capture after scrolling is complete
    2067          */
    2068         if (hWndOldCapture)
    2069         {
    2070           SetCapture(hWndOldCapture);
    2071         }
     2060            INT nHitTestType=0;
     2061            LONG style = GetWindowLongA( hwnd, GWL_STYLE );
     2062            /* Check Vertical scroll bar */
     2063            if (style & WS_VSCROLL)
     2064            {
     2065                clientRect.right += GetSystemMetrics(SM_CXVSCROLL);
     2066                if (PtInRect( &clientRect, mousePos ))
     2067                {
     2068                    nHitTestType = HTVSCROLL;
     2069                }
     2070            }
     2071              /* Check horizontal scroll bar */
     2072            if (style & WS_HSCROLL)
     2073            {
     2074                clientRect.bottom += GetSystemMetrics(SM_CYHSCROLL);
     2075                if (PtInRect( &clientRect, mousePos ))
     2076                {
     2077                    nHitTestType = HTHSCROLL;
     2078                }
     2079            }
     2080            /* Windows sends this message when a scrollbar is clicked
     2081             */
     2082
     2083            if(nHitTestType != 0)
     2084            {
     2085                SendMessageW(hwnd, WM_NCLBUTTONDOWN, nHitTestType,
     2086                    MAKELONG(screenMousePos.x, screenMousePos.y));
     2087            }
     2088            /* Resume the Capture after scrolling is complete
     2089             */
     2090            if(hWndOldCapture != 0)
     2091            {
     2092                SetCapture(hWndOldCapture);
     2093            }
     2094
    20722095      }
    20732096    }
  • 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.