ReactOS 0.4.16-dev-2491-g3dc6630
listbox.c
Go to the documentation of this file.
1/*
2 * Listbox controls
3 *
4 * Copyright 1996 Alexandre Julliard
5 * Copyright 2005 Frank Richter
6 *
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
11 *
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20 *
21 */
22
23#include <string.h>
24#include <stdlib.h>
25#include <stdarg.h>
26#include <stdio.h>
27#include "windef.h"
28#include "winbase.h"
29#include "wingdi.h"
30#include "winuser.h"
31#include "commctrl.h"
32#include "uxtheme.h"
33#include "vssym32.h"
34#include "wine/exception.h"
35#include "wine/debug.h"
36#include "wine/heap.h"
37
38#include "comctl32.h"
39
41
42/* Items array granularity (must be power of 2) */
43#define LB_ARRAY_GRANULARITY 16
44
45/* Scrolling timeout in ms */
46#define LB_SCROLL_TIMEOUT 50
47
48/* Listbox system timer id */
49#define LB_TIMER_ID 2
50
51/* flag listbox changed while setredraw false - internal style */
52#define LBS_DISPLAYCHANGED 0x80000000
53
54/* Item structure */
55typedef struct
56{
57 LPWSTR str; /* Item text */
58 BOOL selected; /* Is item selected? */
59 UINT height; /* Item height (only for OWNERDRAWVARIABLE) */
60 ULONG_PTR data; /* User data */
62
63/* Listbox structure */
64typedef struct
65{
66 HWND self; /* Our own window handle */
67 HWND owner; /* Owner window to send notifications to */
68 UINT style; /* Window style */
69 INT width; /* Window width */
70 INT height; /* Window height */
71 union
72 {
73 LB_ITEMDATA *items; /* Array of items */
74 BYTE *nodata_items; /* For multi-selection LBS_NODATA */
75 } u;
76 INT nb_items; /* Number of items */
77 UINT items_size; /* Total number of allocated items in the array */
78 INT top_item; /* Top visible item */
79 INT selected_item; /* Selected item */
80 INT focus_item; /* Item that has the focus */
81 INT anchor_item; /* Anchor item for extended selection */
82 INT item_height; /* Default item height */
83 INT page_size; /* Items per listbox page */
84 INT column_width; /* Column width for multi-column listboxes */
85 INT horz_extent; /* Horizontal extent */
86 INT horz_pos; /* Horizontal position */
87 INT nb_tabs; /* Number of tabs in array */
88 INT *tabs; /* Array of tabs */
89 INT avg_char_width; /* Average width of characters */
90 INT wheel_remain; /* Left over scroll amount */
91 BOOL caret_on; /* Is caret on? */
92 BOOL captured; /* Is mouse captured? */
94 HFONT font; /* Current font */
95 LCID locale; /* Current locale for string comparisons */
96 HEADCOMBO *lphc; /* ComboLBox */
97} LB_DESCR;
98
99
100#define IS_OWNERDRAW(descr) \
101 ((descr)->style & (LBS_OWNERDRAWFIXED | LBS_OWNERDRAWVARIABLE))
102
103#define HAS_STRINGS(descr) \
104 (!IS_OWNERDRAW(descr) || ((descr)->style & LBS_HASSTRINGS))
105
106
107#define IS_MULTISELECT(descr) \
108 ((descr)->style & (LBS_MULTIPLESEL|LBS_EXTENDEDSEL) && \
109 !((descr)->style & LBS_NOSEL))
110
111#define SEND_NOTIFICATION(descr,code) \
112 (SendMessageW( (descr)->owner, WM_COMMAND, \
113 MAKEWPARAM( GetWindowLongPtrW((descr->self),GWLP_ID), (code)), (LPARAM)(descr->self) ))
114
115#define ISWIN31 (LOWORD(GetVersion()) == 0x0a03)
116
117/* Current timer status */
118typedef enum
119{
126
128
130
131/*
132 For listboxes without LBS_NODATA, an array of LB_ITEMDATA is allocated
133 to store the states of each item into descr->u.items.
134
135 For single-selection LBS_NODATA listboxes, no storage is allocated,
136 and thus descr->u.nodata_items will always be NULL.
137
138 For multi-selection LBS_NODATA listboxes, one byte per item is stored
139 for the item's selection state into descr->u.nodata_items.
140*/
141static size_t get_sizeof_item( const LB_DESCR *descr )
142{
143 return (descr->style & LBS_NODATA) ? sizeof(BYTE) : sizeof(LB_ITEMDATA);
144}
145
147{
149
150 if (items_size > descr->items_size ||
151 items_size + LB_ARRAY_GRANULARITY * 2 < descr->items_size)
152 {
153 items_size = (items_size + LB_ARRAY_GRANULARITY - 1) & ~(LB_ARRAY_GRANULARITY - 1);
155 {
156 items = heap_realloc(descr->u.items, items_size * get_sizeof_item(descr));
157 if (!items)
158 {
160 return FALSE;
161 }
162 descr->u.items = items;
163 }
164 descr->items_size = items_size;
165 }
166
167 if ((descr->style & LBS_NODATA) && descr->u.nodata_items && items_size > descr->nb_items)
168 {
169 memset(descr->u.nodata_items + descr->nb_items, 0,
170 (items_size - descr->nb_items) * get_sizeof_item(descr));
171 }
172 return TRUE;
173}
174
176{
177 return (descr->style & LBS_NODATA) ? 0 : descr->u.items[index].data;
178}
179
181{
182 if (!(descr->style & LBS_NODATA)) descr->u.items[index].data = data;
183}
184
186{
187 return HAS_STRINGS(descr) ? descr->u.items[index].str : NULL;
188}
189
190static void set_item_string( const LB_DESCR *descr, UINT index, WCHAR *string )
191{
192 if (!(descr->style & LBS_NODATA)) descr->u.items[index].str = string;
193}
194
196{
197 return (descr->style & LBS_NODATA) ? 0 : descr->u.items[index].height;
198}
199
201{
202 if (!(descr->style & LBS_NODATA)) descr->u.items[index].height = height;
203}
204
206{
207 if (!(descr->style & (LBS_MULTIPLESEL | LBS_EXTENDEDSEL)))
208 return index == descr->selected_item;
209 if (descr->style & LBS_NODATA)
210 return descr->u.nodata_items[index];
211 else
212 return descr->u.items[index].selected;
213}
214
216{
217 if (descr->style & (LBS_MULTIPLESEL | LBS_EXTENDEDSEL))
218 {
219 if (descr->style & LBS_NODATA)
220 descr->u.nodata_items[index] = state;
221 else
222 descr->u.items[index].selected = state;
223 }
224}
225
227{
228 size_t size = get_sizeof_item(descr);
229 BYTE *p = descr->u.nodata_items + index * size;
230
231 if (!descr->u.items) return;
232
233 if (index < descr->nb_items)
234 memmove(p + size, p, (descr->nb_items - index) * size);
235}
236
238{
239 size_t size = get_sizeof_item(descr);
240 BYTE *p = descr->u.nodata_items + index * size;
241
242 if (!descr->u.items) return;
243
244 if (index < descr->nb_items)
245 memmove(p, p + size, (descr->nb_items - index) * size);
246}
247
248/***********************************************************************
249 * LISTBOX_GetCurrentPageSize
250 *
251 * Return the current page size
252 */
254{
255 INT i, height;
256 if (!(descr->style & LBS_OWNERDRAWVARIABLE)) return descr->page_size;
257 for (i = descr->top_item, height = 0; i < descr->nb_items; i++)
258 {
259 if ((height += get_item_height(descr, i)) > descr->height) break;
260 }
261 if (i == descr->top_item) return 1;
262 else return i - descr->top_item;
263}
264
265
266/***********************************************************************
267 * LISTBOX_GetMaxTopIndex
268 *
269 * Return the maximum possible index for the top of the listbox.
270 */
272{
273 INT max, page;
274
275 if (descr->style & LBS_OWNERDRAWVARIABLE)
276 {
277 page = descr->height;
278 for (max = descr->nb_items - 1; max >= 0; max--)
279 if ((page -= get_item_height(descr, max)) < 0) break;
280 if (max < descr->nb_items - 1) max++;
281 }
282 else if (descr->style & LBS_MULTICOLUMN)
283 {
284 if ((page = descr->width / descr->column_width) < 1) page = 1;
285 max = (descr->nb_items + descr->page_size - 1) / descr->page_size;
286 max = (max - page) * descr->page_size;
287 }
288 else
289 {
290 max = descr->nb_items - descr->page_size;
291 }
292 if (max < 0) max = 0;
293 return max;
294}
295
296
297/***********************************************************************
298 * LISTBOX_UpdateScroll
299 *
300 * Update the scrollbars. Should be called whenever the content
301 * of the listbox changes.
302 */
304{
306
307 /* Check the listbox scroll bar flags individually before we call
308 SetScrollInfo otherwise when the listbox style is WS_HSCROLL and
309 no WS_VSCROLL, we end up with an uninitialized, visible horizontal
310 scroll bar when we do not need one.
311 if (!(descr->style & WS_VSCROLL)) return;
312 */
313
314 /* It is important that we check descr->style, and not wnd->dwStyle,
315 for WS_VSCROLL, as the former is exactly the one passed in
316 argument to CreateWindow.
317 In Windows (and from now on in Wine :) a listbox created
318 with such a style (no WS_SCROLL) does not update
319 the scrollbar with listbox-related data, thus letting
320 the programmer use it for his/her own purposes. */
321
322 if (descr->style & LBS_NOREDRAW) return;
323 info.cbSize = sizeof(info);
324
325 if (descr->style & LBS_MULTICOLUMN)
326 {
327 info.nMin = 0;
328 info.nMax = (descr->nb_items - 1) / descr->page_size;
329 info.nPos = descr->top_item / descr->page_size;
330 info.nPage = descr->width / descr->column_width;
331 if (info.nPage < 1) info.nPage = 1;
332 info.fMask = SIF_RANGE | SIF_POS | SIF_PAGE;
333 if (descr->style & LBS_DISABLENOSCROLL)
334 info.fMask |= SIF_DISABLENOSCROLL;
335 if (descr->style & WS_HSCROLL)
336 SetScrollInfo( descr->self, SB_HORZ, &info, TRUE );
337 info.nMax = 0;
338 info.fMask = SIF_RANGE;
339 if (descr->style & WS_VSCROLL)
340 SetScrollInfo( descr->self, SB_VERT, &info, TRUE );
341 }
342 else
343 {
344 info.nMin = 0;
345 info.nMax = descr->nb_items - 1;
346 info.nPos = descr->top_item;
348 info.fMask = SIF_RANGE | SIF_POS | SIF_PAGE;
349 if (descr->style & LBS_DISABLENOSCROLL)
350 info.fMask |= SIF_DISABLENOSCROLL;
351 if (descr->style & WS_VSCROLL)
352 SetScrollInfo( descr->self, SB_VERT, &info, TRUE );
353
354 if ((descr->style & WS_HSCROLL) && descr->horz_extent)
355 {
356 info.nPos = descr->horz_pos;
357 info.nPage = descr->width;
358 info.fMask = SIF_POS | SIF_PAGE;
359 if (descr->style & LBS_DISABLENOSCROLL)
360 info.fMask |= SIF_DISABLENOSCROLL;
361 SetScrollInfo( descr->self, SB_HORZ, &info, TRUE );
362 }
363 else
364 {
365 if (descr->style & LBS_DISABLENOSCROLL)
366 {
367 info.nMin = 0;
368 info.nMax = 0;
370 SetScrollInfo( descr->self, SB_HORZ, &info, TRUE );
371 }
372 else
373 {
374 ShowScrollBar( descr->self, SB_HORZ, FALSE );
375 }
376 }
377 }
378}
379
380
381/***********************************************************************
382 * LISTBOX_SetTopItem
383 *
384 * Set the top item of the listbox, scrolling up or down if necessary.
385 */
387{
389
390 TRACE("setting top item %d, scroll %d\n", index, scroll);
391
392 if (index > max) index = max;
393 if (index < 0) index = 0;
394 if (descr->style & LBS_MULTICOLUMN) index -= index % descr->page_size;
395 if (descr->top_item == index) return LB_OKAY;
396 if (scroll)
397 {
398 INT dx = 0, dy = 0;
399 if (descr->style & LBS_MULTICOLUMN)
400 dx = (descr->top_item - index) / descr->page_size * descr->column_width;
401 else if (descr->style & LBS_OWNERDRAWVARIABLE)
402 {
403 INT i;
404 if (index > descr->top_item)
405 {
406 for (i = index - 1; i >= descr->top_item; i--)
408 }
409 else
410 {
411 for (i = index; i < descr->top_item; i++)
413 }
414 }
415 else
416 dy = (descr->top_item - index) * descr->item_height;
417
418 ScrollWindowEx( descr->self, dx, dy, NULL, NULL, 0, NULL,
420 }
421 else
422 InvalidateRect( descr->self, NULL, TRUE );
423 descr->top_item = index;
425 return LB_OKAY;
426}
427
428
429/***********************************************************************
430 * LISTBOX_UpdatePage
431 *
432 * Update the page size. Should be called when the size of
433 * the client area or the item height changes.
434 */
436{
438
439 if ((descr->item_height == 0) || (page_size = descr->height / descr->item_height) < 1)
440 page_size = 1;
441 if (page_size == descr->page_size) return;
442 descr->page_size = page_size;
443 if (descr->style & LBS_MULTICOLUMN)
444 InvalidateRect( descr->self, NULL, TRUE );
445 LISTBOX_SetTopItem( descr, descr->top_item, FALSE );
446}
447
448
449/***********************************************************************
450 * LISTBOX_UpdateSize
451 *
452 * Update the size of the listbox. Should be called when the size of
453 * the client area changes.
454 */
456{
457 RECT rect;
458
459 GetClientRect( descr->self, &rect );
460 descr->width = rect.right - rect.left;
461 descr->height = rect.bottom - rect.top;
462 if (!(descr->style & LBS_NOINTEGRALHEIGHT) && !(descr->style & LBS_OWNERDRAWVARIABLE))
463 {
464 INT remaining;
465 RECT rect;
466
467 GetWindowRect( descr->self, &rect );
468 if(descr->item_height != 0)
469 remaining = descr->height % descr->item_height;
470 else
471 remaining = 0;
472 if ((descr->height > descr->item_height) && remaining)
473 {
474 TRACE("[%p]: changing height %d -> %d\n",
475 descr->self, descr->height, descr->height - remaining );
476 SetWindowPos( descr->self, 0, 0, 0, rect.right - rect.left,
477 rect.bottom - rect.top - remaining,
479 return;
480 }
481 }
482 TRACE("[%p]: new size = %d,%d\n", descr->self, descr->width, descr->height );
485
486 /* Invalidate the focused item so it will be repainted correctly */
487 if (LISTBOX_GetItemRect( descr, descr->focus_item, &rect ) == 1)
488 {
489 InvalidateRect( descr->self, &rect, FALSE );
490 }
491}
492
493
494/***********************************************************************
495 * LISTBOX_GetItemRect
496 *
497 * Get the rectangle enclosing an item, in listbox client coordinates.
498 * Return 1 if the rectangle is (partially) visible, 0 if hidden, -1 on error.
499 */
501{
502 /* Index <= 0 is legal even on empty listboxes */
503 if (index && (index >= descr->nb_items))
504 {
507 return LB_ERR;
508 }
509 SetRect( rect, 0, 0, descr->width, descr->height );
510 if (descr->style & LBS_MULTICOLUMN)
511 {
512 INT col = (index / descr->page_size) -
513 (descr->top_item / descr->page_size);
514 rect->left += col * descr->column_width;
515 rect->right = rect->left + descr->column_width;
516 rect->top += (index % descr->page_size) * descr->item_height;
517 rect->bottom = rect->top + descr->item_height;
518 }
519 else if (descr->style & LBS_OWNERDRAWVARIABLE)
520 {
521 INT i;
522 rect->right += descr->horz_pos;
523 if ((index >= 0) && (index < descr->nb_items))
524 {
525 if (index < descr->top_item)
526 {
527 for (i = descr->top_item-1; i >= index; i--)
528 rect->top -= get_item_height(descr, i);
529 }
530 else
531 {
532 for (i = descr->top_item; i < index; i++)
533 rect->top += get_item_height(descr, i);
534 }
535 rect->bottom = rect->top + get_item_height(descr, index);
536
537 }
538 }
539 else
540 {
541 rect->top += (index - descr->top_item) * descr->item_height;
542 rect->bottom = rect->top + descr->item_height;
543 rect->right += descr->horz_pos;
544 }
545
546 TRACE("item %d, rect %s\n", index, wine_dbgstr_rect(rect));
547
548 return ((rect->left < descr->width) && (rect->right > 0) &&
549 (rect->top < descr->height) && (rect->bottom > 0));
550}
551
552
553/***********************************************************************
554 * LISTBOX_GetItemFromPoint
555 *
556 * Return the item nearest from point (x,y) (in client coordinates).
557 */
559{
560 INT index = descr->top_item;
561
562 if (!descr->nb_items) return -1; /* No items */
563 if (descr->style & LBS_OWNERDRAWVARIABLE)
564 {
565 INT pos = 0;
566 if (y >= 0)
567 {
568 while (index < descr->nb_items)
569 {
570 if ((pos += get_item_height(descr, index)) > y) break;
571 index++;
572 }
573 }
574 else
575 {
576 while (index > 0)
577 {
578 index--;
579 if ((pos -= get_item_height(descr, index)) <= y) break;
580 }
581 }
582 }
583 else if (descr->style & LBS_MULTICOLUMN)
584 {
585 if (y >= descr->item_height * descr->page_size) return -1;
586 if (y >= 0) index += y / descr->item_height;
587 if (x >= 0) index += (x / descr->column_width) * descr->page_size;
588 else index -= (((x + 1) / descr->column_width) - 1) * descr->page_size;
589 }
590 else
591 {
592 index += (y / descr->item_height);
593 }
594 if (index < 0) return 0;
595 if (index >= descr->nb_items) return -1;
596 return index;
597}
598
599
600/***********************************************************************
601 * LISTBOX_PaintItem
602 *
603 * Paint an item.
604 */
606 INT index, UINT action, BOOL ignoreFocus )
607{
608 BOOL selected = FALSE, focused;
609 WCHAR *item_str = NULL;
610
611 if (index < descr->nb_items)
612 {
613 item_str = get_item_string(descr, index);
614#ifdef __REACTOS__
615 if (!(descr->style & LBS_NOSEL))
616#endif
618 }
619
620 focused = !ignoreFocus && descr->focus_item == index && descr->caret_on && descr->in_focus;
621
622 if (IS_OWNERDRAW(descr))
623 {
624 DRAWITEMSTRUCT dis;
625 RECT r;
626 HRGN hrgn;
627
628 if (index >= descr->nb_items)
629 {
630 if (action == ODA_FOCUS)
632 else
633 ERR("called with an out of bounds index %d(%d) in owner draw, Not good.\n",index,descr->nb_items);
634 return;
635 }
636
637 /* some programs mess with the clipping region when
638 drawing the item, *and* restore the previous region
639 after they are done, so a region has better to exist
640 else everything ends clipped */
641 GetClientRect(descr->self, &r);
643
644 dis.CtlType = ODT_LISTBOX;
645 dis.CtlID = GetWindowLongPtrW( descr->self, GWLP_ID );
646 dis.hwndItem = descr->self;
647 dis.itemAction = action;
648 dis.hDC = hdc;
649 dis.itemID = index;
650 dis.itemState = 0;
651 if (selected)
652 dis.itemState |= ODS_SELECTED;
653 if (focused)
654 dis.itemState |= ODS_FOCUS;
655 if (!IsWindowEnabled(descr->self)) dis.itemState |= ODS_DISABLED;
657 dis.rcItem = *rect;
658 TRACE("[%p]: drawitem %d (%s) action=%02x state=%02x rect=%s\n",
659 descr->self, index, debugstr_w(item_str), action,
661 SendMessageW(descr->owner, WM_DRAWITEM, dis.CtlID, (LPARAM)&dis);
663 if (hrgn) DeleteObject( hrgn );
664 }
665 else
666 {
667 COLORREF oldText = 0, oldBk = 0;
668
669 if (action == ODA_FOCUS)
670 {
672 return;
673 }
674 if (selected)
675 {
678 }
679#ifdef __REACTOS__
680 else
681 {
682 HBRUSH br = GetCurrentObject(hdc, OBJ_BRUSH);
683 FillRect(hdc, rect, br);
684 }
685#endif
686
687 TRACE("[%p]: painting %d (%s) action=%02x rect=%s\n",
688 descr->self, index, debugstr_w(item_str), action,
690 if (!item_str)
691 ExtTextOutW( hdc, rect->left + 1, rect->top,
693 else if (!(descr->style & LBS_USETABSTOPS))
694#ifdef __REACTOS__
695 {
696 RECT rc = *rect;
697 if (!selected)
698 {
699 SIZE sz;
700 GetTextExtentPoint32(hdc, item_str, lstrlenW(item_str), &sz);
701 rc.right = min(sz.cx, rc.right);
702 }
703 ExtTextOutW( hdc, rect->left + 1, rect->top,
704 ETO_OPAQUE | ETO_CLIPPED, &rc, item_str,
705 lstrlenW(item_str), NULL);
706 }
707#else
708 ExtTextOutW( hdc, rect->left + 1, rect->top,
709 ETO_OPAQUE | ETO_CLIPPED, rect, item_str,
710 lstrlenW(item_str), NULL );
711#endif
712 else
713 {
714 /* Output empty string to paint background in the full width. */
715 ExtTextOutW( hdc, rect->left + 1, rect->top,
717 TabbedTextOutW( hdc, rect->left + 1 , rect->top,
718 item_str, lstrlenW(item_str),
719 descr->nb_tabs, descr->tabs, 0);
720 }
721 if (selected)
722 {
723 SetBkColor( hdc, oldBk );
724 SetTextColor( hdc, oldText );
725 }
726 if (focused)
728 }
729}
730
731
732/***********************************************************************
733 * LISTBOX_SetRedraw
734 *
735 * Change the redraw flag.
736 */
738{
739 if (on)
740 {
741 if (!(descr->style & LBS_NOREDRAW)) return;
742 descr->style &= ~LBS_NOREDRAW;
743 if (descr->style & LBS_DISPLAYCHANGED)
744 { /* page was changed while setredraw false, refresh automatically */
745 InvalidateRect(descr->self, NULL, TRUE);
746 if ((descr->top_item + descr->page_size) > descr->nb_items)
747 { /* reset top of page if less than number of items/page */
748 descr->top_item = descr->nb_items - descr->page_size;
749 if (descr->top_item < 0) descr->top_item = 0;
750 }
751 descr->style &= ~LBS_DISPLAYCHANGED;
752 }
754 }
755 else descr->style |= LBS_NOREDRAW;
756}
757
758
759/***********************************************************************
760 * LISTBOX_RepaintItem
761 *
762 * Repaint a single item synchronously.
763 */
765{
766 HDC hdc;
767 RECT rect;
768 HFONT oldFont = 0;
769 HBRUSH hbrush, oldBrush = 0;
770
771 /* Do not repaint the item if the item is not visible */
772 if (!IsWindowVisible(descr->self)) return;
773 if (descr->style & LBS_NOREDRAW)
774 {
775 descr->style |= LBS_DISPLAYCHANGED;
776 return;
777 }
778 if (LISTBOX_GetItemRect( descr, index, &rect ) != 1) return;
779 if (!(hdc = GetDCEx( descr->self, 0, DCX_CACHE ))) return;
780 if (descr->font) oldFont = SelectObject( hdc, descr->font );
781 hbrush = (HBRUSH)SendMessageW( descr->owner, WM_CTLCOLORLISTBOX,
782 (WPARAM)hdc, (LPARAM)descr->self );
783 if (hbrush) oldBrush = SelectObject( hdc, hbrush );
784 if (!IsWindowEnabled(descr->self))
786 SetWindowOrgEx( hdc, descr->horz_pos, 0, NULL );
788 if (oldFont) SelectObject( hdc, oldFont );
789 if (oldBrush) SelectObject( hdc, oldBrush );
790 ReleaseDC( descr->self, hdc );
791}
792
793
794/***********************************************************************
795 * LISTBOX_DrawFocusRect
796 */
798{
799 HDC hdc;
800 RECT rect;
801 HFONT oldFont = 0;
802
803 /* Do not repaint the item if the item is not visible */
804 if (!IsWindowVisible(descr->self)) return;
805
806 if (descr->focus_item == -1) return;
807 if (!descr->caret_on || !descr->in_focus) return;
808
809 if (LISTBOX_GetItemRect( descr, descr->focus_item, &rect ) != 1) return;
810 if (!(hdc = GetDCEx( descr->self, 0, DCX_CACHE ))) return;
811 if (descr->font) oldFont = SelectObject( hdc, descr->font );
812 if (!IsWindowEnabled(descr->self))
814 SetWindowOrgEx( hdc, descr->horz_pos, 0, NULL );
815 LISTBOX_PaintItem( descr, hdc, &rect, descr->focus_item, ODA_FOCUS, !on );
816 if (oldFont) SelectObject( hdc, oldFont );
817 ReleaseDC( descr->self, hdc );
818}
819
820
821/***********************************************************************
822 * LISTBOX_InitStorage
823 */
825{
826 UINT new_size = descr->nb_items + nb_items;
827
828 if (new_size > descr->items_size && !resize_storage(descr, new_size))
829 return LB_ERRSPACE;
830 return descr->items_size;
831}
832
833
834/***********************************************************************
835 * LISTBOX_SetTabStops
836 */
838{
839 INT i;
840
841 if (!(descr->style & LBS_USETABSTOPS))
842 {
844 return FALSE;
845 }
846
847 HeapFree( GetProcessHeap(), 0, descr->tabs );
848 if (!(descr->nb_tabs = count))
849 {
850 descr->tabs = NULL;
851 return TRUE;
852 }
853 if (!(descr->tabs = HeapAlloc( GetProcessHeap(), 0,
854 descr->nb_tabs * sizeof(INT) )))
855 return FALSE;
856 memcpy( descr->tabs, tabs, descr->nb_tabs * sizeof(INT) );
857
858 /* convert into "dialog units"*/
859 for (i = 0; i < descr->nb_tabs; i++)
860 descr->tabs[i] = MulDiv(descr->tabs[i], descr->avg_char_width, 4);
861
862 return TRUE;
863}
864
865
866/***********************************************************************
867 * LISTBOX_GetText
868 */
870{
871 DWORD len;
872
873 if ((index < 0) || (index >= descr->nb_items))
874 {
876 return LB_ERR;
877 }
878
879 if (HAS_STRINGS(descr))
880 {
882
883 if (!buffer)
884 return lstrlenW(str);
885
886 TRACE("index %d (0x%04x) %s\n", index, index, debugstr_w(str));
887
888 __TRY /* hide a Delphi bug that passes a read-only buffer */
889 {
892 }
894 {
895 WARN( "got an invalid buffer (Delphi bug?)\n" );
897 return LB_ERR;
898 }
900 } else
901 {
902 if (buffer)
904 len = sizeof(ULONG_PTR);
905 }
906 return len;
907}
908
910{
912 if (ret == CSTR_LESS_THAN)
913 return -1;
914 if (ret == CSTR_EQUAL)
915 return 0;
916 if (ret == CSTR_GREATER_THAN)
917 return 1;
918 return -1;
919}
920
921/***********************************************************************
922 * LISTBOX_FindStringPos
923 *
924 * Find the nearest string located before a given string in sort order.
925 * If 'exact' is TRUE, return an error if we don't get an exact match.
926 */
928{
929 INT index, min, max, res;
930
931 if (!descr->nb_items || !(descr->style & LBS_SORT)) return -1; /* Add it at the end */
932
933 min = 0;
934 max = descr->nb_items - 1;
935 while (min <= max)
936 {
937 index = (min + max) / 2;
938 if (HAS_STRINGS(descr))
940 else
941 {
943 UINT id = (UINT)GetWindowLongPtrW( descr->self, GWLP_ID );
944
945 cis.CtlType = ODT_LISTBOX;
946 cis.CtlID = id;
947 cis.hwndItem = descr->self;
948 /* note that some application (MetaStock) expects the second item
949 * to be in the listbox */
950 cis.itemID1 = index;
952 cis.itemID2 = -1;
953 cis.itemData2 = (ULONG_PTR)str;
954 cis.dwLocaleId = descr->locale;
955 res = SendMessageW( descr->owner, WM_COMPAREITEM, id, (LPARAM)&cis );
956 }
957 if (!res) return index;
958 if (res > 0) max = index - 1;
959 else min = index + 1;
960 }
961 return exact ? -1 : min;
962}
963
964
965/***********************************************************************
966 * LISTBOX_FindFileStrPos
967 *
968 * Find the nearest string located before a given string in directory
969 * sort order (i.e. first files, then directories, then drives).
970 */
972{
973 INT min, max, res;
974
975 if (!HAS_STRINGS(descr))
977 min = 0;
978 max = descr->nb_items;
979 while (min != max)
980 {
981 INT index = (min + max) / 2;
983 if (*p == '[') /* drive or directory */
984 {
985 if (*str != '[') res = -1;
986 else if (p[1] == '-') /* drive */
987 {
988 if (str[1] == '-') res = str[2] - p[2];
989 else res = -1;
990 }
991 else /* directory */
992 {
993 if (str[1] == '-') res = 1;
994 else res = LISTBOX_lstrcmpiW( descr->locale, str, p );
995 }
996 }
997 else /* filename */
998 {
999 if (*str == '[') res = 1;
1000 else res = LISTBOX_lstrcmpiW( descr->locale, str, p );
1001 }
1002 if (!res) return index;
1003 if (res < 0) max = index;
1004 else min = index + 1;
1005 }
1006 return max;
1007}
1008
1009
1010/***********************************************************************
1011 * LISTBOX_FindString
1012 *
1013 * Find the item beginning with a given string.
1014 */
1016{
1017 INT i, index;
1018
1019 if (descr->style & LBS_NODATA) return LB_ERR;
1020
1021 start++;
1022 if (start >= descr->nb_items) start = 0;
1023 if (HAS_STRINGS(descr))
1024 {
1025 if (!str || ! str[0] ) return LB_ERR;
1026 if (exact)
1027 {
1028 for (i = 0, index = start; i < descr->nb_items; i++, index++)
1029 {
1030 if (index == descr->nb_items) index = 0;
1032 return index;
1033 }
1034 }
1035 else
1036 {
1037 /* Special case for drives and directories: ignore prefix */
1038 INT len = lstrlenW(str);
1039 WCHAR *item_str;
1040
1041 for (i = 0, index = start; i < descr->nb_items; i++, index++)
1042 {
1043 if (index == descr->nb_items) index = 0;
1044 item_str = get_item_string(descr, index);
1045
1046 if (!wcsnicmp(str, item_str, len)) return index;
1047 if (item_str[0] == '[')
1048 {
1049 if (!wcsnicmp(str, item_str + 1, len)) return index;
1050 if (item_str[1] == '-' && !wcsnicmp(str, item_str + 2, len)) return index;
1051 }
1052 }
1053 }
1054 }
1055 else
1056 {
1057 if (exact && (descr->style & LBS_SORT))
1058 /* If sorted, use a WM_COMPAREITEM binary search */
1059 return LISTBOX_FindStringPos( descr, str, TRUE );
1060
1061 /* Otherwise use a linear search */
1062 for (i = 0, index = start; i < descr->nb_items; i++, index++)
1063 {
1064 if (index == descr->nb_items) index = 0;
1065 if (get_item_data(descr, index) == (ULONG_PTR)str) return index;
1066 }
1067 }
1068 return LB_ERR;
1069}
1070
1071
1072/***********************************************************************
1073 * LISTBOX_GetSelCount
1074 */
1076{
1077 INT i, count;
1078
1079 if (!(descr->style & LBS_MULTIPLESEL) ||
1080 (descr->style & LBS_NOSEL))
1081 return LB_ERR;
1082 for (i = count = 0; i < descr->nb_items; i++)
1083 if (is_item_selected(descr, i)) count++;
1084 return count;
1085}
1086
1087
1088/***********************************************************************
1089 * LISTBOX_GetSelItems
1090 */
1092{
1093 INT i, count;
1094
1095 if (!(descr->style & LBS_MULTIPLESEL)) return LB_ERR;
1096 for (i = count = 0; (i < descr->nb_items) && (count < max); i++)
1097 if (is_item_selected(descr, i)) array[count++] = i;
1098 return count;
1099}
1100
1101
1102/***********************************************************************
1103 * LISTBOX_Paint
1104 */
1106{
1107 INT i, col_pos = descr->page_size - 1;
1108 RECT rect;
1109 RECT focusRect = {-1, -1, -1, -1};
1110 HFONT oldFont = 0;
1111 HBRUSH hbrush, oldBrush = 0;
1112
1113 if (descr->style & LBS_NOREDRAW) return 0;
1114
1115 SetRect( &rect, 0, 0, descr->width, descr->height );
1116 if (descr->style & LBS_MULTICOLUMN)
1117 rect.right = rect.left + descr->column_width;
1118 else if (descr->horz_pos)
1119 {
1120 SetWindowOrgEx( hdc, descr->horz_pos, 0, NULL );
1121 rect.right += descr->horz_pos;
1122 }
1123
1124 if (descr->font) oldFont = SelectObject( hdc, descr->font );
1125 hbrush = (HBRUSH)SendMessageW( descr->owner, WM_CTLCOLORLISTBOX,
1126 (WPARAM)hdc, (LPARAM)descr->self );
1127 if (hbrush) oldBrush = SelectObject( hdc, hbrush );
1129
1130 if (!descr->nb_items && (descr->focus_item != -1) && descr->caret_on &&
1131 (descr->in_focus))
1132 {
1133 /* Special case for empty listbox: paint focus rect */
1134 rect.bottom = rect.top + descr->item_height;
1136 &rect, NULL, 0, NULL );
1137 LISTBOX_PaintItem( descr, hdc, &rect, descr->focus_item, ODA_FOCUS, FALSE );
1138 rect.top = rect.bottom;
1139 }
1140
1141 /* Paint all the item, regarding the selection
1142 Focus state will be painted after */
1143
1144 for (i = descr->top_item; i < descr->nb_items; i++)
1145 {
1146 if (!(descr->style & LBS_OWNERDRAWVARIABLE))
1147 rect.bottom = rect.top + descr->item_height;
1148 else
1149 rect.bottom = rect.top + get_item_height(descr, i);
1150
1151 /* keep the focus rect, to paint the focus item after */
1152 if (i == descr->focus_item)
1153 focusRect = rect;
1154#ifdef __REACTOS__
1155 rect.bottom = min(rect.bottom, descr->height);
1156#endif
1158 rect.top = rect.bottom;
1159
1160 if ((descr->style & LBS_MULTICOLUMN) && !col_pos)
1161 {
1162 if (!IS_OWNERDRAW(descr))
1163 {
1164 /* Clear the bottom of the column */
1165 if (rect.top < descr->height)
1166 {
1167 rect.bottom = descr->height;
1169 &rect, NULL, 0, NULL );
1170 }
1171 }
1172
1173 /* Go to the next column */
1174 rect.left += descr->column_width;
1175 rect.right += descr->column_width;
1176 rect.top = 0;
1177 col_pos = descr->page_size - 1;
1178 if (rect.left >= descr->width) break;
1179 }
1180 else
1181 {
1182 col_pos--;
1183 if (rect.top >= descr->height) break;
1184 }
1185 }
1186
1187 /* Paint the focus item now */
1188 if (focusRect.top != focusRect.bottom &&
1189 descr->caret_on && descr->in_focus)
1190 LISTBOX_PaintItem( descr, hdc, &focusRect, descr->focus_item, ODA_FOCUS, FALSE );
1191
1192 if (!IS_OWNERDRAW(descr))
1193 {
1194 /* Clear the remainder of the client area */
1195 if (rect.top < descr->height)
1196 {
1197 rect.bottom = descr->height;
1198#ifdef __REACTOS__
1199 HBRUSH br = GetCurrentObject(hdc, OBJ_BRUSH);
1200 FillRect(hdc, &rect, br);
1201#else
1203 &rect, NULL, 0, NULL );
1204#endif
1205 }
1206 if (rect.right < descr->width)
1207 {
1208 rect.left = rect.right;
1209 rect.right = descr->width;
1210 rect.top = 0;
1211 rect.bottom = descr->height;
1212#ifdef __REACTOS__
1213 HBRUSH br = GetCurrentObject(hdc, OBJ_BRUSH);
1214 FillRect(hdc, &rect, br);
1215#else
1217 &rect, NULL, 0, NULL );
1218#endif
1219 }
1220 }
1221 if (oldFont) SelectObject( hdc, oldFont );
1222 if (oldBrush) SelectObject( hdc, oldBrush );
1223 return 0;
1224}
1225
1226static void LISTBOX_NCPaint( LB_DESCR *descr, HRGN region )
1227{
1228 DWORD exstyle = GetWindowLongW( descr->self, GWL_EXSTYLE);
1229 HTHEME theme = GetWindowTheme( descr->self );
1230 HRGN cliprgn = region;
1231 int cxEdge, cyEdge;
1232 HDC hdc;
1233 RECT r;
1234
1235 if (!theme || !(exstyle & WS_EX_CLIENTEDGE))
1236 return;
1237
1238 cxEdge = GetSystemMetrics(SM_CXEDGE);
1239 cyEdge = GetSystemMetrics(SM_CYEDGE);
1240
1241 GetWindowRect(descr->self, &r);
1242
1243 /* New clipping region passed to default proc to exclude border */
1244 cliprgn = CreateRectRgn(r.left + cxEdge, r.top + cyEdge,
1245 r.right - cxEdge, r.bottom - cyEdge);
1246 if (region != (HRGN)1)
1247 CombineRgn(cliprgn, cliprgn, region, RGN_AND);
1248 OffsetRect(&r, -r.left, -r.top);
1249
1250#ifdef __REACTOS__ /* r73789 */
1251 hdc = GetWindowDC(descr->self);
1252 /* Exclude client part */
1254 r.left + cxEdge,
1255 r.top + cyEdge,
1256 r.right - cxEdge,
1257 r.bottom -cyEdge);
1258#else
1259 hdc = GetDCEx(descr->self, region, DCX_WINDOW|DCX_INTERSECTRGN);
1260 OffsetRect(&r, -r.left, -r.top);
1261#endif
1262
1263 if (IsThemeBackgroundPartiallyTransparent (theme, 0, 0))
1265 DrawThemeBackground (theme, hdc, 0, 0, &r, 0);
1266 ReleaseDC(descr->self, hdc);
1267}
1268
1269/***********************************************************************
1270 * LISTBOX_InvalidateItems
1271 *
1272 * Invalidate all items from a given item. If the specified item is not
1273 * visible, nothing happens.
1274 */
1276{
1277 RECT rect;
1278
1279 if (LISTBOX_GetItemRect( descr, index, &rect ) == 1)
1280 {
1281 if (descr->style & LBS_NOREDRAW)
1282 {
1283 descr->style |= LBS_DISPLAYCHANGED;
1284 return;
1285 }
1286 rect.bottom = descr->height;
1287 InvalidateRect( descr->self, &rect, TRUE );
1288 if (descr->style & LBS_MULTICOLUMN)
1289 {
1290 /* Repaint the other columns */
1291 rect.left = rect.right;
1292 rect.right = descr->width;
1293 rect.top = 0;
1294 InvalidateRect( descr->self, &rect, TRUE );
1295 }
1296 }
1297}
1298
1300{
1301 RECT rect;
1302
1303 if (LISTBOX_GetItemRect( descr, index, &rect ) == 1)
1304 InvalidateRect( descr->self, &rect, TRUE );
1305}
1306
1307/***********************************************************************
1308 * LISTBOX_GetItemHeight
1309 */
1311{
1312 if (descr->style & LBS_OWNERDRAWVARIABLE && descr->nb_items > 0)
1313 {
1314 if ((index < 0) || (index >= descr->nb_items))
1315 {
1317 return LB_ERR;
1318 }
1319 return get_item_height(descr, index);
1320 }
1321 else return descr->item_height;
1322}
1323
1324
1325/***********************************************************************
1326 * LISTBOX_SetItemHeight
1327 */
1329{
1330 if (height > MAXWORD)
1331 return -1;
1332
1333 if (!height) height = 1;
1334
1335 if (descr->style & LBS_OWNERDRAWVARIABLE)
1336 {
1337 if ((index < 0) || (index >= descr->nb_items))
1338 {
1340 return LB_ERR;
1341 }
1342 TRACE("[%p]: item %d height = %d\n", descr->self, index, height );
1345 if (repaint)
1347 }
1348 else if (height != descr->item_height)
1349 {
1350 TRACE("[%p]: new height = %d\n", descr->self, height );
1351 descr->item_height = height;
1354 if (repaint)
1355 InvalidateRect( descr->self, 0, TRUE );
1356 }
1357 return LB_OKAY;
1358}
1359
1360
1361/***********************************************************************
1362 * LISTBOX_SetHorizontalPos
1363 */
1365{
1366 INT diff;
1367
1368 if (pos > descr->horz_extent - descr->width)
1369 pos = descr->horz_extent - descr->width;
1370 if (pos < 0) pos = 0;
1371 if (!(diff = descr->horz_pos - pos)) return;
1372 TRACE("[%p]: new horz pos = %d\n", descr->self, pos );
1373 descr->horz_pos = pos;
1375 if (abs(diff) < descr->width)
1376 {
1377 RECT rect;
1378 /* Invalidate the focused item so it will be repainted correctly */
1379 if (LISTBOX_GetItemRect( descr, descr->focus_item, &rect ) == 1)
1380 InvalidateRect( descr->self, &rect, TRUE );
1381 ScrollWindowEx( descr->self, diff, 0, NULL, NULL, 0, NULL,
1383 }
1384 else
1385 InvalidateRect( descr->self, NULL, TRUE );
1386}
1387
1388
1389/***********************************************************************
1390 * LISTBOX_SetHorizontalExtent
1391 */
1393{
1394 if (descr->style & LBS_MULTICOLUMN)
1395 return LB_OKAY;
1396 if (extent == descr->horz_extent) return LB_OKAY;
1397 TRACE("[%p]: new horz extent = %d\n", descr->self, extent );
1398 descr->horz_extent = extent;
1399 if (descr->style & WS_HSCROLL) {
1401 info.cbSize = sizeof(info);
1402 info.nMin = 0;
1403 info.nMax = descr->horz_extent ? descr->horz_extent - 1 : 0;
1404 info.fMask = SIF_RANGE;
1405 if (descr->style & LBS_DISABLENOSCROLL)
1406 info.fMask |= SIF_DISABLENOSCROLL;
1407 SetScrollInfo( descr->self, SB_HORZ, &info, TRUE );
1408 }
1409 if (descr->horz_pos > extent - descr->width)
1411 return LB_OKAY;
1412}
1413
1414
1415/***********************************************************************
1416 * LISTBOX_SetColumnWidth
1417 */
1419{
1420 RECT rect;
1421
1422 TRACE("[%p]: new column width = %d\n", descr->self, column_width);
1423
1424 GetClientRect(descr->self, &rect);
1425 descr->width = rect.right - rect.left;
1426 descr->height = rect.bottom - rect.top;
1427 descr->column_width = column_width;
1428
1431 return LB_OKAY;
1432}
1433
1434
1435/***********************************************************************
1436 * LISTBOX_SetFont
1437 *
1438 * Returns the item height.
1439 */
1441{
1442 HDC hdc;
1443 HFONT oldFont = 0;
1444 const char *alphabet = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
1445 SIZE sz;
1446
1447 descr->font = font;
1448
1449 if (!(hdc = GetDCEx( descr->self, 0, DCX_CACHE )))
1450 {
1451 ERR("unable to get DC.\n" );
1452 return 16;
1453 }
1454 if (font) oldFont = SelectObject( hdc, font );
1455 GetTextExtentPointA( hdc, alphabet, 52, &sz);
1456 if (oldFont) SelectObject( hdc, oldFont );
1457 ReleaseDC( descr->self, hdc );
1458
1459 descr->avg_char_width = (sz.cx / 26 + 1) / 2;
1460 if (!IS_OWNERDRAW(descr))
1462 return sz.cy;
1463}
1464
1465
1466/***********************************************************************
1467 * LISTBOX_MakeItemVisible
1468 *
1469 * Make sure that a given item is partially or fully visible.
1470 */
1472{
1473 INT top;
1474
1475 TRACE("current top item %d, index %d, fully %d\n", descr->top_item, index, fully);
1476
1477 if (index <= descr->top_item) top = index;
1478 else if (descr->style & LBS_MULTICOLUMN)
1479 {
1480 INT cols = descr->width;
1481 if (!fully) cols += descr->column_width - 1;
1482 if (cols >= descr->column_width) cols /= descr->column_width;
1483 else cols = 1;
1484 if (index < descr->top_item + (descr->page_size * cols)) return;
1485 top = index - descr->page_size * (cols - 1);
1486 }
1487 else if (descr->style & LBS_OWNERDRAWVARIABLE)
1488 {
1489 INT height = fully ? get_item_height(descr, index) : 1;
1490 for (top = index; top > descr->top_item; top--)
1491 if ((height += get_item_height(descr, top - 1)) > descr->height) break;
1492 }
1493 else
1494 {
1495 if (index < descr->top_item + descr->page_size) return;
1496 if (!fully && (index == descr->top_item + descr->page_size) &&
1497 (descr->height > (descr->page_size * descr->item_height))) return;
1498 top = index - descr->page_size + 1;
1499 }
1501}
1502
1503/***********************************************************************
1504 * LISTBOX_SetCaretIndex
1505 *
1506 * NOTES
1507 * index must be between 0 and descr->nb_items-1, or LB_ERR is returned.
1508 *
1509 */
1511{
1512 BOOL focus_changed = descr->focus_item != index;
1513
1514 TRACE("old focus %d, index %d\n", descr->focus_item, index);
1515
1516 if (descr->style & LBS_NOSEL) return LB_ERR;
1517 if ((index < 0) || (index >= descr->nb_items)) return LB_ERR;
1518
1519 if (focus_changed)
1520 {
1522 descr->focus_item = index;
1523 }
1524
1525 LISTBOX_MakeItemVisible( descr, index, fully_visible );
1526
1527 if (focus_changed)
1529
1530 return LB_OKAY;
1531}
1532
1533
1534/***********************************************************************
1535 * LISTBOX_SelectItemRange
1536 *
1537 * Select a range of items. Should only be used on a MULTIPLESEL listbox.
1538 */
1540 INT last, BOOL on )
1541{
1542 INT i;
1543
1544 /* A few sanity checks */
1545
1546 if (descr->style & LBS_NOSEL) return LB_ERR;
1547 if (!(descr->style & LBS_MULTIPLESEL)) return LB_ERR;
1548
1549 if (!descr->nb_items) return LB_OKAY;
1550
1551 if (last == -1 || last >= descr->nb_items) last = descr->nb_items - 1;
1552 if (first < 0) first = 0;
1553 if (last < first) return LB_OKAY;
1554
1555 if (on) /* Turn selection on */
1556 {
1557 for (i = first; i <= last; i++)
1558 {
1559 if (is_item_selected(descr, i)) continue;
1562 }
1563 }
1564 else /* Turn selection off */
1565 {
1566 for (i = first; i <= last; i++)
1567 {
1568 if (!is_item_selected(descr, i)) continue;
1571 }
1572 }
1573 return LB_OKAY;
1574}
1575
1576/***********************************************************************
1577 * LISTBOX_SetSelection
1578 */
1580 BOOL on, BOOL send_notify )
1581{
1582 TRACE( "cur_sel=%d index=%d notify=%s\n",
1583 descr->selected_item, index, send_notify ? "YES" : "NO" );
1584
1585 if (descr->style & LBS_NOSEL)
1586 {
1587 descr->selected_item = index;
1588 return LB_ERR;
1589 }
1590 if ((index < -1) || (index >= descr->nb_items)) return LB_ERR;
1591 if (descr->style & LBS_MULTIPLESEL)
1592 {
1593 if (index == -1) /* Select all items */
1594 return LISTBOX_SelectItemRange( descr, 0, descr->nb_items, on );
1595 else /* Only one item */
1596 return LISTBOX_SelectItemRange( descr, index, index, on );
1597 }
1598 else
1599 {
1600 INT oldsel = descr->selected_item;
1601 if (index == oldsel) return LB_OKAY;
1602 if (oldsel != -1) set_item_selected_state(descr, oldsel, FALSE);
1604 descr->selected_item = index;
1605 if (oldsel != -1) LISTBOX_RepaintItem( descr, oldsel, ODA_SELECT );
1607 if (send_notify && descr->nb_items) SEND_NOTIFICATION( descr,
1608 (index != -1) ? LBN_SELCHANGE : LBN_SELCANCEL );
1609 else
1610 if( descr->lphc ) /* set selection change flag for parent combo */
1611 descr->lphc->wState |= CBF_SELCHANGE;
1612 }
1613 return LB_OKAY;
1614}
1615
1616
1617/***********************************************************************
1618 * LISTBOX_MoveCaret
1619 *
1620 * Change the caret position and extend the selection to the new caret.
1621 */
1622static void LISTBOX_MoveCaret( LB_DESCR *descr, INT index, BOOL fully_visible )
1623{
1624 TRACE("old focus %d, index %d\n", descr->focus_item, index);
1625
1626 if ((index < 0) || (index >= descr->nb_items))
1627 return;
1628
1629 /* Important, repaint needs to be done in this order if
1630 you want to mimic Windows behavior:
1631 1. Remove the focus and paint the item
1632 2. Remove the selection and paint the item(s)
1633 3. Set the selection and repaint the item(s)
1634 4. Set the focus to 'index' and repaint the item */
1635
1636 /* 1. remove the focus and repaint the item */
1638
1639 /* 2. then turn off the previous selection */
1640 /* 3. repaint the new selected item */
1641 if (descr->style & LBS_EXTENDEDSEL)
1642 {
1643 if (descr->anchor_item != -1)
1644 {
1645 INT first = min( index, descr->anchor_item );
1646 INT last = max( index, descr->anchor_item );
1647 if (first > 0)
1651 }
1652 }
1653 else if (!(descr->style & LBS_MULTIPLESEL))
1654 {
1655 /* Set selection to new caret item */
1657 }
1658
1659 /* 4. repaint the new item with the focus */
1660 descr->focus_item = index;
1661 LISTBOX_MakeItemVisible( descr, index, fully_visible );
1663}
1664
1665
1666/***********************************************************************
1667 * LISTBOX_InsertItem
1668 */
1671{
1672 INT oldfocus = descr->focus_item;
1673
1674 if (index == -1) index = descr->nb_items;
1675 else if ((index < 0) || (index > descr->nb_items)) return LB_ERR;
1676 if (!resize_storage(descr, descr->nb_items + 1)) return LB_ERR;
1677
1679 descr->nb_items++;
1684
1685 /* Get item height */
1686
1687 if (descr->style & LBS_OWNERDRAWVARIABLE)
1688 {
1690 UINT id = (UINT)GetWindowLongPtrW( descr->self, GWLP_ID );
1691
1692 mis.CtlType = ODT_LISTBOX;
1693 mis.CtlID = id;
1694 mis.itemID = index;
1695 mis.itemData = data;
1696 mis.itemHeight = descr->item_height;
1697 SendMessageW( descr->owner, WM_MEASUREITEM, id, (LPARAM)&mis );
1699 TRACE("[%p]: measure item %d (%s) = %d\n",
1700 descr->self, index, str ? debugstr_w(str) : "", get_item_height(descr, index));
1701 }
1702
1703 /* Repaint the items */
1704
1707
1708 /* Move selection and focused item */
1709 /* If listbox was empty, set focus to the first item */
1710 if (descr->nb_items == 1)
1712 /* single select don't change selection index in win31 */
1713 else if ((ISWIN31) && !(IS_MULTISELECT(descr)))
1714 {
1715 descr->selected_item++;
1716 LISTBOX_SetSelection( descr, descr->selected_item-1, TRUE, FALSE );
1717 }
1718 else
1719 {
1720 if (index <= descr->selected_item)
1721 {
1722 descr->selected_item++;
1723 descr->focus_item = oldfocus; /* focus not changed */
1724 }
1725 }
1726 return LB_OKAY;
1727}
1728
1729
1730/***********************************************************************
1731 * LISTBOX_InsertString
1732 */
1734{
1735 LPWSTR new_str = NULL;
1736 LRESULT ret;
1737
1738 if (HAS_STRINGS(descr))
1739 {
1740 static const WCHAR empty_stringW[] = { 0 };
1741 if (!str) str = empty_stringW;
1742 if (!(new_str = HeapAlloc( GetProcessHeap(), 0, (lstrlenW(str) + 1) * sizeof(WCHAR) )))
1743 {
1745 return LB_ERRSPACE;
1746 }
1747 lstrcpyW(new_str, str);
1748 }
1749
1750 if (index == -1) index = descr->nb_items;
1751 if ((ret = LISTBOX_InsertItem( descr, index, new_str, (ULONG_PTR)str )) != 0)
1752 {
1753 HeapFree( GetProcessHeap(), 0, new_str );
1754 return ret;
1755 }
1756
1757 TRACE("[%p]: added item %d %s\n",
1758 descr->self, index, HAS_STRINGS(descr) ? debugstr_w(new_str) : "" );
1759 return index;
1760}
1761
1762
1763/***********************************************************************
1764 * LISTBOX_DeleteItem
1765 *
1766 * Delete the content of an item. 'index' must be a valid index.
1767 */
1769{
1770 /* Note: Win 3.1 only sends DELETEITEM on owner-draw items,
1771 * while Win95 sends it for all items with user data.
1772 * It's probably better to send it too often than not
1773 * often enough, so this is what we do here.
1774 */
1776 {
1777 DELETEITEMSTRUCT dis;
1778 UINT id = (UINT)GetWindowLongPtrW( descr->self, GWLP_ID );
1779
1780 dis.CtlType = ODT_LISTBOX;
1781 dis.CtlID = id;
1782 dis.itemID = index;
1783 dis.hwndItem = descr->self;
1785 SendMessageW( descr->owner, WM_DELETEITEM, id, (LPARAM)&dis );
1786 }
1788}
1789
1790
1791/***********************************************************************
1792 * LISTBOX_RemoveItem
1793 *
1794 * Remove an item from the listbox and delete its content.
1795 */
1797{
1798 if ((index < 0) || (index >= descr->nb_items)) return LB_ERR;
1799
1800 /* We need to invalidate the original rect instead of the updated one. */
1802
1803 if (descr->nb_items == 1)
1804 {
1805 SendMessageW(descr->self, LB_RESETCONTENT, 0, 0);
1806 return LB_OKAY;
1807 }
1808 descr->nb_items--;
1811
1812 if (descr->anchor_item == descr->nb_items) descr->anchor_item--;
1813 resize_storage(descr, descr->nb_items);
1814
1815 /* Repaint the items */
1816
1818 /* if we removed the scrollbar, reset the top of the list
1819 (correct for owner-drawn ???) */
1820 if (descr->nb_items == descr->page_size)
1822
1823 /* Move selection and focused item */
1824 if (!IS_MULTISELECT(descr))
1825 {
1826 if (index == descr->selected_item)
1827 descr->selected_item = -1;
1828 else if (index < descr->selected_item)
1829 {
1830 descr->selected_item--;
1831 if (ISWIN31) /* win 31 do not change the selected item number */
1832 LISTBOX_SetSelection( descr, descr->selected_item + 1, TRUE, FALSE);
1833 }
1834 }
1835
1836 if (descr->focus_item >= descr->nb_items)
1837 {
1838 descr->focus_item = descr->nb_items - 1;
1839 if (descr->focus_item < 0) descr->focus_item = 0;
1840 }
1841 return LB_OKAY;
1842}
1843
1844
1845/***********************************************************************
1846 * LISTBOX_ResetContent
1847 */
1849{
1850 INT i;
1851
1852 if (!(descr->style & LBS_NODATA))
1853 for (i = descr->nb_items - 1; i >= 0; i--) LISTBOX_DeleteItem(descr, i);
1854 HeapFree( GetProcessHeap(), 0, descr->u.items );
1855 descr->nb_items = 0;
1856 descr->top_item = 0;
1857 descr->selected_item = -1;
1858 descr->focus_item = 0;
1859 descr->anchor_item = -1;
1860 descr->items_size = 0;
1861 descr->u.items = NULL;
1862}
1863
1864
1865/***********************************************************************
1866 * LISTBOX_SetCount
1867 */
1869{
1870 UINT orig_num = descr->nb_items;
1871
1872 if (!(descr->style & LBS_NODATA)) return LB_ERR;
1873
1874 if (!resize_storage(descr, count))
1875 return LB_ERRSPACE;
1876 descr->nb_items = count;
1877
1878 if (count)
1879 {
1881 if (count < orig_num)
1882 {
1883 descr->anchor_item = min(descr->anchor_item, count - 1);
1884 if (descr->selected_item >= count)
1885 descr->selected_item = -1;
1886
1887 /* If we removed the scrollbar, reset the top of the list */
1888 if (count <= descr->page_size && orig_num > descr->page_size)
1890
1891 descr->focus_item = min(descr->focus_item, count - 1);
1892 }
1893
1894 /* If it was empty before growing, set focus to the first item */
1895 else if (orig_num == 0) LISTBOX_SetCaretIndex(descr, 0, FALSE);
1896 }
1897 else SendMessageW(descr->self, LB_RESETCONTENT, 0, 0);
1898
1899 InvalidateRect( descr->self, NULL, TRUE );
1900 return LB_OKAY;
1901}
1902
1903
1904/***********************************************************************
1905 * LISTBOX_Directory
1906 */
1908 LPCWSTR filespec, BOOL long_names )
1909{
1910 HANDLE handle;
1913 int pos;
1914 LRESULT maxinsert = LB_ERR;
1915
1916 /* don't scan directory if we just want drives exclusively */
1917 if (attrib != (DDL_DRIVES | DDL_EXCLUSIVE)) {
1918 /* scan directory */
1919 if ((handle = FindFirstFileW(filespec, &entry)) == INVALID_HANDLE_VALUE)
1920 {
1921 int le = GetLastError();
1922 if ((le != ERROR_NO_MORE_FILES) && (le != ERROR_FILE_NOT_FOUND)) return LB_ERR;
1923 }
1924 else
1925 {
1926 do
1927 {
1928 WCHAR buffer[270];
1929 if (entry.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
1930 {
1931 static const WCHAR bracketW[] = { ']',0 };
1932 static const WCHAR dotW[] = { '.',0 };
1933 if (!(attrib & DDL_DIRECTORY) ||
1934 !lstrcmpW( entry.cFileName, dotW )) continue;
1935 buffer[0] = '[';
1936 if (!long_names && entry.cAlternateFileName[0])
1937 lstrcpyW( buffer + 1, entry.cAlternateFileName );
1938 else
1939 lstrcpyW( buffer + 1, entry.cFileName );
1940 lstrcatW(buffer, bracketW);
1941 }
1942 else /* not a directory */
1943 {
1944#define ATTRIBS (FILE_ATTRIBUTE_READONLY | FILE_ATTRIBUTE_HIDDEN | \
1945 FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_ARCHIVE)
1946
1947 if ((attrib & DDL_EXCLUSIVE) &&
1948 ((attrib & ATTRIBS) != (entry.dwFileAttributes & ATTRIBS)))
1949 continue;
1950#undef ATTRIBS
1951 if (!long_names && entry.cAlternateFileName[0])
1952 lstrcpyW( buffer, entry.cAlternateFileName );
1953 else
1954 lstrcpyW( buffer, entry.cFileName );
1955 }
1956 if (!long_names) CharLowerW( buffer );
1958 if ((ret = LISTBOX_InsertString( descr, pos, buffer )) < 0)
1959 break;
1960 if (ret <= maxinsert) maxinsert++; else maxinsert = ret;
1961 } while (FindNextFileW( handle, &entry ));
1962 FindClose( handle );
1963 }
1964 }
1965 if (ret >= 0)
1966 {
1967 ret = maxinsert;
1968
1969 /* scan drives */
1970 if (attrib & DDL_DRIVES)
1971 {
1972 WCHAR buffer[] = {'[','-','a','-',']',0};
1973 WCHAR root[] = {'A',':','\\',0};
1974 int drive;
1975 for (drive = 0; drive < 26; drive++, buffer[2]++, root[0]++)
1976 {
1977 if (GetDriveTypeW(root) <= DRIVE_NO_ROOT_DIR) continue;
1978 if ((ret = LISTBOX_InsertString( descr, -1, buffer )) < 0)
1979 break;
1980 }
1981 }
1982 }
1983 return ret;
1984}
1985
1986
1987/***********************************************************************
1988 * LISTBOX_HandleVScroll
1989 */
1991{
1993
1994 if (descr->style & LBS_MULTICOLUMN) return 0;
1995 switch(scrollReq)
1996 {
1997 case SB_LINEUP:
1998 LISTBOX_SetTopItem( descr, descr->top_item - 1, TRUE );
1999 break;
2000 case SB_LINEDOWN:
2001 LISTBOX_SetTopItem( descr, descr->top_item + 1, TRUE );
2002 break;
2003 case SB_PAGEUP:
2004 LISTBOX_SetTopItem( descr, descr->top_item -
2006 break;
2007 case SB_PAGEDOWN:
2008 LISTBOX_SetTopItem( descr, descr->top_item +
2010 break;
2011 case SB_THUMBPOSITION:
2013 break;
2014 case SB_THUMBTRACK:
2015 info.cbSize = sizeof(info);
2016 info.fMask = SIF_TRACKPOS;
2017 GetScrollInfo( descr->self, SB_VERT, &info );
2018 LISTBOX_SetTopItem( descr, info.nTrackPos, TRUE );
2019 break;
2020 case SB_TOP:
2022 break;
2023 case SB_BOTTOM:
2024 LISTBOX_SetTopItem( descr, descr->nb_items, TRUE );
2025 break;
2026 }
2027 return 0;
2028}
2029
2030
2031/***********************************************************************
2032 * LISTBOX_HandleHScroll
2033 */
2035{
2037 INT page;
2038
2039 if (descr->style & LBS_MULTICOLUMN)
2040 {
2041 switch(scrollReq)
2042 {
2043 case SB_LINELEFT:
2044 LISTBOX_SetTopItem( descr, descr->top_item-descr->page_size,
2045 TRUE );
2046 break;
2047 case SB_LINERIGHT:
2048 LISTBOX_SetTopItem( descr, descr->top_item+descr->page_size,
2049 TRUE );
2050 break;
2051 case SB_PAGELEFT:
2052 page = descr->width / descr->column_width;
2053 if (page < 1) page = 1;
2055 descr->top_item - page * descr->page_size, TRUE );
2056 break;
2057 case SB_PAGERIGHT:
2058 page = descr->width / descr->column_width;
2059 if (page < 1) page = 1;
2061 descr->top_item + page * descr->page_size, TRUE );
2062 break;
2063 case SB_THUMBPOSITION:
2064 LISTBOX_SetTopItem( descr, pos*descr->page_size, TRUE );
2065 break;
2066 case SB_THUMBTRACK:
2067 info.cbSize = sizeof(info);
2068 info.fMask = SIF_TRACKPOS;
2069 GetScrollInfo( descr->self, SB_VERT, &info );
2070 LISTBOX_SetTopItem( descr, info.nTrackPos*descr->page_size,
2071 TRUE );
2072 break;
2073 case SB_LEFT:
2075 break;
2076 case SB_RIGHT:
2077 LISTBOX_SetTopItem( descr, descr->nb_items, TRUE );
2078 break;
2079 }
2080 }
2081 else if (descr->horz_extent)
2082 {
2083 switch(scrollReq)
2084 {
2085 case SB_LINELEFT:
2086 LISTBOX_SetHorizontalPos( descr, descr->horz_pos - 1 );
2087 break;
2088 case SB_LINERIGHT:
2089 LISTBOX_SetHorizontalPos( descr, descr->horz_pos + 1 );
2090 break;
2091 case SB_PAGELEFT:
2093 descr->horz_pos - descr->width );
2094 break;
2095 case SB_PAGERIGHT:
2097 descr->horz_pos + descr->width );
2098 break;
2099 case SB_THUMBPOSITION:
2101 break;
2102 case SB_THUMBTRACK:
2103 info.cbSize = sizeof(info);
2104 info.fMask = SIF_TRACKPOS;
2105 GetScrollInfo( descr->self, SB_HORZ, &info );
2106 LISTBOX_SetHorizontalPos( descr, info.nTrackPos );
2107 break;
2108 case SB_LEFT:
2110 break;
2111 case SB_RIGHT:
2113 descr->horz_extent - descr->width );
2114 break;
2115 }
2116 }
2117 return 0;
2118}
2119
2121{
2122 INT pulScrollLines = 3;
2123
2124 SystemParametersInfoW(SPI_GETWHEELSCROLLLINES,0, &pulScrollLines, 0);
2125
2126 /* if scrolling changes direction, ignore left overs */
2127 if ((delta < 0 && descr->wheel_remain < 0) ||
2128 (delta > 0 && descr->wheel_remain > 0))
2129 descr->wheel_remain += delta;
2130 else
2131 descr->wheel_remain = delta;
2132
2133 if (descr->wheel_remain && pulScrollLines)
2134 {
2135 int cLineScroll;
2136 if (descr->style & LBS_MULTICOLUMN)
2137 {
2138 pulScrollLines = min(descr->width / descr->column_width, pulScrollLines);
2139 pulScrollLines = max(1, pulScrollLines);
2140 cLineScroll = pulScrollLines * descr->wheel_remain / WHEEL_DELTA;
2141 descr->wheel_remain -= WHEEL_DELTA * cLineScroll / pulScrollLines;
2142 cLineScroll *= descr->page_size;
2143 }
2144 else
2145 {
2146 pulScrollLines = min(descr->page_size, pulScrollLines);
2147 cLineScroll = pulScrollLines * descr->wheel_remain / WHEEL_DELTA;
2148 descr->wheel_remain -= WHEEL_DELTA * cLineScroll / pulScrollLines;
2149 }
2150 LISTBOX_SetTopItem( descr, descr->top_item - cLineScroll, TRUE );
2151 }
2152 return 0;
2153}
2154
2155/***********************************************************************
2156 * LISTBOX_HandleLButtonDown
2157 */
2159{
2161
2162 TRACE("[%p]: lbuttondown %d,%d item %d, focus item %d\n",
2163 descr->self, x, y, index, descr->focus_item);
2164
2165 if (!descr->caret_on && (descr->in_focus)) return 0;
2166
2167 if (!descr->in_focus)
2168 {
2169 if( !descr->lphc ) SetFocus( descr->self );
2170 else SetFocus( (descr->lphc->hWndEdit) ? descr->lphc->hWndEdit : descr->lphc->self );
2171 }
2172
2173 if (index == -1) return 0;
2174
2175 if (!descr->lphc)
2176 {
2177 if (descr->style & LBS_NOTIFY )
2179 MAKELPARAM( x, y ) );
2180 }
2181
2182 descr->captured = TRUE;
2183 SetCapture( descr->self );
2184
2185 if (descr->style & (LBS_EXTENDEDSEL | LBS_MULTIPLESEL))
2186 {
2187 /* we should perhaps make sure that all items are deselected
2188 FIXME: needed for !LBS_EXTENDEDSEL, too ?
2189 if (!(keys & (MK_SHIFT|MK_CONTROL)))
2190 LISTBOX_SetSelection( descr, -1, FALSE, FALSE);
2191 */
2192
2193 if (!(keys & MK_SHIFT)) descr->anchor_item = index;
2194 if (keys & MK_CONTROL)
2195 {
2199 (descr->style & LBS_NOTIFY) != 0);
2200 }
2201 else
2202 {
2204
2205 if (descr->style & LBS_EXTENDEDSEL)
2206 {
2209 (descr->style & LBS_NOTIFY) != 0 );
2210 }
2211 else
2212 {
2215 (descr->style & LBS_NOTIFY) != 0 );
2216 }
2217 }
2218 }
2219 else
2220 {
2221 descr->anchor_item = index;
2224 TRUE, (descr->style & LBS_NOTIFY) != 0 );
2225 }
2226
2227 if (!descr->lphc)
2228 {
2230 {
2231 POINT pt;
2232
2233 pt.x = x;
2234 pt.y = y;
2235
2236 if (DragDetect( descr->self, pt ))
2237 SendMessageW( descr->owner, WM_BEGINDRAG, 0, 0 );
2238 }
2239 }
2240 return 0;
2241}
2242
2243
2244/*************************************************************************
2245 * LISTBOX_HandleLButtonDownCombo [Internal]
2246 *
2247 * Process LButtonDown message for the ComboListBox
2248 *
2249 * PARAMS
2250 * pWnd [I] The windows internal structure
2251 * pDescr [I] The ListBox internal structure
2252 * keys [I] Key Flag (WM_LBUTTONDOWN doc for more info)
2253 * x [I] X Mouse Coordinate
2254 * y [I] Y Mouse Coordinate
2255 *
2256 * RETURNS
2257 * 0 since we are processing the WM_LBUTTONDOWN Message
2258 *
2259 * NOTES
2260 * This function is only to be used when a ListBox is a ComboListBox
2261 */
2262
2264{
2265 RECT clientRect, screenRect;
2266 POINT mousePos;
2267
2268 mousePos.x = x;
2269 mousePos.y = y;
2270
2271 GetClientRect(descr->self, &clientRect);
2272
2273 if(PtInRect(&clientRect, mousePos))
2274 {
2275 /* MousePos is in client, resume normal processing */
2276 if (msg == WM_LBUTTONDOWN)
2277 {
2278 descr->lphc->droppedIndex = descr->nb_items ? descr->selected_item : -1;
2280 }
2281 else if (descr->style & LBS_NOTIFY)
2283 }
2284 else
2285 {
2286 POINT screenMousePos;
2287 HWND hWndOldCapture;
2288
2289 /* Check the Non-Client Area */
2290 screenMousePos = mousePos;
2291 hWndOldCapture = GetCapture();
2293 GetWindowRect(descr->self, &screenRect);
2294 ClientToScreen(descr->self, &screenMousePos);
2295
2296 if(!PtInRect(&screenRect, screenMousePos))
2297 {
2298 LISTBOX_SetCaretIndex( descr, descr->lphc->droppedIndex, FALSE );
2299 LISTBOX_SetSelection( descr, descr->lphc->droppedIndex, FALSE, FALSE );
2301 }
2302 else
2303 {
2304 /* Check to see the NC is a scrollbar */
2305 INT nHitTestType=0;
2307 /* Check Vertical scroll bar */
2308 if (style & WS_VSCROLL)
2309 {
2310 clientRect.right += GetSystemMetrics(SM_CXVSCROLL);
2311 if (PtInRect( &clientRect, mousePos ))
2312 nHitTestType = HTVSCROLL;
2313 }
2314 /* Check horizontal scroll bar */
2315 if (style & WS_HSCROLL)
2316 {
2317 clientRect.bottom += GetSystemMetrics(SM_CYHSCROLL);
2318 if (PtInRect( &clientRect, mousePos ))
2319 nHitTestType = HTHSCROLL;
2320 }
2321 /* Windows sends this message when a scrollbar is clicked
2322 */
2323
2324 if(nHitTestType != 0)
2325 {
2326 SendMessageW(descr->self, WM_NCLBUTTONDOWN, nHitTestType,
2327 MAKELONG(screenMousePos.x, screenMousePos.y));
2328 }
2329 /* Resume the Capture after scrolling is complete
2330 */
2331 if(hWndOldCapture != 0)
2332 SetCapture(hWndOldCapture);
2333 }
2334 }
2335 return 0;
2336}
2337
2338/***********************************************************************
2339 * LISTBOX_HandleLButtonUp
2340 */
2342{
2346 if (descr->captured)
2347 {
2348 descr->captured = FALSE;
2349 if (GetCapture() == descr->self) ReleaseCapture();
2350 if ((descr->style & LBS_NOTIFY) && descr->nb_items)
2352 }
2353 return 0;
2354}
2355
2356
2357/***********************************************************************
2358 * LISTBOX_HandleTimer
2359 *
2360 * Handle scrolling upon a timer event.
2361 * Return TRUE if scrolling should continue.
2362 */
2364{
2365 switch(dir)
2366 {
2367 case LB_TIMER_UP:
2368 if (descr->top_item) index = descr->top_item - 1;
2369 else index = 0;
2370 break;
2371 case LB_TIMER_LEFT:
2372 if (descr->top_item) index -= descr->page_size;
2373 break;
2374 case LB_TIMER_DOWN:
2376 if (index == descr->focus_item) index++;
2377 if (index >= descr->nb_items) index = descr->nb_items - 1;
2378 break;
2379 case LB_TIMER_RIGHT:
2380 if (index + descr->page_size < descr->nb_items)
2381 index += descr->page_size;
2382 break;
2383 case LB_TIMER_NONE:
2384 break;
2385 }
2386 if (index == descr->focus_item) return FALSE;
2388 return TRUE;
2389}
2390
2391
2392/***********************************************************************
2393 * LISTBOX_HandleSystemTimer
2394 *
2395 * WM_SYSTIMER handler.
2396 */
2398{
2399 if (!LISTBOX_HandleTimer( descr, descr->focus_item, LISTBOX_Timer ))
2400 {
2403 }
2404 return 0;
2405}
2406
2407
2408/***********************************************************************
2409 * LISTBOX_HandleMouseMove
2410 *
2411 * WM_MOUSEMOVE handler.
2412 */
2414 INT x, INT y )
2415{
2416 INT index;
2418
2419 if (!descr->captured) return;
2420
2421 if (descr->style & LBS_MULTICOLUMN)
2422 {
2423 if (y < 0) y = 0;
2424 else if (y >= descr->item_height * descr->page_size)
2425 y = descr->item_height * descr->page_size - 1;
2426
2427 if (x < 0)
2428 {
2430 x = 0;
2431 }
2432 else if (x >= descr->width)
2433 {
2435 x = descr->width - 1;
2436 }
2437 }
2438 else
2439 {
2440 if (y < 0) dir = LB_TIMER_UP; /* above */
2441 else if (y >= descr->height) dir = LB_TIMER_DOWN; /* below */
2442 }
2443
2445 if (index == -1) index = descr->focus_item;
2447
2448 /* Start/stop the system timer */
2449
2450 if (dir != LB_TIMER_NONE)
2452 else if (LISTBOX_Timer != LB_TIMER_NONE)
2455}
2456
2457
2458/***********************************************************************
2459 * LISTBOX_HandleKeyDown
2460 */
2462{
2463 INT caret = -1;
2464 BOOL bForceSelection = TRUE; /* select item pointed to by focus_item */
2465 if ((IS_MULTISELECT(descr)) || (descr->selected_item == descr->focus_item))
2466 bForceSelection = FALSE; /* only for single select list */
2467
2468 if (descr->style & LBS_WANTKEYBOARDINPUT)
2469 {
2470 caret = SendMessageW( descr->owner, WM_VKEYTOITEM,
2471 MAKEWPARAM(LOWORD(key), descr->focus_item),
2472 (LPARAM)descr->self );
2473 if (caret == -2) return 0;
2474 }
2475 if (caret == -1) switch(key)
2476 {
2477 case VK_LEFT:
2478 if (descr->style & LBS_MULTICOLUMN)
2479 {
2480 bForceSelection = FALSE;
2481 if (descr->focus_item >= descr->page_size)
2482 caret = descr->focus_item - descr->page_size;
2483 break;
2484 }
2485 /* fall through */
2486 case VK_UP:
2487 caret = descr->focus_item - 1;
2488 if (caret < 0) caret = 0;
2489 break;
2490 case VK_RIGHT:
2491 if (descr->style & LBS_MULTICOLUMN)
2492 {
2493 bForceSelection = FALSE;
2494 caret = min(descr->focus_item + descr->page_size, descr->nb_items - 1);
2495 break;
2496 }
2497 /* fall through */
2498 case VK_DOWN:
2499 caret = descr->focus_item + 1;
2500 if (caret >= descr->nb_items) caret = descr->nb_items - 1;
2501 break;
2502
2503 case VK_PRIOR:
2504 if (descr->style & LBS_MULTICOLUMN)
2505 {
2506 INT page = descr->width / descr->column_width;
2507 if (page < 1) page = 1;
2508 caret = descr->focus_item - (page * descr->page_size) + 1;
2509 }
2510 else caret = descr->focus_item-LISTBOX_GetCurrentPageSize(descr) + 1;
2511 if (caret < 0) caret = 0;
2512 break;
2513 case VK_NEXT:
2514 if (descr->style & LBS_MULTICOLUMN)
2515 {
2516 INT page = descr->width / descr->column_width;
2517 if (page < 1) page = 1;
2518 caret = descr->focus_item + (page * descr->page_size) - 1;
2519 }
2520 else caret = descr->focus_item + LISTBOX_GetCurrentPageSize(descr) - 1;
2521 if (caret >= descr->nb_items) caret = descr->nb_items - 1;
2522 break;
2523 case VK_HOME:
2524 caret = 0;
2525 break;
2526 case VK_END:
2527 caret = descr->nb_items - 1;
2528 break;
2529 case VK_SPACE:
2530 if (descr->style & LBS_EXTENDEDSEL) caret = descr->focus_item;
2531 else if (descr->style & LBS_MULTIPLESEL)
2532 {
2533 LISTBOX_SetSelection( descr, descr->focus_item,
2534 !is_item_selected(descr, descr->focus_item),
2535 (descr->style & LBS_NOTIFY) != 0 );
2536 }
2537 break;
2538 default:
2539 bForceSelection = FALSE;
2540 }
2541 if (bForceSelection) /* focused item is used instead of key */
2542 caret = descr->focus_item;
2543 if (caret >= 0)
2544 {
2545 if (((descr->style & LBS_EXTENDEDSEL) &&
2546 !(GetKeyState( VK_SHIFT ) & 0x8000)) ||
2548 descr->anchor_item = caret;
2549 LISTBOX_MoveCaret( descr, caret, TRUE );
2550
2551 if (descr->style & LBS_MULTIPLESEL)
2552 descr->selected_item = caret;
2553 else
2555 if (descr->style & LBS_NOTIFY)
2556 {
2557 if (descr->lphc && IsWindowVisible( descr->self ))
2558 {
2559 /* make sure that combo parent doesn't hide us */
2560 descr->lphc->wState |= CBF_NOROLLUP;
2561 }
2562 if (descr->nb_items) SEND_NOTIFICATION( descr, LBN_SELCHANGE );
2563 }
2564 }
2565 return 0;
2566}
2567
2568
2569/***********************************************************************
2570 * LISTBOX_HandleChar
2571 */
2573{
2574 INT caret = -1;
2575 WCHAR str[2];
2576
2577 str[0] = charW;
2578 str[1] = '\0';
2579
2580 if (descr->style & LBS_WANTKEYBOARDINPUT)
2581 {
2582 caret = SendMessageW( descr->owner, WM_CHARTOITEM,
2583 MAKEWPARAM(charW, descr->focus_item),
2584 (LPARAM)descr->self );
2585 if (caret == -2) return 0;
2586 }
2587 if (caret == -1)
2588 caret = LISTBOX_FindString( descr, descr->focus_item, str, FALSE);
2589 if (caret != -1)
2590 {
2591 if ((!IS_MULTISELECT(descr)) && descr->selected_item == -1)
2593 LISTBOX_MoveCaret( descr, caret, TRUE );
2594 if ((descr->style & LBS_NOTIFY) && descr->nb_items)
2596 }
2597 return 0;
2598}
2599
2600
2601/***********************************************************************
2602 * LISTBOX_Create
2603 */
2605{
2606 LB_DESCR *descr;
2608 RECT rect;
2609
2610 if (!(descr = HeapAlloc( GetProcessHeap(), 0, sizeof(*descr) )))
2611 return FALSE;
2612
2613 GetClientRect( hwnd, &rect );
2614 descr->self = hwnd;
2615 descr->owner = GetParent( descr->self );
2616 descr->style = GetWindowLongW( descr->self, GWL_STYLE );
2617 descr->width = rect.right - rect.left;
2618 descr->height = rect.bottom - rect.top;
2619 descr->u.items = NULL;
2620 descr->items_size = 0;
2621 descr->nb_items = 0;
2622 descr->top_item = 0;
2623 descr->selected_item = -1;
2624 descr->focus_item = 0;
2625 descr->anchor_item = -1;
2626 descr->item_height = 1;
2627 descr->page_size = 1;
2628 descr->column_width = 150;
2629 descr->horz_extent = 0;
2630 descr->horz_pos = 0;
2631 descr->nb_tabs = 0;
2632 descr->tabs = NULL;
2633 descr->wheel_remain = 0;
2634 descr->caret_on = !lphc;
2635 if (descr->style & LBS_NOSEL) descr->caret_on = FALSE;
2636 descr->in_focus = FALSE;
2637 descr->captured = FALSE;
2638 descr->font = 0;
2639 descr->locale = GetUserDefaultLCID();
2640 descr->lphc = lphc;
2641
2642 if( lphc )
2643 {
2644 TRACE("[%p]: resetting owner %p -> %p\n", descr->self, descr->owner, lphc->self );
2645 descr->owner = lphc->self;
2646 }
2647
2648 SetWindowLongPtrW( descr->self, 0, (LONG_PTR)descr );
2649
2650/* if (wnd->dwExStyle & WS_EX_NOPARENTNOTIFY) descr->style &= ~LBS_NOTIFY;
2651 */
2652 if (descr->style & LBS_EXTENDEDSEL) descr->style |= LBS_MULTIPLESEL;
2653 if (descr->style & LBS_MULTICOLUMN) descr->style &= ~LBS_OWNERDRAWVARIABLE;
2654 if (descr->style & LBS_OWNERDRAWVARIABLE) descr->style |= LBS_NOINTEGRALHEIGHT;
2656 descr->style &= ~LBS_NODATA;
2657 descr->item_height = LISTBOX_SetFont( descr, 0 );
2658
2659 if (descr->style & LBS_OWNERDRAWFIXED)
2660 {
2661 descr->style &= ~LBS_OWNERDRAWVARIABLE;
2662
2663 if( descr->lphc && (descr->lphc->dwStyle & CBS_DROPDOWN))
2664 {
2665 /* WinWord gets VERY unhappy if we send WM_MEASUREITEM from here */
2666 descr->item_height = lphc->fixedOwnerDrawHeight;
2667 }
2668 else
2669 {
2670 UINT id = (UINT)GetWindowLongPtrW( descr->self, GWLP_ID );
2671 mis.CtlType = ODT_LISTBOX;
2672 mis.CtlID = id;
2673 mis.itemID = -1;
2674 mis.itemWidth = 0;
2675 mis.itemData = 0;
2676 mis.itemHeight = descr->item_height;
2677 SendMessageW( descr->owner, WM_MEASUREITEM, id, (LPARAM)&mis );
2678 descr->item_height = mis.itemHeight ? mis.itemHeight : 1;
2679 }
2680 }
2681
2683
2684 TRACE("owner: %p, style: %08x, width: %d, height: %d\n", descr->owner, descr->style, descr->width, descr->height);
2685 return TRUE;
2686}
2687
2688
2689/***********************************************************************
2690 * LISTBOX_Destroy
2691 */
2693{
2694 HTHEME theme = GetWindowTheme( descr->self );
2695 CloseThemeData( theme );
2697 SetWindowLongPtrW( descr->self, 0, 0 );
2698 HeapFree( GetProcessHeap(), 0, descr );
2699 return TRUE;
2700}
2701
2702
2703/***********************************************************************
2704 * ListBoxWndProc_common
2705 */
2707{
2709 HEADCOMBO *lphc = NULL;
2710 HTHEME theme;
2711 LRESULT ret;
2712
2713 if (!descr)
2714 {
2715 if (!IsWindow(hwnd)) return 0;
2716
2717 if (msg == WM_CREATE)
2718 {
2720 if (lpcs->style & LBS_COMBOBOX) lphc = lpcs->lpCreateParams;
2721 if (!LISTBOX_Create( hwnd, lphc )) return -1;
2722 TRACE("creating hwnd %p descr %p\n", hwnd, (void *)GetWindowLongPtrW( hwnd, 0 ) );
2723 return 0;
2724 }
2725 /* Ignore all other messages before we get a WM_CREATE */
2726 return DefWindowProcW( hwnd, msg, wParam, lParam );
2727 }
2728 if (descr->style & LBS_COMBOBOX) lphc = descr->lphc;
2729
2730 TRACE("[%p]: msg %#x wp %08lx lp %08lx\n", descr->self, msg, wParam, lParam );
2731
2732 switch(msg)
2733 {
2734 case LB_RESETCONTENT:
2737 InvalidateRect( descr->self, NULL, TRUE );
2738 return 0;
2739
2740 case LB_ADDSTRING:
2741 {
2742 const WCHAR *textW = (const WCHAR *)lParam;
2745 }
2746
2747 case LB_INSERTSTRING:
2748 return LISTBOX_InsertString( descr, wParam, (const WCHAR *)lParam );
2749
2750 case LB_ADDFILE:
2751 {
2752 const WCHAR *textW = (const WCHAR *)lParam;
2755 }
2756
2757 case LB_DELETESTRING:
2759 return descr->nb_items;
2760 else
2761 {
2763 return LB_ERR;
2764 }
2765
2766 case LB_GETITEMDATA:
2767 if (((INT)wParam < 0) || ((INT)wParam >= descr->nb_items))
2768 {
2770 return LB_ERR;
2771 }
2772 return get_item_data(descr, wParam);
2773
2774 case LB_SETITEMDATA:
2775 if (((INT)wParam < 0) || ((INT)wParam >= descr->nb_items))
2776 {
2778 return LB_ERR;
2779 }
2781 /* undocumented: returns TRUE, not LB_OKAY (0) */
2782 return TRUE;
2783
2784 case LB_GETCOUNT:
2785 return descr->nb_items;
2786
2787 case LB_GETTEXT:
2789
2790 case LB_GETTEXTLEN:
2791 if ((INT)wParam >= descr->nb_items || (INT)wParam < 0)
2792 {
2794 return LB_ERR;
2795 }
2796 if (!HAS_STRINGS(descr)) return sizeof(ULONG_PTR);
2798
2799 case LB_GETCURSEL:
2800 if (descr->nb_items == 0)
2801 return LB_ERR;
2802 if (!IS_MULTISELECT(descr))
2803 return descr->selected_item;
2804 if (descr->selected_item != -1)
2805 return descr->selected_item;
2806 return descr->focus_item;
2807 /* otherwise, if the user tries to move the selection with the */
2808 /* arrow keys, we will give the application something to choke on */
2809 case LB_GETTOPINDEX:
2810 return descr->top_item;
2811
2812 case LB_GETITEMHEIGHT:
2814
2815 case LB_SETITEMHEIGHT:
2817
2818 case LB_ITEMFROMPOINT:
2819 {
2820 POINT pt;
2821 RECT rect;
2822 int index;
2823 BOOL hit = TRUE;
2824
2825 /* The hiword of the return value is not a client area
2826 hittest as suggested by MSDN, but rather a hittest on
2827 the returned listbox item. */
2828
2829 if(descr->nb_items == 0)
2830 return 0x1ffff; /* win9x returns 0x10000, we copy winnt */
2831
2832 pt.x = (short)LOWORD(lParam);
2833 pt.y = (short)HIWORD(lParam);
2834
2835 SetRect(&rect, 0, 0, descr->width, descr->height);
2836
2837 if(!PtInRect(&rect, pt))
2838 {
2839 pt.x = min(pt.x, rect.right - 1);
2840 pt.x = max(pt.x, 0);
2841 pt.y = min(pt.y, rect.bottom - 1);
2842 pt.y = max(pt.y, 0);
2843 hit = FALSE;
2844 }
2845
2847
2848 if(index == -1)
2849 {
2850 index = descr->nb_items - 1;
2851 hit = FALSE;
2852 }
2853 return MAKELONG(index, hit ? 0 : 1);
2854 }
2855
2856 case LB_SETCARETINDEX:
2857 if ((!IS_MULTISELECT(descr)) && (descr->selected_item != -1)) return LB_ERR;
2859 return LB_ERR;
2860 else if (ISWIN31)
2861 return wParam;
2862 else
2863 return LB_OKAY;
2864
2865 case LB_GETCARETINDEX:
2866 return descr->focus_item;
2867
2868 case LB_SETTOPINDEX:
2869 return LISTBOX_SetTopItem( descr, wParam, TRUE );
2870
2871 case LB_SETCOLUMNWIDTH:
2873
2874 case LB_GETITEMRECT:
2876
2877 case LB_FINDSTRING:
2878 return LISTBOX_FindString( descr, wParam, (const WCHAR *)lParam, FALSE );
2879
2880 case LB_FINDSTRINGEXACT:
2881 return LISTBOX_FindString( descr, wParam, (const WCHAR *)lParam, TRUE );
2882
2883 case LB_SELECTSTRING:
2884 {
2885 const WCHAR *textW = (const WCHAR *)lParam;
2886 INT index;
2887
2888 if (HAS_STRINGS(descr))
2889 TRACE("LB_SELECTSTRING: %s\n", debugstr_w(textW));
2890
2892 if (index != LB_ERR)
2893 {
2896 }
2897 return index;
2898 }
2899
2900 case LB_GETSEL:
2901 if (((INT)wParam < 0) || ((INT)wParam >= descr->nb_items))
2902 return LB_ERR;
2903 return is_item_selected(descr, wParam);
2904
2905 case LB_SETSEL:
2907 if (ret != LB_ERR && wParam)
2908 {
2909 descr->anchor_item = lParam;
2910 if (lParam != -1)
2912 }
2913 return ret;
2914
2915 case LB_SETCURSEL:
2916 if (IS_MULTISELECT(descr)) return LB_ERR;
2919 if (ret != LB_ERR) ret = descr->selected_item;
2920 return ret;
2921
2922 case LB_GETSELCOUNT:
2923 return LISTBOX_GetSelCount( descr );
2924
2925 case LB_GETSELITEMS:
2927
2928 case LB_SELITEMRANGE:
2929 if (LOWORD(lParam) <= HIWORD(lParam))
2931 HIWORD(lParam), wParam );
2932 else
2934 LOWORD(lParam), wParam );
2935
2936 case LB_SELITEMRANGEEX:
2937 if ((INT)lParam >= (INT)wParam)
2939 else
2941
2943 return descr->horz_extent;
2944
2947
2948 case LB_GETANCHORINDEX:
2949 return descr->anchor_item;
2950
2951 case LB_SETANCHORINDEX:
2952 if (((INT)wParam < -1) || ((INT)wParam >= descr->nb_items))
2953 {
2955 return LB_ERR;
2956 }
2957 descr->anchor_item = (INT)wParam;
2958 return LB_OKAY;
2959
2960 case LB_DIR:
2961 return LISTBOX_Directory( descr, wParam, (const WCHAR *)lParam, msg == LB_DIR );
2962
2963 case LB_GETLOCALE:
2964 return descr->locale;
2965
2966 case LB_SETLOCALE:
2967 {
2968 LCID ret;
2970 return LB_ERR;
2971 ret = descr->locale;
2972 descr->locale = (LCID)wParam;
2973 return ret;
2974 }
2975
2976 case LB_INITSTORAGE:
2977 return LISTBOX_InitStorage( descr, wParam );
2978
2979 case LB_SETCOUNT:
2980 return LISTBOX_SetCount( descr, (INT)wParam );
2981
2982 case LB_SETTABSTOPS:
2984
2985 case LB_CARETON:
2986 if (descr->caret_on)
2987 return LB_OKAY;
2988 descr->caret_on = TRUE;
2989 if ((descr->focus_item != -1) && (descr->in_focus))
2990 LISTBOX_RepaintItem( descr, descr->focus_item, ODA_FOCUS );
2991 return LB_OKAY;
2992
2993 case LB_CARETOFF:
2994 if (!descr->caret_on)
2995 return LB_OKAY;
2996 descr->caret_on = FALSE;
2997 if ((descr->focus_item != -1) && (descr->in_focus))
2998 LISTBOX_RepaintItem( descr, descr->focus_item, ODA_FOCUS );
2999 return LB_OKAY;
3000
3001 case LB_GETLISTBOXINFO:
3002 return descr->page_size;
3003
3004 case WM_DESTROY:
3005 return LISTBOX_Destroy( descr );
3006
3007 case WM_ENABLE:
3008 InvalidateRect( descr->self, NULL, TRUE );
3009 return 0;
3010
3011 case WM_SETREDRAW:
3013 return 0;
3014
3015 case WM_GETDLGCODE:
3017
3018 case WM_PRINTCLIENT:
3019 case WM_PAINT:
3020 {
3021 PAINTSTRUCT ps;
3022 HDC hdc = ( wParam ) ? ((HDC)wParam) : BeginPaint( descr->self, &ps );
3023 ret = LISTBOX_Paint( descr, hdc );
3024 if( !wParam ) EndPaint( descr->self, &ps );
3025 }
3026 return ret;
3027
3028 case WM_NCPAINT:
3029 LISTBOX_NCPaint( descr, (HRGN)wParam );
3030 break;
3031
3032 case WM_SIZE:
3034 return 0;
3035 case WM_GETFONT:
3036 return (LRESULT)descr->font;
3037 case WM_SETFONT:
3039 if (lParam) InvalidateRect( descr->self, 0, TRUE );
3040 return 0;
3041 case WM_SETFOCUS:
3042 descr->in_focus = TRUE;
3043 descr->caret_on = TRUE;
3044 if (descr->focus_item != -1)
3047 return 0;
3048 case WM_KILLFOCUS:
3049 LISTBOX_HandleLButtonUp( descr ); /* Release capture if we have it */
3050 descr->in_focus = FALSE;
3051 descr->wheel_remain = 0;
3052 if ((descr->focus_item != -1) && descr->caret_on)
3053 LISTBOX_RepaintItem( descr, descr->focus_item, ODA_FOCUS );
3055 return 0;
3056 case WM_HSCROLL:
3058 case WM_VSCROLL:
3060 case WM_MOUSEWHEEL:
3061 if (wParam & (MK_SHIFT | MK_CONTROL))
3062 return DefWindowProcW( descr->self, msg, wParam, lParam );
3064 case WM_LBUTTONDOWN:
3065 if (lphc)
3068 (INT16)HIWORD(lParam) );
3071 (INT16)HIWORD(lParam) );
3072 case WM_LBUTTONDBLCLK:
3073 if (lphc)
3076 (INT16)HIWORD(lParam) );
3077 if (descr->style & LBS_NOTIFY)
3079 return 0;
3080 case WM_MOUSEMOVE:
3081 if ( lphc && ((lphc->dwStyle & CBS_DROPDOWNLIST) != CBS_SIMPLE) )
3082 {
3083 BOOL captured = descr->captured;
3084 POINT mousePos;
3085 RECT clientRect;
3086
3087 mousePos.x = (INT16)LOWORD(lParam);
3088 mousePos.y = (INT16)HIWORD(lParam);
3089
3090 /*
3091 * If we are in a dropdown combobox, we simulate that
3092 * the mouse is captured to show the tracking of the item.
3093 */
3094 if (GetClientRect(descr->self, &clientRect) && PtInRect( &clientRect, mousePos ))
3095 descr->captured = TRUE;
3096
3097 LISTBOX_HandleMouseMove( descr, mousePos.x, mousePos.y);
3098
3099 descr->captured = captured;
3100 }
3101 else if (GetCapture() == descr->self)
3102 {
3104 (INT16)HIWORD(lParam) );
3105 }
3106 return 0;
3107 case WM_LBUTTONUP:
3108 if (lphc)
3109 {
3110 POINT mousePos;
3111 RECT clientRect;
3112
3113 /*
3114 * If the mouse button "up" is not in the listbox,
3115 * we make sure there is no selection by re-selecting the
3116 * item that was selected when the listbox was made visible.
3117 */
3118 mousePos.x = (INT16)LOWORD(lParam);
3119 mousePos.y = (INT16)HIWORD(lParam);
3120
3121 GetClientRect(descr->self, &clientRect);
3122
3123 /*
3124 * When the user clicks outside the combobox and the focus
3125 * is lost, the owning combobox will send a fake buttonup with
3126 * 0xFFFFFFF as the mouse location, we must also revert the
3127 * selection to the original selection.
3128 */
3129 if ( (lParam == (LPARAM)-1) || (!PtInRect( &clientRect, mousePos )) )
3131 }
3133 case WM_KEYDOWN:
3134 if( lphc && (lphc->dwStyle & CBS_DROPDOWNLIST) != CBS_SIMPLE )
3135 {
3136 /* for some reason Windows makes it possible to
3137 * show/hide ComboLBox by sending it WM_KEYDOWNs */
3138
3139 if( (!(lphc->wState & CBF_EUI) && wParam == VK_F4) ||
3140 ( (lphc->wState & CBF_EUI) && !(lphc->wState & CBF_DROPPED)
3141 && (wParam == VK_DOWN || wParam == VK_UP)) )
3142 {
3143 COMBO_FlipListbox( lphc, FALSE, FALSE );
3144 return 0;
3145 }
3146 }
3148 case WM_CHAR:
3149 return LISTBOX_HandleChar( descr, wParam );
3150
3151 case WM_SYSTIMER:
3153 case WM_ERASEBKGND:
3154 if ((IS_OWNERDRAW(descr)) && !(descr->style & LBS_DISPLAYCHANGED))
3155 {
3156 RECT rect;
3157 HBRUSH hbrush = (HBRUSH)SendMessageW( descr->owner, WM_CTLCOLORLISTBOX,
3158 wParam, (LPARAM)descr->self );
3159 TRACE("hbrush = %p\n", hbrush);
3160 if(!hbrush)
3162 if(hbrush)
3163 {
3164 GetClientRect(descr->self, &rect);
3166 }
3167 }
3168 return 1;
3169 case WM_DROPFILES:
3170 if( lphc ) return 0;
3171 return SendMessageW( descr->owner, msg, wParam, lParam );
3172
3173 case WM_NCDESTROY:
3174 if( lphc && (lphc->dwStyle & CBS_DROPDOWNLIST) != CBS_SIMPLE )
3175 lphc->hWndLBox = 0;
3176 break;
3177
3178 case WM_NCACTIVATE:
3179 if (lphc) return 0;
3180 break;
3181
3182 case WM_THEMECHANGED:
3183 theme = GetWindowTheme( hwnd );
3184 CloseThemeData( theme );
3186 break;
3187
3188 default:
3189 if ((msg >= WM_USER) && (msg < 0xc000))
3190 WARN("[%p]: unknown msg %04x wp %08lx lp %08lx\n",
3191 hwnd, msg, wParam, lParam );
3192 }
3193
3194 return DefWindowProcW( hwnd, msg, wParam, lParam );
3195}
3196
3198{
3199 WNDCLASSW wndClass;
3200
3201 memset(&wndClass, 0, sizeof(wndClass));
3204 wndClass.cbClsExtra = 0;
3205 wndClass.cbWndExtra = sizeof(LB_DESCR *);
3206 wndClass.hCursor = LoadCursorW(0, (LPWSTR)IDC_ARROW);
3207 wndClass.hbrBackground = NULL;
3208 wndClass.lpszClassName = WC_LISTBOXW;
3209 RegisterClassW(&wndClass);
3210}
3211
3213{
3214 static const WCHAR combolboxW[] = {'C','o','m','b','o','L','B','o','x',0};
3215 WNDCLASSW wndClass;
3216
3217 memset(&wndClass, 0, sizeof(wndClass));
3220 wndClass.cbClsExtra = 0;
3221 wndClass.cbWndExtra = sizeof(LB_DESCR *);
3222 wndClass.hCursor = LoadCursorW(0, (LPWSTR)IDC_ARROW);
3223 wndClass.hbrBackground = NULL;
3224 wndClass.lpszClassName = combolboxW;
3225 RegisterClassW(&wndClass);
3226}
3227
3228#ifdef __REACTOS__
3229void LISTBOX_Unregister(void)
3230{
3232}
3233
3234void COMBOLBOX_Unregister(void)
3235{
3236 static const WCHAR combolboxW[] = {'C','o','m','b','o','L','B','o','x',0};
3238}
3239#endif
static HRGN hrgn
static HBRUSH hbrush
short INT16
Definition: actypes.h:130
Arabic default style
Definition: afstyles.h:94
static int state
Definition: maze.c:121
unsigned int dir
Definition: maze.c:112
static void * heap_realloc(void *mem, size_t len)
Definition: appwiz.h:71
static const char * wine_dbgstr_rect(const RECT *prc)
Definition: atltest.h:160
#define msg(x)
Definition: auth_time.c:54
#define WINE_DEFAULT_DEBUG_CHANNEL(t)
Definition: precomp.h:23
#define index(s, c)
Definition: various.h:29
#define WARN(fmt,...)
Definition: precomp.h:61
#define ERR(fmt,...)
Definition: precomp.h:57
WPARAM wParam
Definition: combotst.c:138
LPARAM lParam
Definition: combotst.c:139
#define WM_SYSTIMER
Definition: comctl32.h:125
#define CBF_SELCHANGE
Definition: controls.h:55
#define CBF_DROPPED
Definition: controls.h:45
#define CBF_EUI
Definition: controls.h:59
#define CBF_NOROLLUP
Definition: controls.h:47
static char selected[MAX_PATH+1]
Definition: dirdlg.c:7
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
HRGN set_control_clipping(HDC hdc, const RECT *rect)
Definition: button.c:242
BOOL COMBO_FlipListbox(LPHEADCOMBO lphc, BOOL ok, BOOL bRedrawButton)
Definition: combo.c:1086
static LRESULT LISTBOX_RemoveItem(LB_DESCR *descr, INT index)
Definition: listbox.c:1796
#define SEND_NOTIFICATION(descr, code)
Definition: listbox.c:111
static LRESULT LISTBOX_InsertString(LB_DESCR *descr, INT index, LPCWSTR str)
Definition: listbox.c:1733
static void LISTBOX_DrawFocusRect(LB_DESCR *descr, BOOL on)
Definition: listbox.c:797
static void LISTBOX_SetHorizontalPos(LB_DESCR *descr, INT pos)
Definition: listbox.c:1364
static LRESULT LISTBOX_HandleKeyDown(LB_DESCR *descr, DWORD key)
Definition: listbox.c:2461
static LRESULT LISTBOX_SetCaretIndex(LB_DESCR *descr, INT index, BOOL fully_visible)
Definition: listbox.c:1510
static BOOL LISTBOX_SetTabStops(LB_DESCR *descr, INT count, LPINT tabs)
Definition: listbox.c:837
static LRESULT LISTBOX_HandleLButtonUp(LB_DESCR *descr)
Definition: listbox.c:2341
#define ATTRIBS
static void remove_item_data(LB_DESCR *descr, UINT index)
Definition: listbox.c:237
static void LISTBOX_DeleteItem(LB_DESCR *descr, INT index)
Definition: listbox.c:1768
static void LISTBOX_InvalidateItems(LB_DESCR *descr, INT index)
Definition: listbox.c:1275
static LRESULT LISTBOX_GetSelCount(const LB_DESCR *descr)
Definition: listbox.c:1075
static void LISTBOX_SetRedraw(LB_DESCR *descr, BOOL on)
Definition: listbox.c:737
static void LISTBOX_InvalidateItemRect(LB_DESCR *descr, INT index)
Definition: listbox.c:1299
static LRESULT LISTBOX_GetText(LB_DESCR *descr, INT index, LPWSTR buffer, BOOL unicode)
Definition: listbox.c:869
#define ISWIN31
Definition: listbox.c:115
static LRESULT LISTBOX_InitStorage(LB_DESCR *descr, INT nb_items)
Definition: listbox.c:824
static void LISTBOX_MakeItemVisible(LB_DESCR *descr, INT index, BOOL fully)
Definition: listbox.c:1471
static INT LISTBOX_FindFileStrPos(LB_DESCR *descr, LPCWSTR str)
Definition: listbox.c:971
static LRESULT LISTBOX_SetSelection(LB_DESCR *descr, INT index, BOOL on, BOOL send_notify)
Definition: listbox.c:1579
static LRESULT LISTBOX_HandleLButtonDownCombo(LB_DESCR *descr, UINT msg, DWORD keys, INT x, INT y)
Definition: listbox.c:2263
static LRESULT LISTBOX_HandleVScroll(LB_DESCR *descr, WORD scrollReq, WORD pos)
Definition: listbox.c:1990
#define IS_MULTISELECT(descr)
Definition: listbox.c:107
static void LISTBOX_ResetContent(LB_DESCR *descr)
Definition: listbox.c:1848
static LRESULT LISTBOX_HandleTimer(LB_DESCR *descr, INT index, TIMER_DIRECTION dir)
Definition: listbox.c:2363
#define HAS_STRINGS(descr)
Definition: listbox.c:103
static LRESULT LISTBOX_HandleMouseWheel(LB_DESCR *descr, SHORT delta)
Definition: listbox.c:2120
TIMER_DIRECTION
Definition: listbox.c:119
@ LB_TIMER_NONE
Definition: listbox.c:120
@ LB_TIMER_UP
Definition: listbox.c:121
@ LB_TIMER_RIGHT
Definition: listbox.c:124
@ LB_TIMER_DOWN
Definition: listbox.c:123
@ LB_TIMER_LEFT
Definition: listbox.c:122
static UINT get_item_height(const LB_DESCR *descr, UINT index)
Definition: listbox.c:195
static LRESULT LISTBOX_SetHorizontalExtent(LB_DESCR *descr, INT extent)
Definition: listbox.c:1392
static void set_item_height(LB_DESCR *descr, UINT index, UINT height)
Definition: listbox.c:200
static void set_item_selected_state(LB_DESCR *descr, UINT index, BOOL state)
Definition: listbox.c:215
static LRESULT LISTBOX_InsertItem(LB_DESCR *descr, INT index, LPWSTR str, ULONG_PTR data)
Definition: listbox.c:1669
static void LISTBOX_MoveCaret(LB_DESCR *descr, INT index, BOOL fully_visible)
Definition: listbox.c:1622
static LRESULT LISTBOX_GetSelItems(const LB_DESCR *descr, INT max, LPINT array)
Definition: listbox.c:1091
static BOOL is_item_selected(const LB_DESCR *descr, UINT index)
Definition: listbox.c:205
static LRESULT LISTBOX_Paint(LB_DESCR *descr, HDC hdc)
Definition: listbox.c:1105
static void LISTBOX_UpdateScroll(LB_DESCR *descr)
Definition: listbox.c:303
static TIMER_DIRECTION LISTBOX_Timer
Definition: listbox.c:127
static LRESULT LISTBOX_SetTopItem(LB_DESCR *descr, INT index, BOOL scroll)
Definition: listbox.c:386
static INT LISTBOX_SetFont(LB_DESCR *descr, HFONT font)
Definition: listbox.c:1440
static LRESULT LISTBOX_SetColumnWidth(LB_DESCR *descr, INT column_width)
Definition: listbox.c:1418
static LRESULT LISTBOX_HandleHScroll(LB_DESCR *descr, WORD scrollReq, WORD pos)
Definition: listbox.c:2034
static ULONG_PTR get_item_data(const LB_DESCR *descr, UINT index)
Definition: listbox.c:175
static LRESULT LISTBOX_SelectItemRange(LB_DESCR *descr, INT first, INT last, BOOL on)
Definition: listbox.c:1539
static void set_item_data(LB_DESCR *descr, UINT index, ULONG_PTR data)
Definition: listbox.c:180
void LISTBOX_Register(void)
Definition: listbox.c:3197
static void LISTBOX_RepaintItem(LB_DESCR *descr, INT index, UINT action)
Definition: listbox.c:764
static LRESULT LISTBOX_GetItemRect(const LB_DESCR *descr, INT index, RECT *rect)
Definition: listbox.c:500
static void set_item_string(const LB_DESCR *descr, UINT index, WCHAR *string)
Definition: listbox.c:190
static INT LISTBOX_FindString(LB_DESCR *descr, INT start, LPCWSTR str, BOOL exact)
Definition: listbox.c:1015
static void insert_item_data(LB_DESCR *descr, UINT index)
Definition: listbox.c:226
static BOOL LISTBOX_Destroy(LB_DESCR *descr)
Definition: listbox.c:2692
#define LB_ARRAY_GRANULARITY
Definition: listbox.c:43
static void LISTBOX_NCPaint(LB_DESCR *descr, HRGN region)
Definition: listbox.c:1226
void COMBOLBOX_Register(void)
Definition: listbox.c:3212
static LRESULT LISTBOX_HandleSystemTimer(LB_DESCR *descr)
Definition: listbox.c:2397
#define LB_TIMER_ID
Definition: listbox.c:49
static BOOL resize_storage(LB_DESCR *descr, UINT items_size)
Definition: listbox.c:146
static LRESULT LISTBOX_Directory(LB_DESCR *descr, UINT attrib, LPCWSTR filespec, BOOL long_names)
Definition: listbox.c:1907
static void LISTBOX_HandleMouseMove(LB_DESCR *descr, INT x, INT y)
Definition: listbox.c:2413
static LRESULT LISTBOX_GetItemHeight(const LB_DESCR *descr, INT index)
Definition: listbox.c:1310
#define LB_SCROLL_TIMEOUT
Definition: listbox.c:46
static INT LISTBOX_FindStringPos(LB_DESCR *descr, LPCWSTR str, BOOL exact)
Definition: listbox.c:927
static void LISTBOX_PaintItem(LB_DESCR *descr, HDC hdc, const RECT *rect, INT index, UINT action, BOOL ignoreFocus)
Definition: listbox.c:605
#define IS_OWNERDRAW(descr)
Definition: listbox.c:100
static INT LISTBOX_GetItemFromPoint(const LB_DESCR *descr, INT x, INT y)
Definition: listbox.c:558
static INT LISTBOX_lstrcmpiW(LCID lcid, LPCWSTR str1, LPCWSTR str2)
Definition: listbox.c:909
#define LBS_DISPLAYCHANGED
Definition: listbox.c:52
static size_t get_sizeof_item(const LB_DESCR *descr)
Definition: listbox.c:141
static LRESULT LISTBOX_HandleChar(LB_DESCR *descr, WCHAR charW)
Definition: listbox.c:2572
static void LISTBOX_UpdatePage(LB_DESCR *descr)
Definition: listbox.c:435
static LRESULT LISTBOX_SetItemHeight(LB_DESCR *descr, INT index, INT height, BOOL repaint)
Definition: listbox.c:1328
static void LISTBOX_UpdateSize(LB_DESCR *descr)
Definition: listbox.c:455
static WCHAR * get_item_string(const LB_DESCR *descr, UINT index)
Definition: listbox.c:185
static INT LISTBOX_GetCurrentPageSize(const LB_DESCR *descr)
Definition: listbox.c:253
static LRESULT LISTBOX_SetCount(LB_DESCR *descr, UINT count)
Definition: listbox.c:1868
static INT LISTBOX_GetMaxTopIndex(const LB_DESCR *descr)
Definition: listbox.c:271
static LRESULT CALLBACK LISTBOX_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
Definition: listbox.c:2706
static BOOL LISTBOX_Create(HWND hwnd, LPHEADCOMBO lphc)
Definition: listbox.c:2604
static LRESULT LISTBOX_HandleLButtonDown(LB_DESCR *descr, DWORD keys, INT x, INT y)
Definition: listbox.c:2158
#define GetProcessHeap()
Definition: compat.h:736
#define ERROR_INVALID_PARAMETER
Definition: compat.h:101
#define wcsnicmp
Definition: compat.h:14
#define SetLastError(x)
Definition: compat.h:752
#define INVALID_HANDLE_VALUE
Definition: compat.h:731
#define HeapAlloc
Definition: compat.h:733
#define __TRY
Definition: compat.h:80
#define HeapFree(x, y, z)
Definition: compat.h:735
#define __ENDTRY
Definition: compat.h:82
#define CALLBACK
Definition: compat.h:35
#define lstrcpyW
Definition: compat.h:749
#define __EXCEPT_PAGE_FAULT
Definition: compat.h:81
#define lstrlenW
Definition: compat.h:750
UINT WINAPI GetDriveTypeW(IN LPCWSTR lpRootPathName)
Definition: disk.c:497
HANDLE WINAPI FindFirstFileW(IN LPCWSTR lpFileName, OUT LPWIN32_FIND_DATAW lpFindFileData)
Definition: find.c:320
BOOL WINAPI FindClose(HANDLE hFindFile)
Definition: find.c:502
BOOL WINAPI FindNextFileW(IN HANDLE hFindFile, OUT LPWIN32_FIND_DATAW lpFindFileData)
Definition: find.c:382
int WINAPI lstrcmpW(LPCWSTR str1, LPCWSTR str2)
Definition: locale.c:4152
INT WINAPI CompareStringW(LCID lcid, DWORD flags, LPCWSTR str1, INT len1, LPCWSTR str2, INT len2)
Definition: locale.c:3946
BOOL WINAPI IsValidLocale(LCID lcid, DWORD flags)
Definition: locale.c:2925
LCID WINAPI GetUserDefaultLCID(void)
Definition: locale.c:1216
LCID lcid
Definition: locale.c:5656
const UINT * keys
Definition: locale.c:416
LPWSTR WINAPI CharLowerW(WCHAR *str)
Definition: string.c:1092
HRESULT WINAPI DrawThemeBackground(HTHEME hTheme, HDC hdc, int iPartId, int iStateId, const RECT *pRect, const RECT *pClipRect)
Definition: draw.c:128
BOOL WINAPI IsThemeBackgroundPartiallyTransparent(HTHEME hTheme, int iPartId, int iStateId)
Definition: draw.c:1927
HRESULT WINAPI DrawThemeParentBackground(HWND hwnd, HDC hdc, RECT *prc)
Definition: draw.c:72
HTHEME WINAPI GetWindowTheme(HWND hwnd)
Definition: system.c:920
HRESULT WINAPI CloseThemeData(HTHEME hTheme)
Definition: system.c:1036
HTHEME WINAPI OpenThemeData(HWND hwnd, LPCWSTR pszClassList)
Definition: system.c:890
unsigned short(__cdecl typeof(TIFFCurrentDirectory))(struct tiff *)
Definition: typeof.h:94
#define pt(x, y)
Definition: drawing.c:79
return ret
Definition: mutex.c:146
action
Definition: namespace.c:707
#define ULONG_PTR
Definition: config.h:101
size_t const new_size
Definition: expand.cpp:66
#define abs(i)
Definition: fconv.c:206
unsigned short WORD
Definition: ntddk_ex.h:93
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
pKey DeleteObject()
GLuint start
Definition: gl.h:1545
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLuint GLuint GLsizei count
Definition: gl.h:1545
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
GLuint res
Definition: glext.h:9613
GLuint buffer
Definition: glext.h:5915
GLsizeiptr size
Definition: glext.h:5919
GLuint index
Definition: glext.h:6031
GLdouble GLdouble GLdouble GLdouble top
Definition: glext.h:10859
const GLint * first
Definition: glext.h:5794
GLfloat GLfloat p
Definition: glext.h:8902
GLenum GLsizei len
Definition: glext.h:6722
GLuint id
Definition: glext.h:5910
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
Definition: glfuncs.h:248
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble * u
Definition: glfuncs.h:240
uint32_t entry
Definition: isohybrid.c:63
#define debugstr_w
Definition: kernel32.h:32
GLint dy
Definition: linetemp.h:97
if(dx< 0)
Definition: linetemp.h:194
GLint dx
Definition: linetemp.h:97
LPWSTR WINAPI lstrcatW(LPWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:274
LONG_PTR LPARAM
Definition: minwindef.h:175
LONG_PTR LRESULT
Definition: minwindef.h:176
UINT_PTR WPARAM
Definition: minwindef.h:174
int * LPINT
Definition: minwindef.h:151
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define memmove(s1, s2, n)
Definition: mkisofs.h:881
char string[160]
Definition: util.h:11
#define ERROR_FILE_NOT_FOUND
Definition: disk.h:79
HDC hdc
Definition: main.c:9
static HDC
Definition: imagelist.c:88
static void send_notify(HWND pager, UINT unicode, UINT ansi, LPARAM lParam, BOOL code_change)
Definition: pager.c:918
static const WCHAR textW[]
Definition: itemdlg.c:1559
static UINT UINT last
Definition: font.c:45
static DWORD *static HFONT(WINAPI *pCreateFontIndirectExA)(const ENUMLOGFONTEXDVA *)
static DWORD page_size
Definition: loader.c:54
static const WCHAR dotW[]
Definition: directory.c:80
#define WM_LBTRACKPOINT
Definition: msg.c:61
static HTHEME(WINAPI *pOpenThemeDataEx)(HWND
#define min(a, b)
Definition: monoChain.cc:55
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
INT WINAPI MulDiv(INT nNumber, INT nNumerator, INT nDenominator)
Definition: muldiv.c:25
Definition: mk_font.cpp:20
unsigned int UINT
Definition: ndis.h:50
#define FILE_ATTRIBUTE_DIRECTORY
Definition: nt_native.h:705
#define MAXWORD
#define OBJ_BRUSH
Definition: objidl.idl:1015
static TCHAR * items[]
Definition: page1.c:45
#define LOWORD(l)
Definition: pedump.c:82
#define LBS_DISABLENOSCROLL
Definition: pedump.c:690
#define LBS_SORT
Definition: pedump.c:679
#define LBS_OWNERDRAWFIXED
Definition: pedump.c:682
#define LBS_HASSTRINGS
Definition: pedump.c:684
#define LBS_MULTICOLUMN
Definition: pedump.c:687
#define WS_VSCROLL
Definition: pedump.c:627
#define LBS_OWNERDRAWVARIABLE
Definition: pedump.c:683
short SHORT
Definition: pedump.c:59
long LONG
Definition: pedump.c:60
#define LBS_MULTIPLESEL
Definition: pedump.c:681
#define LBS_USETABSTOPS
Definition: pedump.c:685
#define WS_HSCROLL
Definition: pedump.c:628
#define LBS_NOINTEGRALHEIGHT
Definition: pedump.c:686
#define LBS_NOTIFY
Definition: pedump.c:678
#define LBS_EXTENDEDSEL
Definition: pedump.c:689
#define LBS_WANTKEYBOARDINPUT
Definition: pedump.c:688
#define LBS_NOREDRAW
Definition: pedump.c:680
#define INT
Definition: polytest.cpp:20
#define WC_LISTBOXW
Definition: commctrl.h:4716
#define WM_PRINTCLIENT
Definition: richedit.h:70
const WCHAR * str
DWORD LCID
Definition: nls.h:13
XML_HIDDEN void xmlParserErrors const char const xmlChar const xmlChar * str2
Definition: parser.h:35
XML_HIDDEN void xmlParserErrors const char const xmlChar * str1
Definition: parser.h:35
const char * descr
Definition: boot.c:45
#define memset(x, y, z)
Definition: compat.h:39
#define TRACE(s)
Definition: solgame.cpp:4
& rect
Definition: startmenu.cpp:1413
INT fixedOwnerDrawHeight
Definition: comctl32.h:161
UINT wState
Definition: comctl32.h:155
HWND hWndLBox
Definition: comctl32.h:154
INT droppedIndex
Definition: comctl32.h:160
HWND self
Definition: comctl32.h:150
UINT dwStyle
Definition: comctl32.h:152
INT top_item
Definition: listbox.c:78
INT focus_item
Definition: listbox.c:80
LB_ITEMDATA * items
Definition: listbox.c:73
BOOL caret_on
Definition: listbox.c:91
INT horz_extent
Definition: listbox.c:85
BOOL captured
Definition: listbox.c:92
INT page_size
Definition: listbox.c:83
HWND owner
Definition: listbox.c:67
BOOL in_focus
Definition: listbox.c:93
BYTE * nodata_items
Definition: listbox.c:74
INT anchor_item
Definition: listbox.c:81
INT item_height
Definition: listbox.c:82
INT height
Definition: listbox.c:70
INT nb_items
Definition: listbox.c:76
INT column_width
Definition: listbox.c:84
INT * tabs
Definition: listbox.c:88
UINT style
Definition: listbox.c:68
INT selected_item
Definition: listbox.c:79
UINT items_size
Definition: listbox.c:77
HEADCOMBO * lphc
Definition: listbox.c:96
HFONT font
Definition: listbox.c:94
INT nb_tabs
Definition: listbox.c:87
INT wheel_remain
Definition: listbox.c:90
INT horz_pos
Definition: listbox.c:86
LCID locale
Definition: listbox.c:95
INT avg_char_width
Definition: listbox.c:89
HWND self
Definition: listbox.c:66
INT width
Definition: listbox.c:69
ULONG_PTR data
Definition: listbox.c:60
LPWSTR str
Definition: listbox.c:57
UINT height
Definition: listbox.c:59
BOOL selected
Definition: listbox.c:58
LONG cx
Definition: kdterminal.h:27
LONG cy
Definition: kdterminal.h:28
LPCWSTR lpszClassName
Definition: winuser.h:3293
HBRUSH hbrBackground
Definition: winuser.h:3291
int cbClsExtra
Definition: winuser.h:3286
UINT style
Definition: winuser.h:3284
WNDPROC lpfnWndProc
Definition: winuser.h:3285
int cbWndExtra
Definition: winuser.h:3287
HCURSOR hCursor
Definition: winuser.h:3290
Definition: undname.c:54
Definition: copy.c:22
Definition: module.h:576
ULONG_PTR itemData1
Definition: winuser.h:3102
ULONG_PTR itemData2
Definition: winuser.h:3104
LPVOID lpCreateParams
Definition: winuser.h:3063
ULONG_PTR itemData
Definition: winuser.h:3152
ULONG_PTR itemData
Definition: winuser.h:3201
ULONG_PTR itemData
Definition: winuser.h:3754
long y
Definition: polytest.cpp:48
long x
Definition: polytest.cpp:48
LONG right
Definition: windef.h:108
LONG bottom
Definition: windef.h:109
LONG top
Definition: windef.h:107
#define max(a, b)
Definition: svc.c:63
#define WHEEL_DELTA
Definition: treelist.c:99
#define WM_MOUSEWHEEL
Definition: treelist.c:96
int32_t INT
Definition: typedefs.h:58
uint32_t ULONG_PTR
Definition: typedefs.h:65
#define MAKELONG(a, b)
Definition: typedefs.h:249
#define HIWORD(l)
Definition: typedefs.h:247
#define WS_EX_DRAGDETECT
Definition: undocuser.h:23
#define LB_CARETON
Definition: undocuser.h:53
#define LB_CARETOFF
Definition: undocuser.h:54
#define WM_BEGINDRAG
Definition: undocuser.h:58
static const WCHAR empty_stringW[]
Definition: edit.c:173
static const WCHAR combolboxW[]
Definition: listbox.c:141
#define DRIVE_NO_ROOT_DIR
Definition: winbase.h:281
DWORD WINAPI GetLastError(void)
Definition: except.c:1042
_In_ LONG _In_ HWND hwnd
Definition: winddi.h:4023
DWORD COLORREF
Definition: windef.h:100
#define ERROR_INVALID_INDEX
Definition: winerror.h:1239
#define ERROR_LB_WITHOUT_TABSTOPS
Definition: winerror.h:1260
#define ERROR_NO_MORE_FILES
Definition: winerror.h:243
COLORREF WINAPI SetBkColor(_In_ HDC, _In_ COLORREF)
Definition: dc.c:999
HRGN WINAPI CreateRectRgn(_In_ int, _In_ int, _In_ int, _In_ int)
BOOL WINAPI SetWindowOrgEx(_In_ HDC, _In_ int, _In_ int, _Out_opt_ LPPOINT)
Definition: coord.c:532
#define GetTextExtentPoint32
Definition: wingdi.h:4918
int WINAPI ExcludeClipRect(_In_ HDC, _In_ int, _In_ int, _In_ int, _In_ int)
HGDIOBJ WINAPI GetCurrentObject(_In_ HDC, _In_ UINT)
Definition: dc.c:428
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1546
int WINAPI CombineRgn(_In_opt_ HRGN hrgnDest, _In_opt_ HRGN hrgnSrc1, _In_opt_ HRGN hrgnSrc2, _In_ int fnCombineMode)
#define RGN_AND
Definition: wingdi.h:356
#define ETO_CLIPPED
Definition: wingdi.h:648
BOOL WINAPI ExtTextOutW(_In_ HDC hdc, _In_ int x, _In_ int y, _In_ UINT options, _In_opt_ const RECT *lprect, _In_reads_opt_(c) LPCWSTR lpString, _In_ UINT c, _In_reads_opt_(c) const INT *lpDx)
#define ETO_OPAQUE
Definition: wingdi.h:647
int WINAPI FillRect(HDC, LPCRECT, HBRUSH)
COLORREF WINAPI SetTextColor(_In_ HDC, _In_ COLORREF)
Definition: text.c:917
int WINAPI SelectClipRgn(_In_ HDC, _In_opt_ HRGN)
BOOL WINAPI GetTextExtentPointA(_In_ HDC hdc, _In_reads_(c) LPCSTR lpString, _In_ int c, _Out_ LPSIZE lpsz)
#define NORM_IGNORECASE
Definition: winnls.h:187
#define LCID_INSTALLED
Definition: winnls.h:214
#define CSTR_EQUAL
Definition: winnls.h:500
#define CSTR_LESS_THAN
Definition: winnls.h:499
#define CSTR_GREATER_THAN
Definition: winnls.h:501
#define WM_PAINT
Definition: winuser.h:1648
#define ODS_DISABLED
Definition: winuser.h:2583
#define LB_ERR
Definition: winuser.h:2468
HWND WINAPI SetCapture(_In_ HWND hWnd)
#define LB_ADDFILE
Definition: winuser.h:2059
int WINAPI ReleaseDC(_In_opt_ HWND, _In_ HDC)
#define WM_ERASEBKGND
Definition: winuser.h:1653
#define CS_DROPSHADOW
Definition: winuser.h:668
DWORD WINAPI GetSysColor(_In_ int)
#define LBN_ERRSPACE
Definition: winuser.h:2108
#define MAKEWPARAM(l, h)
Definition: winuser.h:4117
BOOL WINAPI IsWindow(_In_opt_ HWND)
#define MK_SHIFT
Definition: winuser.h:2405
#define LB_GETCOUNT
Definition: winuser.h:2067
#define ODS_SELECTED
Definition: winuser.h:2581
#define LB_FINDSTRINGEXACT
Definition: winuser.h:2064
#define SWP_NOACTIVATE
Definition: winuser.h:1253
#define LB_GETITEMDATA
Definition: winuser.h:2070
#define SB_THUMBTRACK
Definition: winuser.h:573
#define GetWindowLongPtrW
Definition: winuser.h:4983
HDC WINAPI GetWindowDC(_In_opt_ HWND)
#define WM_ENABLE
Definition: winuser.h:1643
#define SM_CYEDGE
Definition: winuser.h:1020
#define SB_LINEUP
Definition: winuser.h:564
#define WM_HSCROLL
Definition: winuser.h:1771
#define MAKELPARAM(l, h)
Definition: winuser.h:4116
#define LB_SETHORIZONTALEXTENT
Definition: winuser.h:2100
#define COLOR_GRAYTEXT
Definition: winuser.h:943
#define COLOR_WINDOW
Definition: winuser.h:929
#define DCX_CACHE
Definition: winuser.h:2150
BOOL WINAPI ReleaseCapture(void)
Definition: message.c:2890
#define WM_CHARTOITEM
Definition: winuser.h:1677
#define ODA_DRAWENTIRE
Definition: winuser.h:2578
#define DCX_WINDOW
Definition: winuser.h:2149
LRESULT WINAPI DefWindowProcW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define LBN_SELCANCEL
Definition: winuser.h:2110
#define CBS_DROPDOWNLIST
Definition: winuser.h:284
#define LB_SETCOUNT
Definition: winuser.h:2098
#define LB_OKAY
Definition: winuser.h:2467
#define LB_GETTEXT
Definition: winuser.h:2085
#define LB_SETTOPINDEX
Definition: winuser.h:2106
#define SM_CXEDGE
Definition: winuser.h:1019
#define WM_VSCROLL
Definition: winuser.h:1772
#define SW_SCROLLCHILDREN
Definition: winuser.h:2614
#define LBN_DBLCLK
Definition: winuser.h:2107
BOOL WINAPI GetWindowRect(_In_ HWND, _Out_ LPRECT)
#define SIF_RANGE
Definition: winuser.h:1246
#define WM_CREATE
Definition: winuser.h:1636
#define DLGC_WANTCHARS
Definition: winuser.h:2660
BOOL WINAPI SetWindowPos(_In_ HWND, _In_opt_ HWND, _In_ int, _In_ int, _In_ int, _In_ int, _In_ UINT)
#define SB_PAGERIGHT
Definition: winuser.h:571
#define SM_CXVSCROLL
Definition: winuser.h:972
#define VK_SPACE
Definition: winuser.h:2255
#define LB_DIR
Definition: winuser.h:2062
#define WM_SIZE
Definition: winuser.h:1639
#define COLOR_HIGHLIGHT
Definition: winuser.h:937
HBRUSH WINAPI GetSysColorBrush(_In_ int)
#define SB_VERT
Definition: winuser.h:553
#define SB_LEFT
Definition: winuser.h:575
LONG WINAPI GetWindowLongW(_In_ HWND, _In_ int)
#define WM_DROPFILES
Definition: winuser.h:1853
#define SB_BOTTOM
Definition: winuser.h:577
#define LB_GETSELCOUNT
Definition: winuser.h:2083
#define WM_LBUTTONDBLCLK
Definition: winuser.h:1806
#define SWP_NOMOVE
Definition: winuser.h:1255
#define SW_INVALIDATE
Definition: winuser.h:2615
#define LB_GETITEMRECT
Definition: winuser.h:2072
#define ODA_FOCUS
Definition: winuser.h:2580
ATOM WINAPI RegisterClassW(_In_ CONST WNDCLASSW *)
#define HTVSCROLL
Definition: winuser.h:2518
#define HTHSCROLL
Definition: winuser.h:2517
#define IDC_ARROW
Definition: winuser.h:695
#define LBN_SETFOCUS
Definition: winuser.h:2112
#define LB_GETTOPINDEX
Definition: winuser.h:2087
#define LB_GETANCHORINDEX
Definition: winuser.h:2065
#define LB_ERRSPACE
Definition: winuser.h:2469
#define VK_UP
Definition: winuser.h:2261
#define DDL_DRIVES
Definition: winuser.h:425
#define WM_SETFOCUS
Definition: winuser.h:1641
#define SIF_PAGE
Definition: winuser.h:1244
#define WM_MOUSEMOVE
Definition: winuser.h:1803
#define LB_GETLOCALE
Definition: winuser.h:2081
HDC WINAPI GetDCEx(_In_opt_ HWND, _In_opt_ HRGN, _In_ DWORD)
HWND WINAPI GetCapture(void)
Definition: message.c:2881
#define LB_SETLOCALE
Definition: winuser.h:2103
#define SB_LINERIGHT
Definition: winuser.h:567
#define CS_DBLCLKS
Definition: winuser.h:659
#define WM_LBUTTONDOWN
Definition: winuser.h:1804
#define LB_GETSEL
Definition: winuser.h:2082
#define LB_ADDSTRING
Definition: winuser.h:2060
HCURSOR WINAPI LoadCursorW(_In_opt_ HINSTANCE, _In_ LPCWSTR)
Definition: cursoricon.c:2474
#define LB_SETCOLUMNWIDTH
Definition: winuser.h:2097
#define SIF_TRACKPOS
Definition: winuser.h:1248
#define WM_GETFONT
Definition: winuser.h:1679
#define WM_DELETEITEM
Definition: winuser.h:1675
BOOL WINAPI ClientToScreen(_In_ HWND, _Inout_ LPPOINT)
#define LB_SELITEMRANGEEX
Definition: winuser.h:2094
#define SM_CYHSCROLL
Definition: winuser.h:973
#define WM_DRAWITEM
Definition: winuser.h:1673
#define VK_NEXT
Definition: winuser.h:2257
#define LB_SELITEMRANGE
Definition: winuser.h:2093
#define LB_SETANCHORINDEX
Definition: winuser.h:2095
#define LB_SETITEMHEIGHT
Definition: winuser.h:2102
BOOL WINAPI PtInRect(_In_ LPCRECT, _In_ POINT)
#define DDL_EXCLUSIVE
Definition: winuser.h:426
#define CBS_SIMPLE
Definition: winuser.h:291
UINT_PTR WINAPI SetSystemTimer(HWND, UINT_PTR, UINT, TIMERPROC)
Definition: ntwrapper.h:106
#define LB_SELECTSTRING
Definition: winuser.h:2092
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
#define DCX_INTERSECTRGN
Definition: winuser.h:2158
#define WM_NCACTIVATE
Definition: winuser.h:1716
#define LBS_COMBOBOX
Definition: winuser.h:324
#define LB_RESETCONTENT
Definition: winuser.h:2091
#define LB_DELETESTRING
Definition: winuser.h:2061
#define SB_LINELEFT
Definition: winuser.h:566
BOOL WINAPI KillSystemTimer(HWND, UINT_PTR)
Definition: timer.c:35
HWND WINAPI SetFocus(_In_opt_ HWND)
#define LB_FINDSTRING
Definition: winuser.h:2063
#define MK_CONTROL
Definition: winuser.h:2406
#define DDL_DIRECTORY
Definition: winuser.h:422
#define LB_GETITEMHEIGHT
Definition: winuser.h:2071
#define WM_SETFONT
Definition: winuser.h:1678
#define VK_END
Definition: winuser.h:2258
#define VK_HOME
Definition: winuser.h:2259
BOOL WINAPI EndPaint(_In_ HWND, _In_ const PAINTSTRUCT *)
#define LB_GETHORIZONTALEXTENT
Definition: winuser.h:2069
#define DLGC_WANTARROWS
Definition: winuser.h:2652
#define SIF_DISABLENOSCROLL
Definition: winuser.h:1247
#define LB_INSERTSTRING
Definition: winuser.h:2089
#define LBS_NODATA
Definition: winuser.h:313
#define SB_PAGEDOWN
Definition: winuser.h:569
#define COLOR_HIGHLIGHTTEXT
Definition: winuser.h:938
BOOL WINAPI DragDetect(_In_ HWND, _In_ POINT)
#define LB_ITEMFROMPOINT
Definition: winuser.h:2090
#define SB_LINEDOWN
Definition: winuser.h:565
#define CBS_DROPDOWN
Definition: winuser.h:283
#define WM_MEASUREITEM
Definition: winuser.h:1674
#define VK_F4
Definition: winuser.h:2294
#define WM_LBUTTONUP
Definition: winuser.h:1805
BOOL WINAPI SystemParametersInfoW(_In_ UINT uiAction, _In_ UINT uiParam, _Inout_opt_ PVOID pvParam, _In_ UINT fWinIni)
#define WM_CHAR
Definition: winuser.h:1745
BOOL WINAPI SetRectEmpty(_Out_ LPRECT)
BOOL WINAPI IsWindowEnabled(_In_ HWND)
#define LB_GETTEXTLEN
Definition: winuser.h:2086
HWND WINAPI GetParent(_In_ HWND)
#define LB_SETITEMDATA
Definition: winuser.h:2101
#define CS_GLOBALCLASS
Definition: winuser.h:660
#define VK_LEFT
Definition: winuser.h:2260
#define LBN_SELCHANGE
Definition: winuser.h:2111
#define WM_NCDESTROY
Definition: winuser.h:1712
#define VK_RIGHT
Definition: winuser.h:2262
#define ODA_SELECT
Definition: winuser.h:2579
#define SB_TOP
Definition: winuser.h:578
#define CS_SAVEBITS
Definition: winuser.h:665
#define SIF_POS
Definition: winuser.h:1245
#define VK_DOWN
Definition: winuser.h:2263
#define LB_GETCARETINDEX
Definition: winuser.h:2066
#define GWLP_ID
Definition: winuser.h:871
#define SW_ERASE
Definition: winuser.h:2616
#define WM_USER
Definition: winuser.h:1923
#define LBN_KILLFOCUS
Definition: winuser.h:2109
BOOL WINAPI OffsetRect(_Inout_ LPRECT, _In_ int, _In_ int)
#define WM_CTLCOLORLISTBOX
Definition: winuser.h:1796
#define LB_SETTABSTOPS
Definition: winuser.h:2105
#define VK_SHIFT
Definition: winuser.h:2238
#define LB_SETSEL
Definition: winuser.h:2104
#define VK_PRIOR
Definition: winuser.h:2256
int WINAPI SetScrollInfo(_In_ HWND, _In_ int, _In_ LPCSCROLLINFO, _In_ BOOL)
#define WM_DESTROY
Definition: winuser.h:1637
BOOL WINAPI UnregisterClassW(_In_ LPCWSTR, HINSTANCE)
#define LBS_NOSEL
Definition: winuser.h:316
#define WS_EX_CLIENTEDGE
Definition: winuser.h:384
#define LB_SETCURSEL
Definition: winuser.h:2099
BOOL WINAPI ShowScrollBar(_In_ HWND, _In_ int, _In_ BOOL)
#define WM_KEYDOWN
Definition: winuser.h:1743
BOOL WINAPI DrawFocusRect(_In_ HDC, _In_ LPCRECT)
#define SB_RIGHT
Definition: winuser.h:576
#define WM_COMPAREITEM
Definition: winuser.h:1683
BOOL WINAPI InvalidateRect(_In_opt_ HWND, _In_opt_ LPCRECT, _In_ BOOL)
#define SWP_NOZORDER
Definition: winuser.h:1258
HDC WINAPI BeginPaint(_In_ HWND, _Out_ LPPAINTSTRUCT)
#define LB_GETCURSEL
Definition: winuser.h:2068
#define SetWindowLongPtrW
Definition: winuser.h:5512
#define GWL_STYLE
Definition: winuser.h:863
#define LB_GETSELITEMS
Definition: winuser.h:2084
BOOL WINAPI GetScrollInfo(_In_ HWND, _In_ int, _Inout_ LPSCROLLINFO)
#define CS_PARENTDC
Definition: winuser.h:664
#define LB_INITSTORAGE
Definition: winuser.h:2088
BOOL WINAPI IsWindowVisible(_In_ HWND)
int WINAPI ScrollWindowEx(_In_ HWND, _In_ int, _In_ int, _In_opt_ LPCRECT, _In_opt_ LPCRECT, _In_opt_ HRGN, _Out_opt_ LPRECT, _In_ UINT)
#define ODT_LISTBOX
Definition: winuser.h:2574
#define WM_KILLFOCUS
Definition: winuser.h:1642
#define ODS_FOCUS
Definition: winuser.h:2585
int WINAPI GetSystemMetrics(_In_ int)
#define SB_PAGEUP
Definition: winuser.h:568
#define WM_NCLBUTTONDOWN
Definition: winuser.h:1720
#define LB_SETCARETINDEX
Definition: winuser.h:2096
#define WM_GETDLGCODE
Definition: winuser.h:1717
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define SB_HORZ
Definition: winuser.h:552
SHORT WINAPI GetKeyState(_In_ int)
#define WM_NCPAINT
Definition: winuser.h:1715
BOOL WINAPI SetRect(_Out_ LPRECT, _In_ int, _In_ int, _In_ int, _In_ int)
#define WM_VKEYTOITEM
Definition: winuser.h:1676
#define SB_PAGELEFT
Definition: winuser.h:570
#define GWL_EXSTYLE
Definition: winuser.h:862
#define WM_SETREDRAW
Definition: winuser.h:1644
#define SB_THUMBPOSITION
Definition: winuser.h:572
LONG WINAPI TabbedTextOutW(_In_ HDC hdc, _In_ int x, _In_ int y, _In_reads_(chCount) LPCWSTR lpString, _In_ int chCount, _In_ int nTabPositions, _In_reads_opt_(nTabPositions) CONST INT *lpnTabStopPositions, _In_ int nTabOrigin)
const WCHAR * LPCWSTR
Definition: xmlstorage.h:185
__wchar_t WCHAR
Definition: xmlstorage.h:180
WCHAR * LPWSTR
Definition: xmlstorage.h:184
unsigned char BYTE
Definition: xxhash.c:193