Ignore:
Timestamp:
Oct 8, 1999, 11:26:08 PM (26 years ago)
Author:
cbratschi
Message:

merged with WINE, other fixes

File:
1 edited

Legend:

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

    r949 r1203  
    1 /* $Id: listbox.cpp,v 1.1 1999-09-15 23:18:51 sandervl Exp $ */
     1/* $Id: listbox.cpp,v 1.2 1999-10-08 21:24:40 cbratschi Exp $ */
    22/*
    33 * Listbox controls
     
    55 * Copyright 1996 Alexandre Julliard
    66 * Copyright 1999 Christoph Bratschi (ported from WINE)
     7 *
     8 * WINE version: 990923
    79 */
    810
     
    624626        INT i;
    625627        LPINT16 p = (LPINT16)tabs;
    626         //dbg_decl_str(listbox, 256);
    627628
    628629        for (i = 0; i < descr->nb_tabs; i++) {
     
    764765    if (HAS_STRINGS(descr))
    765766    {
    766         if (!str) return LB_ERR;
     767        if (!str || !str[0]) return LB_ERR;
    767768        if (exact)
    768769        {
     
    17841785
    17851786
     1787/*************************************************************************
     1788 * LISTBOX_HandleLButtonDownCombo [Internal]
     1789 *
     1790 * Process LButtonDown message for the ComboListBox
     1791 *
     1792 * PARAMS
     1793 *     pWnd       [I] The windows internal structure
     1794 *     pDescr     [I] The ListBox internal structure
     1795 *     wParam     [I] Key Flag (WM_LBUTTONDOWN doc for more info)
     1796 *     x          [I] X Mouse Coordinate
     1797 *     y          [I] Y Mouse Coordinate
     1798 *
     1799 * RETURNS
     1800 *     0 since we are processing the WM_LBUTTONDOWN Message
     1801 *
     1802 * NOTES
     1803 *  This function is only to be used when a ListBox is a ComboListBox
     1804 */
     1805
     1806static LRESULT LISTBOX_HandleLButtonDownCombo( HWND hwnd, LB_DESCR *pDescr,
     1807                                               WPARAM wParam, INT x, INT y)
     1808{
     1809    RECT clientRect, screenRect;
     1810    POINT mousePos;
     1811
     1812    mousePos.x = x;
     1813    mousePos.y = y;
     1814
     1815    GetClientRect(hwnd, &clientRect);
     1816
     1817    if(PtInRect(&clientRect, mousePos))
     1818    {
     1819        /* MousePos is in client, resume normal processing */
     1820        return LISTBOX_HandleLButtonDown( hwnd, pDescr, wParam, x, y);
     1821    }
     1822    else
     1823    {
     1824        POINT screenMousePos;
     1825        HWND hWndOldCapture;
     1826
     1827        /* Check the Non-Client Area */
     1828        screenMousePos = mousePos;
     1829        hWndOldCapture = GetCapture();
     1830        ReleaseCapture();
     1831        GetWindowRect(hwnd, &screenRect);
     1832        ClientToScreen(hwnd, &screenMousePos);
     1833
     1834        if(!PtInRect(&screenRect, screenMousePos))
     1835        {
     1836            /* Close The Drop Down */
     1837            SEND_NOTIFICATION( hwnd, pDescr, LBN_SELCANCEL );
     1838            return 0;
     1839        }
     1840        else
     1841        {
     1842            /* Check to see the NC is a scrollbar */
     1843            INT nHitTestType=0;
     1844            DWORD dwStyle = GetWindowLongA(hwnd,GWL_STYLE);
     1845            /* Check Vertical scroll bar */
     1846            if (dwStyle & WS_VSCROLL)
     1847            {
     1848                clientRect.right += GetSystemMetrics(SM_CXVSCROLL);
     1849                if (PtInRect( &clientRect, mousePos ))
     1850                {
     1851                    nHitTestType = HTVSCROLL;
     1852                }
     1853            }
     1854              /* Check horizontal scroll bar */
     1855            if (dwStyle & WS_HSCROLL)
     1856            {
     1857                clientRect.bottom += GetSystemMetrics(SM_CYHSCROLL);
     1858                if (PtInRect( &clientRect, mousePos ))
     1859                {
     1860                    nHitTestType = HTHSCROLL;
     1861                }
     1862            }
     1863            /* Windows sends this message when a scrollbar is clicked
     1864             */
     1865
     1866            if(nHitTestType != 0)
     1867            {
     1868                SendMessageA(hwnd, WM_NCLBUTTONDOWN, nHitTestType,
     1869                    MAKELONG(screenMousePos.x, screenMousePos.y));
     1870            }
     1871            /* Resume the Capture after scrolling is complete
     1872             */
     1873            if(hWndOldCapture != 0)
     1874            {
     1875                SetCapture(hWndOldCapture);
     1876            }
     1877        }
     1878    }
     1879    return 0;
     1880}
     1881
     1882
    17861883/***********************************************************************
    17871884 *           LISTBOX_HandleLButtonUp
     
    21622259    {
    21632260        switch (msg)
    2164         {
    2165             case WM_CREATE:
    2166             {
     2261        {
     2262            case WM_CREATE:
     2263            {
    21672264                if (!LISTBOX_Create( hwnd, NULL ))
    2168                      return -1;
    2169                 //TRACE("creating wnd=%04x descr=%p\n",
    2170                 //      hwnd, *(LB_DESCR **)wnd->wExtra );
    2171                 return 0;
    2172             }
    2173             case WM_NCCREATE:
    2174             {
    2175                 DWORD dwStyle = GetWindowLongA(hwnd,GWL_STYLE);
    2176        
    2177                 /*
    2178                 * When a listbox is not in a combobox and the look
    2179                 * is win95,  the WS_BORDER style is replaced with
    2180                 * the WS_EX_CLIENTEDGE style.
    2181                 */
    2182                 if (dwStyle & WS_BORDER)
    2183                 {
    2184                     SetWindowLongA(hwnd,GWL_EXSTYLE,GetWindowLongA(hwnd,GWL_EXSTYLE) | WS_EX_CLIENTEDGE);
    2185                     SetWindowLongA(hwnd,GWL_STYLE,GetWindowLongA(hwnd,GWL_STYLE)  & ~ WS_BORDER);
    2186                 }
    2187             }
    2188         }
     2265                     return -1;
     2266                //TRACE("creating wnd=%04x descr=%p\n",
     2267                //      hwnd, *(LB_DESCR **)wnd->wExtra );
     2268                return 0;
     2269            }
     2270            case WM_NCCREATE:
     2271            {
     2272                DWORD dwStyle = GetWindowLongA(hwnd,GWL_STYLE);
     2273
     2274                /*
     2275                * When a listbox is not in a combobox and the look
     2276                * is win95,  the WS_BORDER style is replaced with
     2277                * the WS_EX_CLIENTEDGE style.
     2278                */
     2279                if (dwStyle & WS_BORDER)
     2280                {
     2281                    SetWindowLongA(hwnd,GWL_EXSTYLE,GetWindowLongA(hwnd,GWL_EXSTYLE) | WS_EX_CLIENTEDGE);
     2282                    SetWindowLongA(hwnd,GWL_STYLE,GetWindowLongA(hwnd,GWL_STYLE)  & ~ WS_BORDER);
     2283                }
     2284            }
     2285        }
    21892286        /* Ignore all other messages before we get a WM_CREATE */
    21902287        return DefWindowProcA( hwnd, msg, wParam, lParam );
     
    22142311           return descr->nb_items;
    22152312        else
    2216            return LB_ERR;       
     2313           return LB_ERR;
    22172314
    22182315    case LB_GETITEMDATA:
     
    25612658                    * the mouse is captured to show the tracking of the item.
    25622659                    */
    2563                    captured = descr->captured;
    2564                    descr->captured = TRUE;
    2565 
    2566                    LISTBOX_HandleMouseMove( hwnd,
    2567                                             descr,
    2568                                             mousePos.x, mousePos.y);
    2569 
    2570                    descr->captured = captured;
    2571 
    2572                    /*
    2573                     * However, when tracking, it is important that we do not
    2574                     * perform a selection if the cursor is outside the list.
    2575                     */
     2660
    25762661                   GetClientRect(hwnd, &clientRect);
    2577 
    2578                    if (!PtInRect( &clientRect, mousePos ))
     2662                   if (PtInRect( &clientRect, mousePos ))
     2663                   {
     2664                       captured = descr->captured;
     2665                       descr->captured = TRUE;                 
     2666               
     2667                       LISTBOX_HandleMouseMove( hwnd, descr,
     2668                                                    mousePos.x, mousePos.y);
     2669                       descr->captured = captured;
     2670                   }
     2671                   else
    25792672                   {
    2580                      LISTBOX_MoveCaret( hwnd, descr, -1, FALSE );
     2673                       LISTBOX_HandleMouseMove( hwnd, descr,
     2674                                                    mousePos.x, mousePos.y);
    25812675                   }
     2676
    25822677
    25832678                   return 0;
     
    26202715                 return LISTBOX_HandleLButtonUp( hwnd, descr );
    26212716            case WM_LBUTTONDOWN:
    2622                  return LISTBOX_HandleLButtonDown( hwnd, descr, wParam,
     2717                 return LISTBOX_HandleLButtonDownCombo( hwnd, descr, wParam,
    26232718                         (INT16)LOWORD(lParam), (INT16)HIWORD(lParam));
    2624             /* avoid activation at all costs */
    2625              case WM_MOUSEACTIVATE:
     2719            case WM_MOUSEACTIVATE:
    26262720                 return MA_NOACTIVATE;
    26272721            case WM_NCACTIVATE:
Note: See TracChangeset for help on using the changeset viewer.