Changeset 3144 for trunk/src/user32/listbox.cpp
- Timestamp:
- Mar 17, 2000, 6:12:08 PM (25 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/user32/listbox.cpp
r3117 r3144 1 /* $Id: listbox.cpp,v 1.2 2 2000-03-14 18:27:25cbratschi Exp $ */1 /* $Id: listbox.cpp,v 1.23 2000-03-17 17:12:07 cbratschi Exp $ */ 2 2 /* 3 3 * Listbox controls … … 8 8 * Corel version: 20000212 9 9 * WINE version: 991212 10 * 11 * Status: ??? 12 * Version: ??? 10 13 */ 11 14 … … 24 27 25 28 /* Unimplemented yet: 26 * - LBS_NOSEL 27 * - LBS_USETABSTOPS 28 * - Unicode 29 * - Locale handling 29 - LBS_NOSEL 30 - LBS_USETABSTOPS 31 - Locale handling 32 - OS/2 default font bug: Odin about dialog -> LISTBOX_UpdateSize 33 - WS_EX_NOPARENTNOTIFY 34 - VK_LINEDOWN -> bottom most item not always visible 35 - performance not optimized 30 36 */ 31 37 … … 459 465 460 466 /*********************************************************************** 461 * LISTBOX_ PaintItem462 * 463 * Paintan item.464 */ 465 static void LISTBOX_ PaintItem( HWND hwnd, LB_DESCR *descr, HDC hdc,467 * LISTBOX_DrawItem 468 * 469 * Draw an item. 470 */ 471 static void LISTBOX_DrawItem( HWND hwnd, LB_DESCR *descr, HDC hdc, 466 472 const RECT *rect, INT index, UINT action ) 467 473 { … … 557 563 * Change the redraw flag. 558 564 */ 559 static voidLISTBOX_SetRedraw( HWND hwnd, LB_DESCR *descr, BOOL on )565 static LRESULT LISTBOX_SetRedraw( HWND hwnd, LB_DESCR *descr, BOOL on ) 560 566 { 561 567 if (on) 562 568 { 563 if (!(descr->style & LBS_NOREDRAW)) return ;569 if (!(descr->style & LBS_NOREDRAW)) return 0; 564 570 descr->style &= ~LBS_NOREDRAW; 565 571 LISTBOX_UpdateScroll( hwnd, descr ); 566 572 } 567 573 else descr->style |= LBS_NOREDRAW; 574 575 return 0; 568 576 } 569 577 … … 595 603 SetTextColor( hdc, GetSysColor( COLOR_GRAYTEXT ) ); 596 604 SetWindowOrgEx( hdc, descr->horz_pos, 0, NULL ); 597 LISTBOX_ PaintItem( hwnd, descr, hdc, &rect, index, action );605 LISTBOX_DrawItem( hwnd, descr, hdc, &rect, index, action ); 598 606 if (oldFont) SelectObject( hdc, oldFont ); 599 607 if (oldBrush) SelectObject( hdc, oldBrush ); … … 865 873 866 874 /*********************************************************************** 867 * LISTBOX_ Paint868 */ 869 static LRESULT LISTBOX_ Paint( HWND hwnd, LB_DESCR *descr, HDC hdc )875 * LISTBOX_Draw 876 */ 877 static LRESULT LISTBOX_Draw( HWND hwnd, LB_DESCR *descr, HDC hdc ) 870 878 { 871 879 INT i, col_pos = descr->page_size - 1; … … 897 905 /* Special case for empty listbox: paint focus rect */ 898 906 rect.bottom = rect.top + descr->item_height; 899 LISTBOX_ PaintItem( hwnd, descr, hdc, &rect, descr->focus_item,907 LISTBOX_DrawItem( hwnd, descr, hdc, &rect, descr->focus_item, 900 908 ODA_FOCUS ); 901 909 rect.top = rect.bottom; … … 909 917 rect.bottom = rect.top + descr->items[i].height; 910 918 911 LISTBOX_ PaintItem( hwnd, descr, hdc, &rect, i, ODA_DRAWENTIRE );919 LISTBOX_DrawItem( hwnd, descr, hdc, &rect, i, ODA_DRAWENTIRE ); 912 920 rect.top = rect.bottom; 913 921 … … 1100 1108 * Returns the item height. 1101 1109 */ 1102 static INT LISTBOX_SetFont( HWND hwnd, LB_DESCR *descr, HFONT font)1110 static LRESULT LISTBOX_SetFont(HWND hwnd,LB_DESCR *descr,WPARAM wParam,LPARAM lParam) 1103 1111 { 1104 1112 HDC hdc; … … 1106 1114 TEXTMETRICA tm; 1107 1115 1108 descr->font = font;1116 descr->font = (HFONT)wParam; 1109 1117 1110 1118 if (!(hdc = GetDCEx( hwnd, 0, DCX_CACHE ))) 1111 1119 { 1112 //ERR("unable to get DC.\n" ); 1113 return 16; 1114 } 1115 if (font) oldFont = SelectObject( hdc, font ); 1120 //ERR("unable to get DC.\n" ); 1121 descr->item_height = 16; 1122 return 0; 1123 } 1124 if (descr->font) oldFont = SelectObject(hdc,descr->font); 1116 1125 GetTextMetricsA( hdc, &tm ); 1117 1126 if (oldFont) SelectObject( hdc, oldFont ); … … 1119 1128 if (!IS_OWNERDRAW(descr)) 1120 1129 LISTBOX_SetItemHeight( hwnd, descr, 0, tm.tmHeight ); 1121 return tm.tmHeight ; 1130 1131 descr->item_height = tm.tmHeight; 1132 1133 if (lParam) InvalidateRect( hwnd, 0, TRUE ); 1134 1135 return 0; 1122 1136 } 1123 1137 … … 1245 1259 { 1246 1260 INT oldsel = descr->selected_item; 1247 1261 //SvL: Why was this commented out??? (enabled in latest wine code) 1248 1262 if (index == oldsel) return LB_OKAY; 1249 1263 … … 1403 1417 } 1404 1418 1419 static LRESULT LISTBOX_AddString(HWND hwnd,LB_DESCR *descr,WPARAM wParam,LPARAM lParam) 1420 { 1421 wParam = LISTBOX_FindStringPos( hwnd, descr, (LPCSTR)lParam, FALSE ); 1422 return LISTBOX_InsertString( hwnd, descr, wParam, (LPCSTR)lParam ); 1423 } 1424 1425 static LRESULT LISTBOX_AddFile(HWND hwnd,LB_DESCR *descr,WPARAM wParam,LPARAM lParam) 1426 { 1427 wParam = LISTBOX_FindFileStrPos( hwnd, descr, (LPCSTR)lParam ); 1428 return LISTBOX_InsertString( hwnd, descr, wParam, (LPCSTR)lParam ); 1429 } 1405 1430 1406 1431 /*********************************************************************** … … 1498 1523 } 1499 1524 1525 static LRESULT LISTBOX_DeleteString(HWND hwnd,LB_DESCR *descr,WPARAM wParam,LPARAM lParam) 1526 { 1527 if (LISTBOX_RemoveItem( hwnd, descr, wParam) != LB_ERR) 1528 return descr->nb_items; 1529 else 1530 return LB_ERR; 1531 } 1500 1532 1501 1533 /*********************************************************************** 1502 1534 * LISTBOX_ResetContent 1503 1535 */ 1504 static void LISTBOX_ResetContent( HWND hwnd, LB_DESCR *descr)1536 static LRESULT LISTBOX_ResetContent( HWND hwnd, LB_DESCR *descr,BOOL refresh) 1505 1537 { 1506 1538 INT i; … … 1514 1546 descr->anchor_item = -1; 1515 1547 descr->items = NULL; 1516 LISTBOX_UpdateScroll( hwnd, descr ); 1517 InvalidateRect( hwnd, NULL, TRUE ); 1548 if (refresh) 1549 { 1550 LISTBOX_UpdateScroll( hwnd, descr ); 1551 InvalidateRect( hwnd, NULL, TRUE ); 1552 } 1553 1554 return 0; 1518 1555 } 1519 1556 … … 1525 1562 { 1526 1563 LRESULT ret; 1564 INT oldcount = descr->nb_items; 1527 1565 1528 1566 if (HAS_STRINGS(descr) || !HAS_NODATA(descr)) return LB_ERR; … … 1581 1619 LISTBOX_UpdateScroll( hwnd, descr ); 1582 1620 InvalidateRect(hwnd,NULL,TRUE); 1621 1622 /* Move selection and focused item */ 1623 /* If listbox was empty, set focus to the first item */ 1624 if (oldcount == 0) 1625 LISTBOX_SetCaretIndex( hwnd, descr, 0, FALSE ); 1583 1626 1584 1627 return LB_OKAY; … … 1789 1832 UINT pulScrollLines = 3; 1790 1833 1834 if (wParam & (MK_SHIFT | MK_CONTROL)) 1835 return DefWindowProcA(hwnd,WM_MOUSEWHEEL,wParam,lParam); 1836 1791 1837 SystemParametersInfoW(SPI_GETWHEELSCROLLLINES,0, &pulScrollLines, 0); 1792 1838 … … 2039 2085 * WM_MOUSEMOVE handler. 2040 2086 */ 2041 static voidLISTBOX_HandleMouseMove( HWND hwnd, LB_DESCR *descr,2087 static LRESULT LISTBOX_HandleMouseMove( HWND hwnd, LB_DESCR *descr, 2042 2088 INT x, INT y ) 2043 2089 { … … 2045 2091 TIMER_DIRECTION dir; 2046 2092 2047 if (!descr->captured) return; 2093 if (GetCapture() != hwnd) return 0; 2094 if (!descr->captured) return 0; 2048 2095 2049 2096 if (descr->style & LBS_MULTICOLUMN) … … 2084 2131 2085 2132 LISTBOX_Timer = dir; 2133 2134 return 0; 2086 2135 } 2087 2136 … … 2230 2279 * LISTBOX_Create 2231 2280 */ 2232 static BOOLLISTBOX_Create( HWND hwnd, LPHEADCOMBO lphc )2281 static LRESULT LISTBOX_Create( HWND hwnd, LPHEADCOMBO lphc ) 2233 2282 { 2234 2283 LB_DESCR *descr; … … 2237 2286 2238 2287 if (!(descr = (LB_DESCR*)HeapAlloc( GetProcessHeap(), 0, sizeof(*descr) ))) 2239 return FALSE;2288 return -1; 2240 2289 if (!(descr->heap = HeapCreate( 0, 0x10000, 0 ))) 2241 2290 { 2242 2291 HeapFree( GetProcessHeap(), 0, descr ); 2243 return FALSE;2292 return -1; 2244 2293 } 2245 2294 GetClientRect( hwnd, &rect ); … … 2282 2331 if (descr->style & LBS_MULTICOLUMN) descr->style &= ~LBS_OWNERDRAWVARIABLE; 2283 2332 if (descr->style & LBS_OWNERDRAWVARIABLE) descr->style |= LBS_NOINTEGRALHEIGHT; 2284 descr->item_height = LISTBOX_SetFont( hwnd, descr, 0);2333 LISTBOX_SetFont(hwnd,descr,0,(LPARAM)FALSE); 2285 2334 2286 2335 if (descr->style & LBS_OWNERDRAWFIXED) … … 2306 2355 } 2307 2356 2308 return TRUE; 2309 } 2310 2357 return 0; 2358 } 2359 2360 static LRESULT LISTBOX_NCCreate(HWND hwnd,WPARAM wParam,LPARAM lParam) 2361 { 2362 DWORD dwStyle = GetWindowLongA(hwnd,GWL_STYLE); 2363 2364 /* 2365 * When a listbox is not in a combobox and the look 2366 * is win95, the WS_BORDER style is replaced with 2367 * the WS_EX_CLIENTEDGE style. 2368 */ 2369 if (dwStyle & WS_BORDER) 2370 { 2371 SetWindowLongA(hwnd,GWL_EXSTYLE,GetWindowLongA(hwnd,GWL_EXSTYLE) | WS_EX_CLIENTEDGE); 2372 SetWindowLongA(hwnd,GWL_STYLE,GetWindowLongA(hwnd,GWL_STYLE) & ~ WS_BORDER); 2373 } 2374 2375 return DefWindowProcA(hwnd,WM_NCCREATE,wParam,lParam); 2376 } 2311 2377 2312 2378 /*********************************************************************** … … 2315 2381 static BOOL LISTBOX_Destroy( HWND hwnd, LB_DESCR *descr ) 2316 2382 { 2317 LISTBOX_ResetContent( hwnd, descr);2383 LISTBOX_ResetContent(hwnd,descr,FALSE); 2318 2384 HeapDestroy( descr->heap ); 2319 2385 HeapFree( GetProcessHeap(), 0, descr ); … … 2322 2388 } 2323 2389 2390 static LRESULT LISTBOX_GetItemData(HWND hwnd,LB_DESCR *descr,WPARAM wParam,LPARAM lParam) 2391 { 2392 if (((INT)wParam < 0) || ((INT)wParam >= descr->nb_items)) 2393 return LB_ERR; 2394 return descr->items[wParam].data; 2395 } 2396 2397 static LRESULT LISTBOX_SetItemData(HWND hwnd,LB_DESCR *descr,WPARAM wParam,LPARAM lParam) 2398 { 2399 if (((INT)wParam < 0) || ((INT)wParam >= descr->nb_items)) 2400 return LB_ERR; 2401 descr->items[wParam].data = (DWORD)lParam; 2402 return LB_OKAY; 2403 } 2404 2405 static LRESULT LISTBOX_GetCount(HWND hwnd,LB_DESCR *descr,WPARAM wParam,LPARAM lParam) 2406 { 2407 return descr->nb_items; 2408 } 2409 2410 static LRESULT LISTBOX_GetTextLen(HWND hwnd,LB_DESCR *descr,WPARAM wParam,LPARAM lParam) 2411 { 2412 if (wParam >= descr->nb_items) 2413 return LB_ERR; 2414 return (HAS_STRINGS(descr) ? strlen(descr->items[wParam].str) 2415 : sizeof(DWORD)); 2416 } 2417 2418 static LRESULT LISTBOX_GetCurSel(HWND hwnd,LB_DESCR *descr,WPARAM wParam,LPARAM lParam) 2419 { 2420 if (descr->nb_items==0) 2421 return LB_ERR; 2422 if (!IS_MULTISELECT(descr)) 2423 return descr->selected_item; 2424 /* else */ 2425 if (descr->selected_item!=-1) 2426 return descr->selected_item; 2427 /* else */ 2428 return descr->focus_item; 2429 /* otherwise, if the user tries to move the selection with the */ 2430 /* arrow keys, we will give the application something to choke on */ 2431 } 2432 2433 static LRESULT LISTBOX_GetTopIndex(HWND hwnd,LB_DESCR *descr,WPARAM wParam,LPARAM lParam) 2434 { 2435 return descr->top_item; 2436 } 2437 2438 static LRESULT LISTBOX_ItemFromPoint(HWND hwnd,LB_DESCR *descr,WPARAM wParam,LPARAM lParam) 2439 { 2440 POINT pt; 2441 RECT rect; 2442 2443 pt.x = LOWORD(lParam); 2444 pt.y = HIWORD(lParam); 2445 rect.left = 0; 2446 rect.top = 0; 2447 rect.right = descr->width; 2448 rect.bottom = descr->height; 2449 2450 return MAKELONG( LISTBOX_GetItemFromPoint(hwnd, descr, pt.x, pt.y), 2451 !PtInRect( &rect, pt ) ); 2452 } 2453 2454 static LRESULT LISTBOX_HandleSetCaretIndex(HWND hwnd,LB_DESCR *descr,WPARAM wParam,LPARAM lParam) 2455 { 2456 if ((!IS_MULTISELECT(descr)) && (descr->selected_item != -1)) return LB_ERR; 2457 if (LISTBOX_SetCaretIndex( hwnd, descr, wParam, !lParam ) == LB_ERR) 2458 return LB_ERR; 2459 else 2460 return LB_OKAY; 2461 } 2462 2463 static LRESULT LISTBOX_GetCaretIndex(HWND hwnd,LB_DESCR *descr,WPARAM wParam,LPARAM lParam) 2464 { 2465 return descr->focus_item; 2466 } 2467 2468 static LRESULT LISTBOX_SelectString(HWND hwnd,LB_DESCR *descr,WPARAM wParam,LPARAM lParam) 2469 { 2470 INT index = LISTBOX_FindString( hwnd, descr, wParam, 2471 (LPCSTR)lParam, FALSE ); 2472 if (index == LB_ERR) 2473 return LB_ERR; 2474 LISTBOX_SetSelection( hwnd, descr, index, TRUE, FALSE ); 2475 return index; 2476 } 2477 2478 static LRESULT LISTBOX_GetSel(HWND hwnd,LB_DESCR *descr,WPARAM wParam,LPARAM lParam) 2479 { 2480 if (((INT)wParam < 0) || ((INT)wParam >= descr->nb_items)) 2481 return LB_ERR; 2482 return descr->items[wParam].selected; 2483 } 2484 2485 static LRESULT LISTBOX_SetCurSel(HWND hwnd,LB_DESCR *descr,WPARAM wParam,LPARAM lParam) 2486 { 2487 if (IS_MULTISELECT(descr)) return LB_ERR; 2488 LISTBOX_SetCaretIndex( hwnd, descr, wParam, TRUE ); 2489 return LISTBOX_SetSelection( hwnd, descr, wParam, TRUE, FALSE ); 2490 } 2491 2492 static LRESULT LISTBOX_SelItemRange(HWND hwnd,LB_DESCR *descr,WPARAM wParam,LPARAM lParam) 2493 { 2494 if (LOWORD(lParam) <= HIWORD(lParam)) 2495 return LISTBOX_SelectItemRange( hwnd, descr, LOWORD(lParam), 2496 HIWORD(lParam), wParam ); 2497 else 2498 return LISTBOX_SelectItemRange( hwnd, descr, HIWORD(lParam), 2499 LOWORD(lParam), wParam ); 2500 } 2501 2502 static LRESULT LISTBOX_SelItemRangeEx(HWND hwnd,LB_DESCR *descr,WPARAM wParam,LPARAM lParam) 2503 { 2504 if ((INT)lParam >= (INT)wParam) 2505 return LISTBOX_SelectItemRange( hwnd, descr, wParam, lParam, TRUE ); 2506 else 2507 return LISTBOX_SelectItemRange( hwnd, descr, lParam, wParam, FALSE); 2508 } 2509 2510 static LRESULT LISTBOX_GetHorizontalExtent(HWND hwnd,LB_DESCR *descr,WPARAM wParam,LPARAM lParam) 2511 { 2512 return descr->horz_extent; 2513 } 2514 2515 static LRESULT LISTBOX_GetAnchorIndex(HWND hwnd,LB_DESCR *descr,WPARAM wParam,LPARAM lParam) 2516 { 2517 return descr->anchor_item; 2518 } 2519 2520 static LRESULT LISTBOX_SetAnchorIndex(HWND hwnd,LB_DESCR *descr,WPARAM wParam,LPARAM lParam) 2521 { 2522 if (((INT)wParam < -1) || ((INT)wParam >= descr->nb_items)) 2523 return LB_ERR; 2524 descr->anchor_item = (INT)wParam; 2525 return LB_OKAY; 2526 } 2527 2528 static LRESULT LISTBOX_GetLocale(HWND hwnd,LB_DESCR *descr,WPARAM wParam,LPARAM lParam) 2529 { 2530 return descr->locale; 2531 } 2532 2533 static LRESULT LISTBOX_SetLocale(HWND hwnd,LB_DESCR *descr,WPARAM wParam,LPARAM lParam) 2534 { 2535 descr->locale = (LCID)wParam; /* FIXME: should check for valid lcid */ 2536 return LB_OKAY; 2537 } 2538 2539 static LRESULT LISTBOX_CaretOn(HWND hwnd,LB_DESCR *descr,WPARAM wParam,LPARAM lParam) 2540 { 2541 if (descr->caret_on) 2542 return LB_OKAY; 2543 descr->caret_on = TRUE; 2544 if ((descr->focus_item != -1) && (descr->in_focus)) 2545 LISTBOX_RepaintItem( hwnd, descr, descr->focus_item, ODA_FOCUS ); 2546 return LB_OKAY; 2547 } 2548 2549 static LRESULT LISTBOX_CaretOff(HWND hwnd,LB_DESCR *descr,WPARAM wParam,LPARAM lParam) 2550 { 2551 if (!descr->caret_on) 2552 return LB_OKAY; 2553 descr->caret_on = FALSE; 2554 if ((descr->focus_item != -1) && (descr->in_focus)) 2555 LISTBOX_RepaintItem( hwnd, descr, descr->focus_item, ODA_FOCUS ); 2556 return LB_OKAY; 2557 } 2558 2559 static LRESULT LISTBOX_Enable(HWND hwnd,LB_DESCR *descr,WPARAM wParam,LPARAM lParam) 2560 { 2561 InvalidateRect( hwnd, NULL, TRUE ); 2562 return 0; 2563 } 2564 2565 static LRESULT LISTBOX_GetDlgCode(HWND hwnd,LB_DESCR *descr,WPARAM wParam,LPARAM lParam) 2566 { 2567 return DLGC_WANTARROWS | DLGC_WANTCHARS; 2568 } 2569 2570 static LRESULT LISTBOX_Paint(HWND hwnd,LB_DESCR *descr,WPARAM wParam,LPARAM lParam) 2571 { 2572 PAINTSTRUCT ps; 2573 HDC hdc = ( wParam ) ? ((HDC)wParam) : BeginPaint( hwnd, &ps ); 2574 LRESULT ret; 2575 2576 ret = LISTBOX_Draw( hwnd, descr, hdc ); 2577 if( !wParam ) EndPaint( hwnd, &ps ); 2578 2579 return ret; 2580 } 2581 2582 static LRESULT LISTBOX_Size(HWND hwnd,LB_DESCR *descr,WPARAM wParam,LPARAM lParam) 2583 { 2584 LISTBOX_UpdateSize( hwnd, descr ); 2585 return 0; 2586 } 2587 2588 static LRESULT LISTBOX_GetFont(HWND hwnd,LB_DESCR *descr,WPARAM wParam,LPARAM lParam) 2589 { 2590 return descr->font; 2591 } 2592 2593 static LRESULT LISTBOX_SetFocus(HWND hwnd,LB_DESCR *descr,WPARAM wParam,LPARAM lParam) 2594 { 2595 descr->in_focus = TRUE; 2596 descr->caret_on = TRUE; 2597 if (descr->focus_item != -1) 2598 LISTBOX_RepaintItem( hwnd, descr, descr->focus_item, ODA_FOCUS ); 2599 SEND_NOTIFICATION( hwnd, descr, LBN_SETFOCUS ); 2600 return 0; 2601 } 2602 2603 static LRESULT LISTBOX_KillFocus(HWND hwnd,LB_DESCR *descr,WPARAM wParam,LPARAM lParam) 2604 { 2605 descr->in_focus = FALSE; 2606 if ((descr->focus_item != -1) && descr->caret_on) 2607 LISTBOX_RepaintItem( hwnd, descr, descr->focus_item, ODA_FOCUS ); 2608 SEND_NOTIFICATION( hwnd, descr, LBN_KILLFOCUS ); 2609 return 0; 2610 } 2611 2612 static LRESULT LISTBOX_MouseActivate(HWND hwnd,LB_DESCR *descr,WPARAM wParam,LPARAM lParam) 2613 { 2614 return MA_NOACTIVATE; 2615 } 2616 2617 static LRESULT LISTBOX_LButtonDblClk(HWND hwnd,LB_DESCR *descr,WPARAM wParam,LPARAM lParam) 2618 { 2619 if (descr->style & LBS_NOTIFY) 2620 SEND_NOTIFICATION( hwnd, descr, LBN_DBLCLK ); 2621 return 0; 2622 } 2623 2624 static LRESULT LISTBOX_EraseBackground(HWND hwnd,LB_DESCR *descr,WPARAM wParam,LPARAM lParam) 2625 { 2626 if (IS_OWNERDRAW(descr)) 2627 { 2628 RECT rect; 2629 HBRUSH hbrush = SendMessageA( descr->owner, WM_CTLCOLORLISTBOX, wParam, (LPARAM)hwnd ); 2630 2631 GetClientRect(hwnd, &rect); 2632 if (hbrush) FillRect( (HDC)wParam, &rect, hbrush ); 2633 } 2634 2635 return 1; 2636 } 2637 2638 static LRESULT LISTBOX_DropFiles(HWND hwnd,LB_DESCR *descr,WPARAM wParam,LPARAM lParam) 2639 { 2640 if ( !descr->lphc ) 2641 return SendMessageA( descr->owner, WM_DROPFILES, wParam, lParam ); 2642 2643 return 0; 2644 } 2645 2646 static LRESULT LISTBOX_HandleDragDrop(HWND hwnd,LB_DESCR *descr,UINT msg,WPARAM wParam,LPARAM lParam) 2647 { 2648 if( !descr->lphc ) 2649 { 2650 LPDRAGINFO dragInfo = (LPDRAGINFO)lParam; 2651 2652 dragInfo->l = LISTBOX_GetItemFromPoint( hwnd, descr, dragInfo->pt.x, 2653 dragInfo->pt.y ); 2654 return SendMessageA( descr->owner, msg, wParam, lParam ); 2655 } 2656 2657 return 0; 2658 } 2324 2659 2325 2660 /*********************************************************************** … … 2329 2664 WPARAM wParam, LPARAM lParam ) 2330 2665 { 2331 LRESULT ret;2332 2666 LB_DESCR *descr; 2333 2667 2334 2668 if (!(descr = (LB_DESCR*)GetInfoPtr(hwnd))) 2335 2669 { 2336 switch (msg) 2337 { 2338 case WM_CREATE: 2339 { 2340 if (!LISTBOX_Create( hwnd, NULL )) 2341 return -1; 2342 //TRACE("creating wnd=%04x descr=%p\n", 2343 // hwnd, *(LB_DESCR **)wnd->wExtra ); 2344 return 0; 2345 } 2346 case WM_NCCREATE: 2347 { 2348 DWORD dwStyle = GetWindowLongA(hwnd,GWL_STYLE); 2349 2350 /* 2351 * When a listbox is not in a combobox and the look 2352 * is win95, the WS_BORDER style is replaced with 2353 * the WS_EX_CLIENTEDGE style. 2354 */ 2355 if (dwStyle & WS_BORDER) 2356 { 2357 SetWindowLongA(hwnd,GWL_EXSTYLE,GetWindowLongA(hwnd,GWL_EXSTYLE) | WS_EX_CLIENTEDGE); 2358 SetWindowLongA(hwnd,GWL_STYLE,GetWindowLongA(hwnd,GWL_STYLE) & ~ WS_BORDER); 2359 } 2360 } 2361 } 2362 /* Ignore all other messages before we get a WM_CREATE */ 2363 return DefWindowProcA( hwnd, msg, wParam, lParam ); 2364 } 2365 2366 //TRACE("[%04x]: msg %s wp %08x lp %08lx\n", 2367 // wnd->hwndSelf, SPY_GetMsgName(msg), wParam, lParam ); 2670 switch (msg) 2671 { 2672 case WM_CREATE: 2673 return LISTBOX_Create(hwnd,NULL); 2674 2675 case WM_NCCREATE: 2676 return LISTBOX_NCCreate(hwnd,wParam,lParam); 2677 } 2678 /* Ignore all other messages before we get a WM_CREATE */ 2679 return DefWindowProcA( hwnd, msg, wParam, lParam ); 2680 } 2681 2368 2682 switch(msg) 2369 2683 { 2370 case LB_RESETCONTENT: 2371 LISTBOX_ResetContent( hwnd, descr ); 2372 return 0; 2373 2374 case LB_ADDSTRING: 2375 wParam = LISTBOX_FindStringPos( hwnd, descr, (LPCSTR)lParam, FALSE ); 2684 case LB_RESETCONTENT: 2685 return LISTBOX_ResetContent(hwnd,descr,TRUE); 2686 2687 case LB_ADDSTRING: 2688 return LISTBOX_AddString(hwnd,descr,wParam,lParam); 2689 2690 case LB_INSERTSTRING: 2376 2691 return LISTBOX_InsertString( hwnd, descr, wParam, (LPCSTR)lParam ); 2377 2692 2378 case LB_INSERTSTRING: 2379 return LISTBOX_InsertString( hwnd, descr, wParam, (LPCSTR)lParam ); 2380 2381 case LB_ADDFILE: 2382 wParam = LISTBOX_FindFileStrPos( hwnd, descr, (LPCSTR)lParam ); 2383 return LISTBOX_InsertString( hwnd, descr, wParam, (LPCSTR)lParam ); 2384 2385 case LB_DELETESTRING: 2386 if (LISTBOX_RemoveItem( hwnd, descr, wParam) != LB_ERR) 2387 return descr->nb_items; 2388 else 2389 return LB_ERR; 2390 2391 case LB_GETITEMDATA: 2392 if (((INT)wParam < 0) || ((INT)wParam >= descr->nb_items)) 2393 return LB_ERR; 2394 return descr->items[wParam].data; 2395 2396 case LB_SETITEMDATA: 2397 if (((INT)wParam < 0) || ((INT)wParam >= descr->nb_items)) 2398 return LB_ERR; 2399 descr->items[wParam].data = (DWORD)lParam; 2400 return LB_OKAY; 2401 2402 case LB_GETCOUNT: 2403 return descr->nb_items; 2404 2405 case LB_GETTEXT: 2693 case LB_ADDFILE: 2694 return LISTBOX_AddFile(hwnd,descr,wParam,lParam); 2695 2696 case LB_DELETESTRING: 2697 return LISTBOX_DeleteString(hwnd,descr,wParam,lParam); 2698 2699 case LB_GETITEMDATA: 2700 return LISTBOX_GetItemData(hwnd,descr,wParam,lParam); 2701 2702 case LB_SETITEMDATA: 2703 return LISTBOX_SetItemData(hwnd,descr,wParam,lParam); 2704 2705 case LB_GETCOUNT: 2706 return LISTBOX_GetCount(hwnd,descr,wParam,lParam); 2707 2708 case LB_GETTEXT: 2406 2709 return LISTBOX_GetText( hwnd, descr, wParam, (LPSTR)lParam ); 2407 2710 2408 case LB_GETTEXTLEN: 2409 if (wParam >= descr->nb_items) 2410 return LB_ERR; 2411 return (HAS_STRINGS(descr) ? strlen(descr->items[wParam].str) 2412 : sizeof(DWORD)); 2413 2414 case LB_GETCURSEL: 2415 if (descr->nb_items==0) 2416 return LB_ERR; 2417 if (!IS_MULTISELECT(descr)) 2418 return descr->selected_item; 2419 /* else */ 2420 if (descr->selected_item!=-1) 2421 return descr->selected_item; 2422 /* else */ 2423 return descr->focus_item; 2424 /* otherwise, if the user tries to move the selection with the */ 2425 /* arrow keys, we will give the application something to choke on */ 2426 case LB_GETTOPINDEX: 2427 return descr->top_item; 2428 2429 case LB_GETITEMHEIGHT: 2711 case LB_GETTEXTLEN: 2712 return LISTBOX_GetTextLen(hwnd,descr,wParam,lParam); 2713 2714 case LB_GETCURSEL: 2715 return LISTBOX_GetCurSel(hwnd,descr,wParam,lParam); 2716 2717 case LB_GETTOPINDEX: 2718 return LISTBOX_GetTopIndex(hwnd,descr,wParam,lParam); 2719 2720 case LB_GETITEMHEIGHT: 2430 2721 return LISTBOX_GetItemHeight( hwnd, descr, wParam ); 2431 2722 2432 case LB_SETITEMHEIGHT:2723 case LB_SETITEMHEIGHT: 2433 2724 return LISTBOX_SetItemHeight( hwnd, descr, wParam, lParam ); 2434 2725 2435 case LB_ITEMFROMPOINT: 2436 { 2437 POINT pt; 2438 RECT rect; 2439 2440 pt.x = LOWORD(lParam); 2441 pt.y = HIWORD(lParam); 2442 rect.left = 0; 2443 rect.top = 0; 2444 rect.right = descr->width; 2445 rect.bottom = descr->height; 2446 2447 return MAKELONG( LISTBOX_GetItemFromPoint(hwnd, descr, pt.x, pt.y), 2448 !PtInRect( &rect, pt ) ); 2449 } 2450 2451 case LB_SETCARETINDEX: 2452 if ((!IS_MULTISELECT(descr)) && (descr->selected_item != -1)) return LB_ERR; 2453 if (LISTBOX_SetCaretIndex( hwnd, descr, wParam, !lParam ) == LB_ERR) 2454 return LB_ERR; 2455 else 2456 return LB_OKAY; 2457 2458 case LB_GETCARETINDEX: 2459 return descr->focus_item; 2460 2461 case LB_SETTOPINDEX: 2726 case LB_ITEMFROMPOINT: 2727 return LISTBOX_ItemFromPoint(hwnd,descr,wParam,lParam); 2728 2729 case LB_SETCARETINDEX: 2730 return LISTBOX_HandleSetCaretIndex(hwnd,descr,wParam,lParam); 2731 2732 case LB_GETCARETINDEX: 2733 return LISTBOX_GetCaretIndex(hwnd,descr,wParam,lParam); 2734 2735 case LB_SETTOPINDEX: 2462 2736 return LISTBOX_SetTopItem( hwnd, descr, wParam, TRUE ); 2463 2737 2464 case LB_SETCOLUMNWIDTH:2738 case LB_SETCOLUMNWIDTH: 2465 2739 return LISTBOX_SetColumnWidth( hwnd, descr, wParam ); 2466 2740 2467 case LB_GETITEMRECT:2741 case LB_GETITEMRECT: 2468 2742 return LISTBOX_GetItemRect( hwnd, descr, wParam, (RECT *)lParam ); 2469 2743 2470 case LB_FINDSTRING:2744 case LB_FINDSTRING: 2471 2745 return LISTBOX_FindString( hwnd, descr, wParam, (LPCSTR)lParam, FALSE ); 2472 2746 2473 case LB_FINDSTRINGEXACT:2747 case LB_FINDSTRINGEXACT: 2474 2748 return LISTBOX_FindString( hwnd, descr, wParam, (LPCSTR)lParam, TRUE ); 2475 2749 2476 case LB_SELECTSTRING: 2477 { 2478 INT index = LISTBOX_FindString( hwnd, descr, wParam, 2479 (LPCSTR)lParam, FALSE ); 2480 if (index == LB_ERR) 2481 return LB_ERR; 2482 LISTBOX_SetSelection( hwnd, descr, index, TRUE, FALSE ); 2483 return index; 2484 } 2485 2486 case LB_GETSEL: 2487 if (((INT)wParam < 0) || ((INT)wParam >= descr->nb_items)) 2488 return LB_ERR; 2489 return descr->items[wParam].selected; 2490 2491 case LB_SETSEL: 2750 case LB_SELECTSTRING: 2751 return LISTBOX_SelectString(hwnd,descr,wParam,lParam); 2752 2753 case LB_GETSEL: 2754 return LISTBOX_GetSel(hwnd,descr,wParam,lParam); 2755 2756 case LB_SETSEL: 2492 2757 return LISTBOX_SetSelection( hwnd, descr, lParam, wParam, FALSE ); 2493 2758 2494 case LB_SETCURSEL: 2495 if (IS_MULTISELECT(descr)) return LB_ERR; 2496 LISTBOX_SetCaretIndex( hwnd, descr, wParam, TRUE ); 2497 return LISTBOX_SetSelection( hwnd, descr, wParam, TRUE, FALSE ); 2498 2499 case LB_GETSELCOUNT: 2759 case LB_SETCURSEL: 2760 return LISTBOX_SetCurSel(hwnd,descr,wParam,lParam); 2761 2762 case LB_GETSELCOUNT: 2500 2763 return LISTBOX_GetSelCount( hwnd, descr ); 2501 2764 2502 case LB_GETSELITEMS:2765 case LB_GETSELITEMS: 2503 2766 return LISTBOX_GetSelItems( hwnd, descr, wParam, (LPINT)lParam ); 2504 2767 2505 case LB_SELITEMRANGE: 2506 if (LOWORD(lParam) <= HIWORD(lParam)) 2507 return LISTBOX_SelectItemRange( hwnd, descr, LOWORD(lParam), 2508 HIWORD(lParam), wParam ); 2509 else 2510 return LISTBOX_SelectItemRange( hwnd, descr, HIWORD(lParam), 2511 LOWORD(lParam), wParam ); 2512 2513 case LB_SELITEMRANGEEX: 2514 if ((INT)lParam >= (INT)wParam) 2515 return LISTBOX_SelectItemRange( hwnd, descr, wParam, lParam, TRUE ); 2516 else 2517 return LISTBOX_SelectItemRange( hwnd, descr, lParam, wParam, FALSE); 2518 2519 case LB_GETHORIZONTALEXTENT: 2520 return descr->horz_extent; 2521 2522 case LB_SETHORIZONTALEXTENT: 2768 case LB_SELITEMRANGE: 2769 return LISTBOX_SelItemRange(hwnd,descr,wParam,lParam); 2770 2771 case LB_SELITEMRANGEEX: 2772 return LISTBOX_SelItemRangeEx(hwnd,descr,wParam,lParam); 2773 2774 case LB_GETHORIZONTALEXTENT: 2775 return LISTBOX_GetHorizontalExtent(hwnd,descr,wParam,lParam); 2776 2777 case LB_SETHORIZONTALEXTENT: 2523 2778 return LISTBOX_SetHorizontalExtent( hwnd, descr, wParam ); 2524 2779 2525 case LB_GETANCHORINDEX: 2526 return descr->anchor_item; 2527 2528 case LB_SETANCHORINDEX: 2529 if (((INT)wParam < -1) || ((INT)wParam >= descr->nb_items)) 2530 return LB_ERR; 2531 descr->anchor_item = (INT)wParam; 2532 return LB_OKAY; 2533 2534 case LB_DIR: 2780 case LB_GETANCHORINDEX: 2781 return LISTBOX_GetAnchorIndex(hwnd,descr,wParam,lParam); 2782 2783 case LB_SETANCHORINDEX: 2784 return LISTBOX_SetAnchorIndex(hwnd,descr,wParam,lParam); 2785 2786 case LB_DIR: 2535 2787 return LISTBOX_Directory( hwnd, descr, wParam, (LPCSTR)lParam, TRUE ); 2536 2788 2537 case LB_GETLOCALE: 2538 return descr->locale; 2539 2540 case LB_SETLOCALE: 2541 descr->locale = (LCID)wParam; /* FIXME: should check for valid lcid */ 2542 return LB_OKAY; 2543 2544 case LB_INITSTORAGE: 2789 case LB_GETLOCALE: 2790 return LISTBOX_GetLocale(hwnd,descr,wParam,lParam); 2791 2792 case LB_SETLOCALE: 2793 return LISTBOX_SetLocale(hwnd,descr,wParam,lParam); 2794 2795 case LB_INITSTORAGE: 2545 2796 return LISTBOX_InitStorage( hwnd, descr, wParam, (DWORD)lParam ); 2546 2797 2547 case LB_SETCOUNT:2798 case LB_SETCOUNT: 2548 2799 return LISTBOX_SetCount( hwnd, descr, (INT)wParam ); 2549 2800 2550 case LB_SETTABSTOPS:2801 case LB_SETTABSTOPS: 2551 2802 return LISTBOX_SetTabStops( hwnd, descr, wParam, (LPINT)lParam, FALSE ); 2552 2803 2553 case LB_CARETON: 2554 if (descr->caret_on) 2555 return LB_OKAY; 2556 descr->caret_on = TRUE; 2557 if ((descr->focus_item != -1) && (descr->in_focus)) 2558 LISTBOX_RepaintItem( hwnd, descr, descr->focus_item, ODA_FOCUS ); 2559 return LB_OKAY; 2560 2561 case LB_CARETOFF: 2562 if (!descr->caret_on) 2563 return LB_OKAY; 2564 descr->caret_on = FALSE; 2565 if ((descr->focus_item != -1) && (descr->in_focus)) 2566 LISTBOX_RepaintItem( hwnd, descr, descr->focus_item, ODA_FOCUS ); 2567 return LB_OKAY; 2568 2569 case WM_DESTROY: 2804 case LB_CARETON: 2805 return LISTBOX_CaretOn(hwnd,descr,wParam,lParam); 2806 2807 case LB_CARETOFF: 2808 return LISTBOX_CaretOff(hwnd,descr,wParam,lParam); 2809 2810 case WM_DESTROY: 2570 2811 return LISTBOX_Destroy( hwnd, descr ); 2571 2812 2572 case WM_ENABLE: 2573 InvalidateRect( hwnd, NULL, TRUE ); 2574 return 0; 2575 2576 case WM_SETREDRAW: 2577 LISTBOX_SetRedraw( hwnd, descr, wParam != 0 ); 2578 return 0; 2579 2580 case WM_GETDLGCODE: 2581 return DLGC_WANTARROWS | DLGC_WANTCHARS; 2582 2583 case WM_PAINT: 2584 { 2585 PAINTSTRUCT ps; 2586 HDC hdc = ( wParam ) ? ((HDC)wParam) 2587 : BeginPaint( hwnd, &ps ); 2588 ret = LISTBOX_Paint( hwnd, descr, hdc ); 2589 if( !wParam ) EndPaint( hwnd, &ps ); 2590 } 2591 return ret; 2592 case WM_SIZE: 2593 LISTBOX_UpdateSize( hwnd, descr ); 2594 return 0; 2595 case WM_GETFONT: 2596 return descr->font; 2597 case WM_SETFONT: 2598 LISTBOX_SetFont( hwnd, descr, (HFONT)wParam ); 2599 if (lParam) InvalidateRect( hwnd, 0, TRUE ); 2600 return 0; 2601 case WM_SETFOCUS: 2602 descr->in_focus = TRUE; 2603 descr->caret_on = TRUE; 2604 if (descr->focus_item != -1) 2605 LISTBOX_RepaintItem( hwnd, descr, descr->focus_item, ODA_FOCUS ); 2606 SEND_NOTIFICATION( hwnd, descr, LBN_SETFOCUS ); 2607 return 0; 2608 case WM_KILLFOCUS: 2609 descr->in_focus = FALSE; 2610 if ((descr->focus_item != -1) && descr->caret_on) 2611 LISTBOX_RepaintItem( hwnd, descr, descr->focus_item, ODA_FOCUS ); 2612 SEND_NOTIFICATION( hwnd, descr, LBN_KILLFOCUS ); 2613 return 0; 2614 case WM_HSCROLL: 2813 case WM_ENABLE: 2814 return LISTBOX_Enable(hwnd,descr,wParam,lParam); 2815 2816 case WM_SETREDRAW: 2817 return LISTBOX_SetRedraw( hwnd, descr, wParam != 0 ); 2818 2819 case WM_GETDLGCODE: 2820 return LISTBOX_GetDlgCode(hwnd,descr,wParam,lParam); 2821 2822 case WM_PAINT: 2823 return LISTBOX_Paint(hwnd,descr,wParam,lParam); 2824 2825 case WM_SIZE: 2826 return LISTBOX_Size(hwnd,descr,wParam,lParam); 2827 2828 case WM_GETFONT: 2829 return LISTBOX_GetFont(hwnd,descr,wParam,lParam); 2830 2831 case WM_SETFONT: 2832 return LISTBOX_SetFont(hwnd,descr,wParam,lParam); 2833 2834 case WM_SETFOCUS: 2835 return LISTBOX_SetFocus(hwnd,descr,wParam,lParam); 2836 2837 case WM_KILLFOCUS: 2838 return LISTBOX_KillFocus(hwnd,descr,wParam,lParam); 2839 2840 case WM_HSCROLL: 2615 2841 return LISTBOX_HandleHScroll( hwnd, descr, wParam, lParam ); 2616 case WM_VSCROLL: 2842 2843 case WM_VSCROLL: 2617 2844 return LISTBOX_HandleVScroll( hwnd, descr, wParam, lParam ); 2618 case WM_MOUSEACTIVATE: 2619 return MA_NOACTIVATE;2620 case WM_MOUSEWHEEL:2621 if (wParam & (MK_SHIFT | MK_CONTROL)) 2622 return DefWindowProcA( hwnd, msg, wParam, lParam );2845 2846 case WM_MOUSEACTIVATE: 2847 return LISTBOX_MouseActivate(hwnd,descr,wParam,lParam); 2848 2849 case WM_MOUSEWHEEL: 2623 2850 return LISTBOX_HandleMouseWheel( hwnd, descr, wParam, lParam ); 2624 case WM_LBUTTONDOWN: 2851 2852 case WM_LBUTTONDOWN: 2625 2853 return LISTBOX_HandleLButtonDown( hwnd, descr, wParam, 2626 2854 (INT16)LOWORD(lParam), 2627 2855 (INT16)HIWORD(lParam) ); 2628 case WM_LBUTTONDBLCLK: 2629 if (descr->style & LBS_NOTIFY) 2630 SEND_NOTIFICATION( hwnd, descr, LBN_DBLCLK ); 2631 return 0; 2632 case WM_MOUSEMOVE: 2633 if (GetCapture() == hwnd) 2634 LISTBOX_HandleMouseMove( hwnd, descr, (INT16)LOWORD(lParam), 2635 (INT16)HIWORD(lParam) ); 2636 return 0; 2637 2638 case WM_LBUTTONUP: 2856 case WM_LBUTTONDBLCLK: 2857 return LISTBOX_LButtonDblClk(hwnd,descr,wParam,lParam); 2858 2859 case WM_MOUSEMOVE: 2860 return LISTBOX_HandleMouseMove( hwnd, descr, (INT16)LOWORD(lParam), 2861 (INT16)HIWORD(lParam) ); 2862 2863 case WM_LBUTTONUP: 2639 2864 return LISTBOX_HandleLButtonUp( hwnd, descr ); 2640 case WM_KEYDOWN: 2865 2866 case WM_KEYDOWN: 2641 2867 return LISTBOX_HandleKeyDown( hwnd, descr, wParam ); 2642 case WM_CHAR: 2868 2869 case WM_CHAR: 2643 2870 return LISTBOX_HandleChar( hwnd, descr, wParam ); 2644 case WM_SYSTIMER: 2871 2872 case WM_SYSTIMER: 2645 2873 return LISTBOX_HandleSystemTimer( hwnd, descr ); 2646 case WM_ERASEBKGND: 2647 if (IS_OWNERDRAW(descr)) 2648 { 2649 RECT rect; 2650 HBRUSH hbrush = SendMessageA( descr->owner, WM_CTLCOLORLISTBOX, 2651 wParam, (LPARAM)hwnd ); 2652 GetClientRect(hwnd, &rect); 2653 if (hbrush) FillRect( (HDC)wParam, &rect, hbrush ); 2654 } 2655 return 1; 2656 case WM_DROPFILES: 2657 if( !descr->lphc ) 2658 return SendMessageA( descr->owner, msg, wParam, lParam ); 2659 break; 2660 2661 case WM_DROPOBJECT: 2662 case WM_QUERYDROPOBJECT: 2663 case WM_DRAGSELECT: 2664 case WM_DRAGMOVE: 2665 if( !descr->lphc ) 2666 { 2667 LPDRAGINFO dragInfo = (LPDRAGINFO)lParam; 2668 dragInfo->l = LISTBOX_GetItemFromPoint( hwnd, descr, dragInfo->pt.x, 2669 dragInfo->pt.y ); 2670 return SendMessageA( descr->owner, msg, wParam, lParam ); 2671 } 2672 break; 2874 2875 case WM_ERASEBKGND: 2876 return LISTBOX_EraseBackground(hwnd,descr,wParam,lParam); 2877 2878 case WM_DROPFILES: 2879 return LISTBOX_DropFiles(hwnd,descr,wParam,lParam); 2880 2881 case WM_DROPOBJECT: 2882 case WM_QUERYDROPOBJECT: 2883 case WM_DRAGSELECT: 2884 case WM_DRAGMOVE: 2885 return LISTBOX_HandleDragDrop(hwnd,descr,msg,wParam,lParam); 2673 2886 2674 2887 default:
Note:
See TracChangeset
for help on using the changeset viewer.