Changeset 2185 for trunk/src/user32/combo.cpp
- Timestamp:
- Dec 21, 1999, 6:03:46 PM (26 years ago)
- 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:35cbratschi Exp $ */1 /* $Id: combo.cpp,v 1.20 1999-12-21 17:03:43 cbratschi Exp $ */ 2 2 /* 3 3 * Combo controls … … 8 8 * FIXME: roll up in Netscape 3.01. 9 9 * 10 * WINE version: 991 03110 * WINE version: 991212 11 11 * 12 12 * Status: in progress … … 115 115 116 116 return DefWindowProcA(hwnd,WM_NCDESTROY,wParam,lParam); 117 }118 119 /***********************************************************************120 * CBForceDummyResize121 *122 * The dummy resize is used for listboxes that have a popup to trigger123 * a re-arranging of the contents of the combobox and the recalculation124 * 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 the135 * dropped rect will be resized. In this case, we want to trigger a resize136 * to recalculate layout but we don't want to change the dropped rectangle137 * 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_WINDOWPOSCHANGING139 * 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 );148 117 } 149 118 … … 255 224 } 256 225 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 */ 233 static 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 } 257 258 258 259 /*********************************************************************** … … 958 959 static INT CBUpdateLBox( LPHEADCOMBO lphc ) 959 960 { 960 INT length, idx , ret;961 INT length, idx; 961 962 LPSTR pText = NULL; 962 963 963 idx = ret =LB_ERR;964 idx = LB_ERR; 964 965 length = CB_GETEDITTEXTLENGTH( lphc ); 965 966 … … 975 976 idx = SendMessageA( lphc->hWndLBox, LB_FINDSTRING, 976 977 (WPARAM)(-1), (LPARAM)pText ); 977 if( idx == LB_ERR ) idx = 0; /* select first item */978 else ret = idx;979 978 HeapFree( GetProcessHeap(), 0, pText ); 980 979 } 981 982 /* select entry */983 984 SendMessageA( lphc->hWndLBox, LB_SETCURSEL, (WPARAM)idx, 0 );985 980 986 981 if( idx >= 0 ) … … 990 985 SendMessageA( lphc->hWndLBox, LB_SETCARETINDEX, (WPARAM)idx, 0 ); 991 986 } 992 return ret;987 return idx; 993 988 } 994 989 … … 1004 999 1005 1000 //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 }1022 1001 1023 1002 if( index >= 0 ) /* got an entry */ … … 1031 1010 SendMessageA( lphc->hWndLBox, LB_GETTEXT, 1032 1011 (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 );1039 1012 } 1040 1013 } 1041 1014 } 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 ); 1042 1021 } 1043 1022 … … 1145 1124 RECT rect; 1146 1125 1147 /*1148 * It seems useful to send the WM_LBUTTONUP with (-1,-1) when cancelling1149 * and with (0,0) (anywhere in the listbox) when Oking.1150 */1151 SendMessageA( lphc->hWndLBox, WM_LBUTTONUP, 0, ok ? (LPARAM)0 : (LPARAM)(-1) );1152 1153 1126 lphc->wState &= ~CBF_DROPPED; 1154 1127 ShowWindow( lphc->hWndLBox, SW_HIDE ); … … 1157 1130 ReleaseCapture(); 1158 1131 } 1159 1160 1132 1161 1133 if( CB_GETTYPE(lphc) == CBS_DROPDOWN ) … … 1233 1205 SendMessageA( lphc->hWndLBox, LB_CARETON, 0, 0 ); 1234 1206 1235 if( lphc->wState & CBF_EDIT )1236 SendMessageA( lphc->hWndEdit, EM_SETSEL, 0, (LPARAM)(-1) );1237 1207 lphc->wState |= CBF_FOCUSED; 1208 1238 1209 if( !(lphc->wState & CBF_EDIT) ) 1239 {1240 1210 InvalidateRect(CB_HWND(lphc), &lphc->textRect, TRUE); 1241 }1242 1211 1243 1212 CB_NOTIFY( lphc, CBN_SETFOCUS ); … … 1264 1233 if( lphc->wState & CBF_FOCUSED ) 1265 1234 { 1266 SendMessageA( lphc->hwndself, WM_LBUTTONUP, 0, (LPARAM)(-1) );1267 1268 1235 CBRollUp( lphc, FALSE, TRUE ); 1269 1236 if( IsWindow( lphc->hwndself ) ) … … 1275 1242 1276 1243 /* 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) ) 1281 1245 InvalidateRect(CB_HWND(lphc), &lphc->textRect, TRUE); 1282 }1283 1246 1284 1247 CB_NOTIFY( lphc, CBN_KILLFOCUS ); … … 1320 1283 // CB_HWND(lphc), lphc->hWndEdit ); 1321 1284 1322 if( !(lphc->wState & CBF_FOCUSED) )COMBO_EditSetFocus(lphc);1285 COMBO_EditSetFocus(lphc); 1323 1286 break; 1324 1287 … … 1391 1354 else lphc->wState &= ~CBF_NOROLLUP; 1392 1355 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 1393 1366 CB_NOTIFY( lphc, CBN_SELCHANGE ); 1394 InvalidateRect(CB_HWND(lphc), &lphc->textRect, TRUE);1395 1367 /* fall through */ 1396 1368 … … 2053 2025 { 2054 2026 /* 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 2056 2032 lphc->wState &= ~CBF_SELCHANGE; 2057 2033 }
Note:
See TracChangeset
for help on using the changeset viewer.