Ignore:
Timestamp:
Dec 21, 1999, 6:03:46 PM (26 years ago)
Author:
cbratschi
Message:

WINE 991212, WM_SETREDRAW fix, MDI work

File:
1 edited

Legend:

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

    r1828 r2185  
    1 /* $Id: combo.cpp,v 1.19 1999-11-24 18:21:35 cbratschi Exp $ */
     1/* $Id: combo.cpp,v 1.20 1999-12-21 17:03:43 cbratschi Exp $ */
    22/*
    33 * Combo controls
     
    88 * FIXME: roll up in Netscape 3.01.
    99 *
    10  * WINE version: 991031
     10 * WINE version: 991212
    1111 *
    1212 * Status:  in progress
     
    115115
    116116   return DefWindowProcA(hwnd,WM_NCDESTROY,wParam,lParam);
    117 }
    118 
    119 /***********************************************************************
    120  *           CBForceDummyResize
    121  *
    122  * The dummy resize is used for listboxes that have a popup to trigger
    123  * a re-arranging of the contents of the combobox and the recalculation
    124  * of the size of the "real" control window.
    125  */
    126 static void CBForceDummyResize(
    127   LPHEADCOMBO lphc)
    128 {
    129   RECT windowRect;
    130 
    131   GetWindowRect(CB_HWND(lphc), &windowRect);
    132 
    133   /*
    134    * We have to be careful, resizing a combobox also has the meaning that the
    135    * dropped rect will be resized. In this case, we want to trigger a resize
    136    * to recalculate layout but we don't want to change the dropped rectangle
    137    * So, we add the size of the dropped rectangle to the size of the control.
    138    * this will cancel-out in the processing of the WM_WINDOWPOSCHANGING
    139    * message.
    140    */
    141   SetWindowPos( CB_HWND(lphc),
    142                 (HWND)NULL,
    143                 0, 0,
    144                 windowRect.right  - windowRect.left,
    145                 windowRect.bottom - windowRect.top +
    146                 lphc->droppedRect.bottom - lphc->droppedRect.top,
    147                 SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE );
    148117}
    149118
     
    255224}
    256225
     226/***********************************************************************
     227 *           CBForceDummyResize
     228 *
     229 * The dummy resize is used for listboxes that have a popup to trigger
     230 * a re-arranging of the contents of the combobox and the recalculation
     231 * of the size of the "real" control window.
     232 */
     233static void CBForceDummyResize(
     234  LPHEADCOMBO lphc)
     235{
     236  RECT windowRect;
     237  int newComboHeight;
     238
     239  newComboHeight = CBGetTextAreaHeight(CB_HWND(lphc),lphc) + 2*COMBO_YBORDERSIZE();
     240
     241  GetWindowRect(CB_HWND(lphc), &windowRect);
     242
     243  /*
     244   * We have to be careful, resizing a combobox also has the meaning that the
     245   * dropped rect will be resized. In this case, we want to trigger a resize
     246   * to recalculate layout but we don't want to change the dropped rectangle
     247   * So, we pass the height of text area of control as the height.
     248   * this will cancel-out in the processing of the WM_WINDOWPOSCHANGING
     249   * message.
     250   */
     251  SetWindowPos( CB_HWND(lphc),
     252                (HWND)0,
     253                0, 0,
     254                windowRect.right  - windowRect.left,
     255                newComboHeight,
     256                SWP_NOMOVE | SWP_NOZORDER | SWP_NOACTIVATE );
     257}
    257258
    258259/***********************************************************************
     
    958959static INT CBUpdateLBox( LPHEADCOMBO lphc )
    959960{
    960    INT  length, idx, ret;
     961   INT  length, idx;
    961962   LPSTR        pText = NULL;
    962963
    963    idx = ret = LB_ERR;
     964   idx = LB_ERR;
    964965   length = CB_GETEDITTEXTLENGTH( lphc );
    965966
     
    975976       idx = SendMessageA( lphc->hWndLBox, LB_FINDSTRING,
    976977                             (WPARAM)(-1), (LPARAM)pText );
    977        if( idx == LB_ERR ) idx = 0;     /* select first item */
    978        else ret = idx;
    979978       HeapFree( GetProcessHeap(), 0, pText );
    980979   }
    981 
    982    /* select entry */
    983 
    984    SendMessageA( lphc->hWndLBox, LB_SETCURSEL, (WPARAM)idx, 0 );
    985980
    986981   if( idx >= 0 )
     
    990985       SendMessageA( lphc->hWndLBox, LB_SETCARETINDEX, (WPARAM)idx, 0 );
    991986   }
    992    return ret;
     987   return idx;
    993988}
    994989
     
    1004999
    10051000   //TRACE("\t %i\n", index );
    1006 
    1007    if( index == -1 )
    1008    {
    1009        length = CB_GETEDITTEXTLENGTH( lphc );
    1010        if( length )
    1011        {
    1012            pText = (LPSTR) HeapAlloc( GetProcessHeap(), 0, length + 1);
    1013            if(pText)
    1014            {
    1015                 GetWindowTextA( lphc->hWndEdit, pText, length + 1 );
    1016                 index = SendMessageA( lphc->hWndLBox, LB_FINDSTRING,
    1017                                         (WPARAM)(-1), (LPARAM)pText );
    1018                 HeapFree( GetProcessHeap(), 0, pText );
    1019            }
    1020        }
    1021    }
    10221001
    10231002   if( index >= 0 ) /* got an entry */
     
    10311010                SendMessageA( lphc->hWndLBox, LB_GETTEXT,
    10321011                                (WPARAM)index, (LPARAM)pText );
    1033 
    1034                 lphc->wState |= CBF_NOEDITNOTIFY;
    1035 
    1036                 SendMessageA( lphc->hWndEdit, WM_SETTEXT, 0, (LPARAM)pText );
    1037                 SendMessageA( lphc->hWndEdit, EM_SETSEL, 0, (LPARAM)(-1) );
    1038                 HeapFree( GetProcessHeap(), 0, pText );
    10391012           }
    10401013       }
    10411014   }
     1015   lphc->wState |= CBF_NOEDITNOTIFY;
     1016
     1017   SendMessageA( lphc->hWndEdit, WM_SETTEXT, 0, pText ? (LPARAM)pText : (LPARAM)"" );
     1018
     1019   if( pText )
     1020       HeapFree( GetProcessHeap(), 0, pText );
    10421021}
    10431022
     
    11451124           RECT rect;
    11461125
    1147            /*
    1148             * It seems useful to send the WM_LBUTTONUP with (-1,-1) when cancelling
    1149             * and with (0,0) (anywhere in the listbox) when Oking.
    1150             */
    1151            SendMessageA( lphc->hWndLBox, WM_LBUTTONUP, 0, ok ? (LPARAM)0 : (LPARAM)(-1) );
    1152 
    11531126           lphc->wState &= ~CBF_DROPPED;
    11541127           ShowWindow( lphc->hWndLBox, SW_HIDE );
     
    11571130               ReleaseCapture();
    11581131           }
    1159 
    11601132
    11611133           if( CB_GETTYPE(lphc) == CBS_DROPDOWN )
     
    12331205      SendMessageA( lphc->hWndLBox, LB_CARETON, 0, 0 );
    12341206
    1235     if( lphc->wState & CBF_EDIT )
    1236       SendMessageA( lphc->hWndEdit, EM_SETSEL, 0, (LPARAM)(-1) );
    12371207    lphc->wState |= CBF_FOCUSED;
     1208
    12381209    if( !(lphc->wState & CBF_EDIT) )
    1239     {
    12401210      InvalidateRect(CB_HWND(lphc), &lphc->textRect, TRUE);
    1241     }
    12421211
    12431212    CB_NOTIFY( lphc, CBN_SETFOCUS );
     
    12641233  if( lphc->wState & CBF_FOCUSED )
    12651234  {
    1266     SendMessageA( lphc->hwndself, WM_LBUTTONUP, 0, (LPARAM)(-1) );
    1267 
    12681235    CBRollUp( lphc, FALSE, TRUE );
    12691236    if( IsWindow( lphc->hwndself ) )
     
    12751242
    12761243      /* redraw text */
    1277       if( lphc->wState & CBF_EDIT )
    1278         SendMessageA( lphc->hWndEdit, EM_SETSEL, (WPARAM)(-1), 0 );
    1279       else
    1280       {
     1244      if( !(lphc->wState & CBF_EDIT) )
    12811245        InvalidateRect(CB_HWND(lphc), &lphc->textRect, TRUE);
    1282       }
    12831246
    12841247      CB_NOTIFY( lphc, CBN_KILLFOCUS );
     
    13201283                //             CB_HWND(lphc), lphc->hWndEdit );
    13211284
    1322                 if( !(lphc->wState & CBF_FOCUSED) ) COMBO_EditSetFocus(lphc);
     1285                COMBO_EditSetFocus(lphc);
    13231286                break;
    13241287
     
    13911354                else lphc->wState &= ~CBF_NOROLLUP;
    13921355
     1356                if( lphc->wState & CBF_EDIT )
     1357                {
     1358                    INT index = SendMessageA(lphc->hWndLBox, LB_GETCURSEL, 0, 0);
     1359                    CBUpdateEdit( lphc, index );
     1360                    /* select text in edit, as Windows does */
     1361                    SendMessageA( lphc->hWndEdit, EM_SETSEL, 0, (LPARAM)(-1) );
     1362                }
     1363                else
     1364                    InvalidateRect(CB_HWND(lphc), &lphc->textRect, TRUE);
     1365
    13931366                CB_NOTIFY( lphc, CBN_SELCHANGE );
    1394                 InvalidateRect(CB_HWND(lphc), &lphc->textRect, TRUE);
    13951367                /* fall through */
    13961368
     
    20532025  {
    20542026    /* no LBN_SELCHANGE in this case, update manually */
    2055     InvalidateRect(CB_HWND(lphc), &lphc->textRect, TRUE);
     2027    if( lphc->wState & CBF_EDIT )
     2028        CBUpdateEdit( lphc, (INT)wParam );
     2029    else
     2030        InvalidateRect(CB_HWND(lphc), &lphc->textRect, TRUE);
     2031
    20562032    lphc->wState &= ~CBF_SELCHANGE;
    20572033  }
Note: See TracChangeset for help on using the changeset viewer.