ReactOS 0.4.16-dev-1946-g52006dd
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
680 TRACE("[%p]: painting %d (%s) action=%02x rect=%s\n",
681 descr->self, index, debugstr_w(item_str), action,
683 if (!item_str)
684 ExtTextOutW( hdc, rect->left + 1, rect->top,
686 else if (!(descr->style & LBS_USETABSTOPS))
687 ExtTextOutW( hdc, rect->left + 1, rect->top,
688 ETO_OPAQUE | ETO_CLIPPED, rect, item_str,
689 lstrlenW(item_str), NULL );
690 else
691 {
692 /* Output empty string to paint background in the full width. */
693 ExtTextOutW( hdc, rect->left + 1, rect->top,
695 TabbedTextOutW( hdc, rect->left + 1 , rect->top,
696 item_str, lstrlenW(item_str),
697 descr->nb_tabs, descr->tabs, 0);
698 }
699 if (selected)
700 {
701 SetBkColor( hdc, oldBk );
702 SetTextColor( hdc, oldText );
703 }
704 if (focused)
706 }
707}
708
709
710/***********************************************************************
711 * LISTBOX_SetRedraw
712 *
713 * Change the redraw flag.
714 */
716{
717 if (on)
718 {
719 if (!(descr->style & LBS_NOREDRAW)) return;
720 descr->style &= ~LBS_NOREDRAW;
721 if (descr->style & LBS_DISPLAYCHANGED)
722 { /* page was changed while setredraw false, refresh automatically */
723 InvalidateRect(descr->self, NULL, TRUE);
724 if ((descr->top_item + descr->page_size) > descr->nb_items)
725 { /* reset top of page if less than number of items/page */
726 descr->top_item = descr->nb_items - descr->page_size;
727 if (descr->top_item < 0) descr->top_item = 0;
728 }
729 descr->style &= ~LBS_DISPLAYCHANGED;
730 }
732 }
733 else descr->style |= LBS_NOREDRAW;
734}
735
736
737/***********************************************************************
738 * LISTBOX_RepaintItem
739 *
740 * Repaint a single item synchronously.
741 */
743{
744 HDC hdc;
745 RECT rect;
746 HFONT oldFont = 0;
747 HBRUSH hbrush, oldBrush = 0;
748
749 /* Do not repaint the item if the item is not visible */
750 if (!IsWindowVisible(descr->self)) return;
751 if (descr->style & LBS_NOREDRAW)
752 {
753 descr->style |= LBS_DISPLAYCHANGED;
754 return;
755 }
756 if (LISTBOX_GetItemRect( descr, index, &rect ) != 1) return;
757 if (!(hdc = GetDCEx( descr->self, 0, DCX_CACHE ))) return;
758 if (descr->font) oldFont = SelectObject( hdc, descr->font );
759 hbrush = (HBRUSH)SendMessageW( descr->owner, WM_CTLCOLORLISTBOX,
760 (WPARAM)hdc, (LPARAM)descr->self );
761 if (hbrush) oldBrush = SelectObject( hdc, hbrush );
762 if (!IsWindowEnabled(descr->self))
764 SetWindowOrgEx( hdc, descr->horz_pos, 0, NULL );
766 if (oldFont) SelectObject( hdc, oldFont );
767 if (oldBrush) SelectObject( hdc, oldBrush );
768 ReleaseDC( descr->self, hdc );
769}
770
771
772/***********************************************************************
773 * LISTBOX_DrawFocusRect
774 */
776{
777 HDC hdc;
778 RECT rect;
779 HFONT oldFont = 0;
780
781 /* Do not repaint the item if the item is not visible */
782 if (!IsWindowVisible(descr->self)) return;
783
784 if (descr->focus_item == -1) return;
785 if (!descr->caret_on || !descr->in_focus) return;
786
787 if (LISTBOX_GetItemRect( descr, descr->focus_item, &rect ) != 1) return;
788 if (!(hdc = GetDCEx( descr->self, 0, DCX_CACHE ))) return;
789 if (descr->font) oldFont = SelectObject( hdc, descr->font );
790 if (!IsWindowEnabled(descr->self))
792 SetWindowOrgEx( hdc, descr->horz_pos, 0, NULL );
793 LISTBOX_PaintItem( descr, hdc, &rect, descr->focus_item, ODA_FOCUS, !on );
794 if (oldFont) SelectObject( hdc, oldFont );
795 ReleaseDC( descr->self, hdc );
796}
797
798
799/***********************************************************************
800 * LISTBOX_InitStorage
801 */
803{
804 UINT new_size = descr->nb_items + nb_items;
805
806 if (new_size > descr->items_size && !resize_storage(descr, new_size))
807 return LB_ERRSPACE;
808 return descr->items_size;
809}
810
811
812/***********************************************************************
813 * LISTBOX_SetTabStops
814 */
816{
817 INT i;
818
819 if (!(descr->style & LBS_USETABSTOPS))
820 {
822 return FALSE;
823 }
824
825 HeapFree( GetProcessHeap(), 0, descr->tabs );
826 if (!(descr->nb_tabs = count))
827 {
828 descr->tabs = NULL;
829 return TRUE;
830 }
831 if (!(descr->tabs = HeapAlloc( GetProcessHeap(), 0,
832 descr->nb_tabs * sizeof(INT) )))
833 return FALSE;
834 memcpy( descr->tabs, tabs, descr->nb_tabs * sizeof(INT) );
835
836 /* convert into "dialog units"*/
837 for (i = 0; i < descr->nb_tabs; i++)
838 descr->tabs[i] = MulDiv(descr->tabs[i], descr->avg_char_width, 4);
839
840 return TRUE;
841}
842
843
844/***********************************************************************
845 * LISTBOX_GetText
846 */
848{
849 DWORD len;
850
851 if ((index < 0) || (index >= descr->nb_items))
852 {
854 return LB_ERR;
855 }
856
857 if (HAS_STRINGS(descr))
858 {
860
861 if (!buffer)
862 return lstrlenW(str);
863
864 TRACE("index %d (0x%04x) %s\n", index, index, debugstr_w(str));
865
866 __TRY /* hide a Delphi bug that passes a read-only buffer */
867 {
870 }
872 {
873 WARN( "got an invalid buffer (Delphi bug?)\n" );
875 return LB_ERR;
876 }
878 } else
879 {
880 if (buffer)
882 len = sizeof(ULONG_PTR);
883 }
884 return len;
885}
886
887static inline INT LISTBOX_lstrcmpiW( LCID lcid, LPCWSTR str1, LPCWSTR str2 )
888{
889 INT ret = CompareStringW( lcid, NORM_IGNORECASE, str1, -1, str2, -1 );
890 if (ret == CSTR_LESS_THAN)
891 return -1;
892 if (ret == CSTR_EQUAL)
893 return 0;
894 if (ret == CSTR_GREATER_THAN)
895 return 1;
896 return -1;
897}
898
899/***********************************************************************
900 * LISTBOX_FindStringPos
901 *
902 * Find the nearest string located before a given string in sort order.
903 * If 'exact' is TRUE, return an error if we don't get an exact match.
904 */
906{
907 INT index, min, max, res;
908
909 if (!descr->nb_items || !(descr->style & LBS_SORT)) return -1; /* Add it at the end */
910
911 min = 0;
912 max = descr->nb_items - 1;
913 while (min <= max)
914 {
915 index = (min + max) / 2;
916 if (HAS_STRINGS(descr))
918 else
919 {
921 UINT id = (UINT)GetWindowLongPtrW( descr->self, GWLP_ID );
922
923 cis.CtlType = ODT_LISTBOX;
924 cis.CtlID = id;
925 cis.hwndItem = descr->self;
926 /* note that some application (MetaStock) expects the second item
927 * to be in the listbox */
928 cis.itemID1 = index;
930 cis.itemID2 = -1;
931 cis.itemData2 = (ULONG_PTR)str;
932 cis.dwLocaleId = descr->locale;
933 res = SendMessageW( descr->owner, WM_COMPAREITEM, id, (LPARAM)&cis );
934 }
935 if (!res) return index;
936 if (res > 0) max = index - 1;
937 else min = index + 1;
938 }
939 return exact ? -1 : min;
940}
941
942
943/***********************************************************************
944 * LISTBOX_FindFileStrPos
945 *
946 * Find the nearest string located before a given string in directory
947 * sort order (i.e. first files, then directories, then drives).
948 */
950{
951 INT min, max, res;
952
953 if (!HAS_STRINGS(descr))
955 min = 0;
956 max = descr->nb_items;
957 while (min != max)
958 {
959 INT index = (min + max) / 2;
961 if (*p == '[') /* drive or directory */
962 {
963 if (*str != '[') res = -1;
964 else if (p[1] == '-') /* drive */
965 {
966 if (str[1] == '-') res = str[2] - p[2];
967 else res = -1;
968 }
969 else /* directory */
970 {
971 if (str[1] == '-') res = 1;
972 else res = LISTBOX_lstrcmpiW( descr->locale, str, p );
973 }
974 }
975 else /* filename */
976 {
977 if (*str == '[') res = 1;
978 else res = LISTBOX_lstrcmpiW( descr->locale, str, p );
979 }
980 if (!res) return index;
981 if (res < 0) max = index;
982 else min = index + 1;
983 }
984 return max;
985}
986
987
988/***********************************************************************
989 * LISTBOX_FindString
990 *
991 * Find the item beginning with a given string.
992 */
994{
995 INT i, index;
996
997 if (descr->style & LBS_NODATA) return LB_ERR;
998
999 start++;
1000 if (start >= descr->nb_items) start = 0;
1001 if (HAS_STRINGS(descr))
1002 {
1003 if (!str || ! str[0] ) return LB_ERR;
1004 if (exact)
1005 {
1006 for (i = 0, index = start; i < descr->nb_items; i++, index++)
1007 {
1008 if (index == descr->nb_items) index = 0;
1010 return index;
1011 }
1012 }
1013 else
1014 {
1015 /* Special case for drives and directories: ignore prefix */
1016 INT len = lstrlenW(str);
1017 WCHAR *item_str;
1018
1019 for (i = 0, index = start; i < descr->nb_items; i++, index++)
1020 {
1021 if (index == descr->nb_items) index = 0;
1022 item_str = get_item_string(descr, index);
1023
1024 if (!wcsnicmp(str, item_str, len)) return index;
1025 if (item_str[0] == '[')
1026 {
1027 if (!wcsnicmp(str, item_str + 1, len)) return index;
1028 if (item_str[1] == '-' && !wcsnicmp(str, item_str + 2, len)) return index;
1029 }
1030 }
1031 }
1032 }
1033 else
1034 {
1035 if (exact && (descr->style & LBS_SORT))
1036 /* If sorted, use a WM_COMPAREITEM binary search */
1037 return LISTBOX_FindStringPos( descr, str, TRUE );
1038
1039 /* Otherwise use a linear search */
1040 for (i = 0, index = start; i < descr->nb_items; i++, index++)
1041 {
1042 if (index == descr->nb_items) index = 0;
1043 if (get_item_data(descr, index) == (ULONG_PTR)str) return index;
1044 }
1045 }
1046 return LB_ERR;
1047}
1048
1049
1050/***********************************************************************
1051 * LISTBOX_GetSelCount
1052 */
1054{
1055 INT i, count;
1056
1057 if (!(descr->style & LBS_MULTIPLESEL) ||
1058 (descr->style & LBS_NOSEL))
1059 return LB_ERR;
1060 for (i = count = 0; i < descr->nb_items; i++)
1061 if (is_item_selected(descr, i)) count++;
1062 return count;
1063}
1064
1065
1066/***********************************************************************
1067 * LISTBOX_GetSelItems
1068 */
1070{
1071 INT i, count;
1072
1073 if (!(descr->style & LBS_MULTIPLESEL)) return LB_ERR;
1074 for (i = count = 0; (i < descr->nb_items) && (count < max); i++)
1075 if (is_item_selected(descr, i)) array[count++] = i;
1076 return count;
1077}
1078
1079
1080/***********************************************************************
1081 * LISTBOX_Paint
1082 */
1084{
1085 INT i, col_pos = descr->page_size - 1;
1086 RECT rect;
1087 RECT focusRect = {-1, -1, -1, -1};
1088 HFONT oldFont = 0;
1089 HBRUSH hbrush, oldBrush = 0;
1090
1091 if (descr->style & LBS_NOREDRAW) return 0;
1092
1093 SetRect( &rect, 0, 0, descr->width, descr->height );
1094 if (descr->style & LBS_MULTICOLUMN)
1095 rect.right = rect.left + descr->column_width;
1096 else if (descr->horz_pos)
1097 {
1098 SetWindowOrgEx( hdc, descr->horz_pos, 0, NULL );
1099 rect.right += descr->horz_pos;
1100 }
1101
1102 if (descr->font) oldFont = SelectObject( hdc, descr->font );
1103 hbrush = (HBRUSH)SendMessageW( descr->owner, WM_CTLCOLORLISTBOX,
1104 (WPARAM)hdc, (LPARAM)descr->self );
1105 if (hbrush) oldBrush = SelectObject( hdc, hbrush );
1107
1108 if (!descr->nb_items && (descr->focus_item != -1) && descr->caret_on &&
1109 (descr->in_focus))
1110 {
1111 /* Special case for empty listbox: paint focus rect */
1112 rect.bottom = rect.top + descr->item_height;
1114 &rect, NULL, 0, NULL );
1115 LISTBOX_PaintItem( descr, hdc, &rect, descr->focus_item, ODA_FOCUS, FALSE );
1116 rect.top = rect.bottom;
1117 }
1118
1119 /* Paint all the item, regarding the selection
1120 Focus state will be painted after */
1121
1122 for (i = descr->top_item; i < descr->nb_items; i++)
1123 {
1124 if (!(descr->style & LBS_OWNERDRAWVARIABLE))
1125 rect.bottom = rect.top + descr->item_height;
1126 else
1127 rect.bottom = rect.top + get_item_height(descr, i);
1128
1129 /* keep the focus rect, to paint the focus item after */
1130 if (i == descr->focus_item)
1131 focusRect = rect;
1132#ifdef __REACTOS__
1133 rect.bottom = min(rect.bottom, descr->height);
1134#endif
1136 rect.top = rect.bottom;
1137
1138 if ((descr->style & LBS_MULTICOLUMN) && !col_pos)
1139 {
1140 if (!IS_OWNERDRAW(descr))
1141 {
1142 /* Clear the bottom of the column */
1143 if (rect.top < descr->height)
1144 {
1145 rect.bottom = descr->height;
1147 &rect, NULL, 0, NULL );
1148 }
1149 }
1150
1151 /* Go to the next column */
1152 rect.left += descr->column_width;
1153 rect.right += descr->column_width;
1154 rect.top = 0;
1155 col_pos = descr->page_size - 1;
1156 if (rect.left >= descr->width) break;
1157 }
1158 else
1159 {
1160 col_pos--;
1161 if (rect.top >= descr->height) break;
1162 }
1163 }
1164
1165 /* Paint the focus item now */
1166 if (focusRect.top != focusRect.bottom &&
1167 descr->caret_on && descr->in_focus)
1168 LISTBOX_PaintItem( descr, hdc, &focusRect, descr->focus_item, ODA_FOCUS, FALSE );
1169
1170 if (!IS_OWNERDRAW(descr))
1171 {
1172 /* Clear the remainder of the client area */
1173 if (rect.top < descr->height)
1174 {
1175 rect.bottom = descr->height;
1177 &rect, NULL, 0, NULL );
1178 }
1179 if (rect.right < descr->width)
1180 {
1181 rect.left = rect.right;
1182 rect.right = descr->width;
1183 rect.top = 0;
1184 rect.bottom = descr->height;
1186 &rect, NULL, 0, NULL );
1187 }
1188 }
1189 if (oldFont) SelectObject( hdc, oldFont );
1190 if (oldBrush) SelectObject( hdc, oldBrush );
1191 return 0;
1192}
1193
1194static void LISTBOX_NCPaint( LB_DESCR *descr, HRGN region )
1195{
1196 DWORD exstyle = GetWindowLongW( descr->self, GWL_EXSTYLE);
1197 HTHEME theme = GetWindowTheme( descr->self );
1198 HRGN cliprgn = region;
1199 int cxEdge, cyEdge;
1200 HDC hdc;
1201 RECT r;
1202
1203 if (!theme || !(exstyle & WS_EX_CLIENTEDGE))
1204 return;
1205
1206 cxEdge = GetSystemMetrics(SM_CXEDGE);
1207 cyEdge = GetSystemMetrics(SM_CYEDGE);
1208
1209 GetWindowRect(descr->self, &r);
1210
1211 /* New clipping region passed to default proc to exclude border */
1212 cliprgn = CreateRectRgn(r.left + cxEdge, r.top + cyEdge,
1213 r.right - cxEdge, r.bottom - cyEdge);
1214 if (region != (HRGN)1)
1215 CombineRgn(cliprgn, cliprgn, region, RGN_AND);
1216 OffsetRect(&r, -r.left, -r.top);
1217
1218#ifdef __REACTOS__ /* r73789 */
1219 hdc = GetWindowDC(descr->self);
1220 /* Exclude client part */
1222 r.left + cxEdge,
1223 r.top + cyEdge,
1224 r.right - cxEdge,
1225 r.bottom -cyEdge);
1226#else
1227 hdc = GetDCEx(descr->self, region, DCX_WINDOW|DCX_INTERSECTRGN);
1228 OffsetRect(&r, -r.left, -r.top);
1229#endif
1230
1231 if (IsThemeBackgroundPartiallyTransparent (theme, 0, 0))
1233 DrawThemeBackground (theme, hdc, 0, 0, &r, 0);
1234 ReleaseDC(descr->self, hdc);
1235}
1236
1237/***********************************************************************
1238 * LISTBOX_InvalidateItems
1239 *
1240 * Invalidate all items from a given item. If the specified item is not
1241 * visible, nothing happens.
1242 */
1244{
1245 RECT rect;
1246
1247 if (LISTBOX_GetItemRect( descr, index, &rect ) == 1)
1248 {
1249 if (descr->style & LBS_NOREDRAW)
1250 {
1251 descr->style |= LBS_DISPLAYCHANGED;
1252 return;
1253 }
1254 rect.bottom = descr->height;
1255 InvalidateRect( descr->self, &rect, TRUE );
1256 if (descr->style & LBS_MULTICOLUMN)
1257 {
1258 /* Repaint the other columns */
1259 rect.left = rect.right;
1260 rect.right = descr->width;
1261 rect.top = 0;
1262 InvalidateRect( descr->self, &rect, TRUE );
1263 }
1264 }
1265}
1266
1268{
1269 RECT rect;
1270
1271 if (LISTBOX_GetItemRect( descr, index, &rect ) == 1)
1272 InvalidateRect( descr->self, &rect, TRUE );
1273}
1274
1275/***********************************************************************
1276 * LISTBOX_GetItemHeight
1277 */
1279{
1280 if (descr->style & LBS_OWNERDRAWVARIABLE && descr->nb_items > 0)
1281 {
1282 if ((index < 0) || (index >= descr->nb_items))
1283 {
1285 return LB_ERR;
1286 }
1287 return get_item_height(descr, index);
1288 }
1289 else return descr->item_height;
1290}
1291
1292
1293/***********************************************************************
1294 * LISTBOX_SetItemHeight
1295 */
1297{
1298 if (height > MAXWORD)
1299 return -1;
1300
1301 if (!height) height = 1;
1302
1303 if (descr->style & LBS_OWNERDRAWVARIABLE)
1304 {
1305 if ((index < 0) || (index >= descr->nb_items))
1306 {
1308 return LB_ERR;
1309 }
1310 TRACE("[%p]: item %d height = %d\n", descr->self, index, height );
1313 if (repaint)
1315 }
1316 else if (height != descr->item_height)
1317 {
1318 TRACE("[%p]: new height = %d\n", descr->self, height );
1319 descr->item_height = height;
1322 if (repaint)
1323 InvalidateRect( descr->self, 0, TRUE );
1324 }
1325 return LB_OKAY;
1326}
1327
1328
1329/***********************************************************************
1330 * LISTBOX_SetHorizontalPos
1331 */
1333{
1334 INT diff;
1335
1336 if (pos > descr->horz_extent - descr->width)
1337 pos = descr->horz_extent - descr->width;
1338 if (pos < 0) pos = 0;
1339 if (!(diff = descr->horz_pos - pos)) return;
1340 TRACE("[%p]: new horz pos = %d\n", descr->self, pos );
1341 descr->horz_pos = pos;
1343 if (abs(diff) < descr->width)
1344 {
1345 RECT rect;
1346 /* Invalidate the focused item so it will be repainted correctly */
1347 if (LISTBOX_GetItemRect( descr, descr->focus_item, &rect ) == 1)
1348 InvalidateRect( descr->self, &rect, TRUE );
1349 ScrollWindowEx( descr->self, diff, 0, NULL, NULL, 0, NULL,
1351 }
1352 else
1353 InvalidateRect( descr->self, NULL, TRUE );
1354}
1355
1356
1357/***********************************************************************
1358 * LISTBOX_SetHorizontalExtent
1359 */
1361{
1362 if (descr->style & LBS_MULTICOLUMN)
1363 return LB_OKAY;
1364 if (extent == descr->horz_extent) return LB_OKAY;
1365 TRACE("[%p]: new horz extent = %d\n", descr->self, extent );
1366 descr->horz_extent = extent;
1367 if (descr->style & WS_HSCROLL) {
1369 info.cbSize = sizeof(info);
1370 info.nMin = 0;
1371 info.nMax = descr->horz_extent ? descr->horz_extent - 1 : 0;
1372 info.fMask = SIF_RANGE;
1373 if (descr->style & LBS_DISABLENOSCROLL)
1374 info.fMask |= SIF_DISABLENOSCROLL;
1375 SetScrollInfo( descr->self, SB_HORZ, &info, TRUE );
1376 }
1377 if (descr->horz_pos > extent - descr->width)
1379 return LB_OKAY;
1380}
1381
1382
1383/***********************************************************************
1384 * LISTBOX_SetColumnWidth
1385 */
1387{
1388 RECT rect;
1389
1390 TRACE("[%p]: new column width = %d\n", descr->self, column_width);
1391
1392 GetClientRect(descr->self, &rect);
1393 descr->width = rect.right - rect.left;
1394 descr->height = rect.bottom - rect.top;
1395 descr->column_width = column_width;
1396
1399 return LB_OKAY;
1400}
1401
1402
1403/***********************************************************************
1404 * LISTBOX_SetFont
1405 *
1406 * Returns the item height.
1407 */
1409{
1410 HDC hdc;
1411 HFONT oldFont = 0;
1412 const char *alphabet = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
1413 SIZE sz;
1414
1415 descr->font = font;
1416
1417 if (!(hdc = GetDCEx( descr->self, 0, DCX_CACHE )))
1418 {
1419 ERR("unable to get DC.\n" );
1420 return 16;
1421 }
1422 if (font) oldFont = SelectObject( hdc, font );
1423 GetTextExtentPointA( hdc, alphabet, 52, &sz);
1424 if (oldFont) SelectObject( hdc, oldFont );
1425 ReleaseDC( descr->self, hdc );
1426
1427 descr->avg_char_width = (sz.cx / 26 + 1) / 2;
1428 if (!IS_OWNERDRAW(descr))
1430 return sz.cy;
1431}
1432
1433
1434/***********************************************************************
1435 * LISTBOX_MakeItemVisible
1436 *
1437 * Make sure that a given item is partially or fully visible.
1438 */
1440{
1441 INT top;
1442
1443 TRACE("current top item %d, index %d, fully %d\n", descr->top_item, index, fully);
1444
1445 if (index <= descr->top_item) top = index;
1446 else if (descr->style & LBS_MULTICOLUMN)
1447 {
1448 INT cols = descr->width;
1449 if (!fully) cols += descr->column_width - 1;
1450 if (cols >= descr->column_width) cols /= descr->column_width;
1451 else cols = 1;
1452 if (index < descr->top_item + (descr->page_size * cols)) return;
1453 top = index - descr->page_size * (cols - 1);
1454 }
1455 else if (descr->style & LBS_OWNERDRAWVARIABLE)
1456 {
1457 INT height = fully ? get_item_height(descr, index) : 1;
1458 for (top = index; top > descr->top_item; top--)
1459 if ((height += get_item_height(descr, top - 1)) > descr->height) break;
1460 }
1461 else
1462 {
1463 if (index < descr->top_item + descr->page_size) return;
1464 if (!fully && (index == descr->top_item + descr->page_size) &&
1465 (descr->height > (descr->page_size * descr->item_height))) return;
1466 top = index - descr->page_size + 1;
1467 }
1469}
1470
1471/***********************************************************************
1472 * LISTBOX_SetCaretIndex
1473 *
1474 * NOTES
1475 * index must be between 0 and descr->nb_items-1, or LB_ERR is returned.
1476 *
1477 */
1479{
1480 BOOL focus_changed = descr->focus_item != index;
1481
1482 TRACE("old focus %d, index %d\n", descr->focus_item, index);
1483
1484 if (descr->style & LBS_NOSEL) return LB_ERR;
1485 if ((index < 0) || (index >= descr->nb_items)) return LB_ERR;
1486
1487 if (focus_changed)
1488 {
1490 descr->focus_item = index;
1491 }
1492
1493 LISTBOX_MakeItemVisible( descr, index, fully_visible );
1494
1495 if (focus_changed)
1497
1498 return LB_OKAY;
1499}
1500
1501
1502/***********************************************************************
1503 * LISTBOX_SelectItemRange
1504 *
1505 * Select a range of items. Should only be used on a MULTIPLESEL listbox.
1506 */
1508 INT last, BOOL on )
1509{
1510 INT i;
1511
1512 /* A few sanity checks */
1513
1514 if (descr->style & LBS_NOSEL) return LB_ERR;
1515 if (!(descr->style & LBS_MULTIPLESEL)) return LB_ERR;
1516
1517 if (!descr->nb_items) return LB_OKAY;
1518
1519 if (last == -1 || last >= descr->nb_items) last = descr->nb_items - 1;
1520 if (first < 0) first = 0;
1521 if (last < first) return LB_OKAY;
1522
1523 if (on) /* Turn selection on */
1524 {
1525 for (i = first; i <= last; i++)
1526 {
1527 if (is_item_selected(descr, i)) continue;
1530 }
1531 }
1532 else /* Turn selection off */
1533 {
1534 for (i = first; i <= last; i++)
1535 {
1536 if (!is_item_selected(descr, i)) continue;
1539 }
1540 }
1541 return LB_OKAY;
1542}
1543
1544/***********************************************************************
1545 * LISTBOX_SetSelection
1546 */
1548 BOOL on, BOOL send_notify )
1549{
1550 TRACE( "cur_sel=%d index=%d notify=%s\n",
1551 descr->selected_item, index, send_notify ? "YES" : "NO" );
1552
1553 if (descr->style & LBS_NOSEL)
1554 {
1555 descr->selected_item = index;
1556 return LB_ERR;
1557 }
1558 if ((index < -1) || (index >= descr->nb_items)) return LB_ERR;
1559 if (descr->style & LBS_MULTIPLESEL)
1560 {
1561 if (index == -1) /* Select all items */
1562 return LISTBOX_SelectItemRange( descr, 0, descr->nb_items, on );
1563 else /* Only one item */
1564 return LISTBOX_SelectItemRange( descr, index, index, on );
1565 }
1566 else
1567 {
1568 INT oldsel = descr->selected_item;
1569 if (index == oldsel) return LB_OKAY;
1570 if (oldsel != -1) set_item_selected_state(descr, oldsel, FALSE);
1572 descr->selected_item = index;
1573 if (oldsel != -1) LISTBOX_RepaintItem( descr, oldsel, ODA_SELECT );
1575 if (send_notify && descr->nb_items) SEND_NOTIFICATION( descr,
1576 (index != -1) ? LBN_SELCHANGE : LBN_SELCANCEL );
1577 else
1578 if( descr->lphc ) /* set selection change flag for parent combo */
1579 descr->lphc->wState |= CBF_SELCHANGE;
1580 }
1581 return LB_OKAY;
1582}
1583
1584
1585/***********************************************************************
1586 * LISTBOX_MoveCaret
1587 *
1588 * Change the caret position and extend the selection to the new caret.
1589 */
1590static void LISTBOX_MoveCaret( LB_DESCR *descr, INT index, BOOL fully_visible )
1591{
1592 TRACE("old focus %d, index %d\n", descr->focus_item, index);
1593
1594 if ((index < 0) || (index >= descr->nb_items))
1595 return;
1596
1597 /* Important, repaint needs to be done in this order if
1598 you want to mimic Windows behavior:
1599 1. Remove the focus and paint the item
1600 2. Remove the selection and paint the item(s)
1601 3. Set the selection and repaint the item(s)
1602 4. Set the focus to 'index' and repaint the item */
1603
1604 /* 1. remove the focus and repaint the item */
1606
1607 /* 2. then turn off the previous selection */
1608 /* 3. repaint the new selected item */
1609 if (descr->style & LBS_EXTENDEDSEL)
1610 {
1611 if (descr->anchor_item != -1)
1612 {
1613 INT first = min( index, descr->anchor_item );
1614 INT last = max( index, descr->anchor_item );
1615 if (first > 0)
1619 }
1620 }
1621 else if (!(descr->style & LBS_MULTIPLESEL))
1622 {
1623 /* Set selection to new caret item */
1625 }
1626
1627 /* 4. repaint the new item with the focus */
1628 descr->focus_item = index;
1629 LISTBOX_MakeItemVisible( descr, index, fully_visible );
1631}
1632
1633
1634/***********************************************************************
1635 * LISTBOX_InsertItem
1636 */
1639{
1640 INT oldfocus = descr->focus_item;
1641
1642 if (index == -1) index = descr->nb_items;
1643 else if ((index < 0) || (index > descr->nb_items)) return LB_ERR;
1644 if (!resize_storage(descr, descr->nb_items + 1)) return LB_ERR;
1645
1647 descr->nb_items++;
1652
1653 /* Get item height */
1654
1655 if (descr->style & LBS_OWNERDRAWVARIABLE)
1656 {
1658 UINT id = (UINT)GetWindowLongPtrW( descr->self, GWLP_ID );
1659
1660 mis.CtlType = ODT_LISTBOX;
1661 mis.CtlID = id;
1662 mis.itemID = index;
1663 mis.itemData = data;
1664 mis.itemHeight = descr->item_height;
1665 SendMessageW( descr->owner, WM_MEASUREITEM, id, (LPARAM)&mis );
1667 TRACE("[%p]: measure item %d (%s) = %d\n",
1668 descr->self, index, str ? debugstr_w(str) : "", get_item_height(descr, index));
1669 }
1670
1671 /* Repaint the items */
1672
1675
1676 /* Move selection and focused item */
1677 /* If listbox was empty, set focus to the first item */
1678 if (descr->nb_items == 1)
1680 /* single select don't change selection index in win31 */
1681 else if ((ISWIN31) && !(IS_MULTISELECT(descr)))
1682 {
1683 descr->selected_item++;
1684 LISTBOX_SetSelection( descr, descr->selected_item-1, TRUE, FALSE );
1685 }
1686 else
1687 {
1688 if (index <= descr->selected_item)
1689 {
1690 descr->selected_item++;
1691 descr->focus_item = oldfocus; /* focus not changed */
1692 }
1693 }
1694 return LB_OKAY;
1695}
1696
1697
1698/***********************************************************************
1699 * LISTBOX_InsertString
1700 */
1702{
1703 LPWSTR new_str = NULL;
1704 LRESULT ret;
1705
1706 if (HAS_STRINGS(descr))
1707 {
1708 static const WCHAR empty_stringW[] = { 0 };
1709 if (!str) str = empty_stringW;
1710 if (!(new_str = HeapAlloc( GetProcessHeap(), 0, (lstrlenW(str) + 1) * sizeof(WCHAR) )))
1711 {
1713 return LB_ERRSPACE;
1714 }
1715 lstrcpyW(new_str, str);
1716 }
1717
1718 if (index == -1) index = descr->nb_items;
1719 if ((ret = LISTBOX_InsertItem( descr, index, new_str, (ULONG_PTR)str )) != 0)
1720 {
1721 HeapFree( GetProcessHeap(), 0, new_str );
1722 return ret;
1723 }
1724
1725 TRACE("[%p]: added item %d %s\n",
1726 descr->self, index, HAS_STRINGS(descr) ? debugstr_w(new_str) : "" );
1727 return index;
1728}
1729
1730
1731/***********************************************************************
1732 * LISTBOX_DeleteItem
1733 *
1734 * Delete the content of an item. 'index' must be a valid index.
1735 */
1737{
1738 /* Note: Win 3.1 only sends DELETEITEM on owner-draw items,
1739 * while Win95 sends it for all items with user data.
1740 * It's probably better to send it too often than not
1741 * often enough, so this is what we do here.
1742 */
1744 {
1745 DELETEITEMSTRUCT dis;
1746 UINT id = (UINT)GetWindowLongPtrW( descr->self, GWLP_ID );
1747
1748 dis.CtlType = ODT_LISTBOX;
1749 dis.CtlID = id;
1750 dis.itemID = index;
1751 dis.hwndItem = descr->self;
1753 SendMessageW( descr->owner, WM_DELETEITEM, id, (LPARAM)&dis );
1754 }
1756}
1757
1758
1759/***********************************************************************
1760 * LISTBOX_RemoveItem
1761 *
1762 * Remove an item from the listbox and delete its content.
1763 */
1765{
1766 if ((index < 0) || (index >= descr->nb_items)) return LB_ERR;
1767
1768 /* We need to invalidate the original rect instead of the updated one. */
1770
1771 if (descr->nb_items == 1)
1772 {
1773 SendMessageW(descr->self, LB_RESETCONTENT, 0, 0);
1774 return LB_OKAY;
1775 }
1776 descr->nb_items--;
1779
1780 if (descr->anchor_item == descr->nb_items) descr->anchor_item--;
1781 resize_storage(descr, descr->nb_items);
1782
1783 /* Repaint the items */
1784
1786 /* if we removed the scrollbar, reset the top of the list
1787 (correct for owner-drawn ???) */
1788 if (descr->nb_items == descr->page_size)
1790
1791 /* Move selection and focused item */
1792 if (!IS_MULTISELECT(descr))
1793 {
1794 if (index == descr->selected_item)
1795 descr->selected_item = -1;
1796 else if (index < descr->selected_item)
1797 {
1798 descr->selected_item--;
1799 if (ISWIN31) /* win 31 do not change the selected item number */
1800 LISTBOX_SetSelection( descr, descr->selected_item + 1, TRUE, FALSE);
1801 }
1802 }
1803
1804 if (descr->focus_item >= descr->nb_items)
1805 {
1806 descr->focus_item = descr->nb_items - 1;
1807 if (descr->focus_item < 0) descr->focus_item = 0;
1808 }
1809 return LB_OKAY;
1810}
1811
1812
1813/***********************************************************************
1814 * LISTBOX_ResetContent
1815 */
1817{
1818 INT i;
1819
1820 if (!(descr->style & LBS_NODATA))
1821 for (i = descr->nb_items - 1; i >= 0; i--) LISTBOX_DeleteItem(descr, i);
1822 HeapFree( GetProcessHeap(), 0, descr->u.items );
1823 descr->nb_items = 0;
1824 descr->top_item = 0;
1825 descr->selected_item = -1;
1826 descr->focus_item = 0;
1827 descr->anchor_item = -1;
1828 descr->items_size = 0;
1829 descr->u.items = NULL;
1830}
1831
1832
1833/***********************************************************************
1834 * LISTBOX_SetCount
1835 */
1837{
1838 UINT orig_num = descr->nb_items;
1839
1840 if (!(descr->style & LBS_NODATA)) return LB_ERR;
1841
1842 if (!resize_storage(descr, count))
1843 return LB_ERRSPACE;
1844 descr->nb_items = count;
1845
1846 if (count)
1847 {
1849 if (count < orig_num)
1850 {
1851 descr->anchor_item = min(descr->anchor_item, count - 1);
1852 if (descr->selected_item >= count)
1853 descr->selected_item = -1;
1854
1855 /* If we removed the scrollbar, reset the top of the list */
1856 if (count <= descr->page_size && orig_num > descr->page_size)
1858
1859 descr->focus_item = min(descr->focus_item, count - 1);
1860 }
1861
1862 /* If it was empty before growing, set focus to the first item */
1863 else if (orig_num == 0) LISTBOX_SetCaretIndex(descr, 0, FALSE);
1864 }
1865 else SendMessageW(descr->self, LB_RESETCONTENT, 0, 0);
1866
1867 InvalidateRect( descr->self, NULL, TRUE );
1868 return LB_OKAY;
1869}
1870
1871
1872/***********************************************************************
1873 * LISTBOX_Directory
1874 */
1876 LPCWSTR filespec, BOOL long_names )
1877{
1878 HANDLE handle;
1881 int pos;
1882 LRESULT maxinsert = LB_ERR;
1883
1884 /* don't scan directory if we just want drives exclusively */
1885 if (attrib != (DDL_DRIVES | DDL_EXCLUSIVE)) {
1886 /* scan directory */
1887 if ((handle = FindFirstFileW(filespec, &entry)) == INVALID_HANDLE_VALUE)
1888 {
1889 int le = GetLastError();
1890 if ((le != ERROR_NO_MORE_FILES) && (le != ERROR_FILE_NOT_FOUND)) return LB_ERR;
1891 }
1892 else
1893 {
1894 do
1895 {
1896 WCHAR buffer[270];
1897 if (entry.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY)
1898 {
1899 static const WCHAR bracketW[] = { ']',0 };
1900 static const WCHAR dotW[] = { '.',0 };
1901 if (!(attrib & DDL_DIRECTORY) ||
1902 !lstrcmpW( entry.cFileName, dotW )) continue;
1903 buffer[0] = '[';
1904 if (!long_names && entry.cAlternateFileName[0])
1905 lstrcpyW( buffer + 1, entry.cAlternateFileName );
1906 else
1907 lstrcpyW( buffer + 1, entry.cFileName );
1908 lstrcatW(buffer, bracketW);
1909 }
1910 else /* not a directory */
1911 {
1912#define ATTRIBS (FILE_ATTRIBUTE_READONLY | FILE_ATTRIBUTE_HIDDEN | \
1913 FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_ARCHIVE)
1914
1915 if ((attrib & DDL_EXCLUSIVE) &&
1916 ((attrib & ATTRIBS) != (entry.dwFileAttributes & ATTRIBS)))
1917 continue;
1918#undef ATTRIBS
1919 if (!long_names && entry.cAlternateFileName[0])
1920 lstrcpyW( buffer, entry.cAlternateFileName );
1921 else
1922 lstrcpyW( buffer, entry.cFileName );
1923 }
1924 if (!long_names) CharLowerW( buffer );
1926 if ((ret = LISTBOX_InsertString( descr, pos, buffer )) < 0)
1927 break;
1928 if (ret <= maxinsert) maxinsert++; else maxinsert = ret;
1929 } while (FindNextFileW( handle, &entry ));
1930 FindClose( handle );
1931 }
1932 }
1933 if (ret >= 0)
1934 {
1935 ret = maxinsert;
1936
1937 /* scan drives */
1938 if (attrib & DDL_DRIVES)
1939 {
1940 WCHAR buffer[] = {'[','-','a','-',']',0};
1941 WCHAR root[] = {'A',':','\\',0};
1942 int drive;
1943 for (drive = 0; drive < 26; drive++, buffer[2]++, root[0]++)
1944 {
1945 if (GetDriveTypeW(root) <= DRIVE_NO_ROOT_DIR) continue;
1946 if ((ret = LISTBOX_InsertString( descr, -1, buffer )) < 0)
1947 break;
1948 }
1949 }
1950 }
1951 return ret;
1952}
1953
1954
1955/***********************************************************************
1956 * LISTBOX_HandleVScroll
1957 */
1959{
1961
1962 if (descr->style & LBS_MULTICOLUMN) return 0;
1963 switch(scrollReq)
1964 {
1965 case SB_LINEUP:
1966 LISTBOX_SetTopItem( descr, descr->top_item - 1, TRUE );
1967 break;
1968 case SB_LINEDOWN:
1969 LISTBOX_SetTopItem( descr, descr->top_item + 1, TRUE );
1970 break;
1971 case SB_PAGEUP:
1972 LISTBOX_SetTopItem( descr, descr->top_item -
1974 break;
1975 case SB_PAGEDOWN:
1976 LISTBOX_SetTopItem( descr, descr->top_item +
1978 break;
1979 case SB_THUMBPOSITION:
1981 break;
1982 case SB_THUMBTRACK:
1983 info.cbSize = sizeof(info);
1984 info.fMask = SIF_TRACKPOS;
1985 GetScrollInfo( descr->self, SB_VERT, &info );
1986 LISTBOX_SetTopItem( descr, info.nTrackPos, TRUE );
1987 break;
1988 case SB_TOP:
1990 break;
1991 case SB_BOTTOM:
1992 LISTBOX_SetTopItem( descr, descr->nb_items, TRUE );
1993 break;
1994 }
1995 return 0;
1996}
1997
1998
1999/***********************************************************************
2000 * LISTBOX_HandleHScroll
2001 */
2003{
2005 INT page;
2006
2007 if (descr->style & LBS_MULTICOLUMN)
2008 {
2009 switch(scrollReq)
2010 {
2011 case SB_LINELEFT:
2012 LISTBOX_SetTopItem( descr, descr->top_item-descr->page_size,
2013 TRUE );
2014 break;
2015 case SB_LINERIGHT:
2016 LISTBOX_SetTopItem( descr, descr->top_item+descr->page_size,
2017 TRUE );
2018 break;
2019 case SB_PAGELEFT:
2020 page = descr->width / descr->column_width;
2021 if (page < 1) page = 1;
2023 descr->top_item - page * descr->page_size, TRUE );
2024 break;
2025 case SB_PAGERIGHT:
2026 page = descr->width / descr->column_width;
2027 if (page < 1) page = 1;
2029 descr->top_item + page * descr->page_size, TRUE );
2030 break;
2031 case SB_THUMBPOSITION:
2032 LISTBOX_SetTopItem( descr, pos*descr->page_size, TRUE );
2033 break;
2034 case SB_THUMBTRACK:
2035 info.cbSize = sizeof(info);
2036 info.fMask = SIF_TRACKPOS;
2037 GetScrollInfo( descr->self, SB_VERT, &info );
2038 LISTBOX_SetTopItem( descr, info.nTrackPos*descr->page_size,
2039 TRUE );
2040 break;
2041 case SB_LEFT:
2043 break;
2044 case SB_RIGHT:
2045 LISTBOX_SetTopItem( descr, descr->nb_items, TRUE );
2046 break;
2047 }
2048 }
2049 else if (descr->horz_extent)
2050 {
2051 switch(scrollReq)
2052 {
2053 case SB_LINELEFT:
2054 LISTBOX_SetHorizontalPos( descr, descr->horz_pos - 1 );
2055 break;
2056 case SB_LINERIGHT:
2057 LISTBOX_SetHorizontalPos( descr, descr->horz_pos + 1 );
2058 break;
2059 case SB_PAGELEFT:
2061 descr->horz_pos - descr->width );
2062 break;
2063 case SB_PAGERIGHT:
2065 descr->horz_pos + descr->width );
2066 break;
2067 case SB_THUMBPOSITION:
2069 break;
2070 case SB_THUMBTRACK:
2071 info.cbSize = sizeof(info);
2072 info.fMask = SIF_TRACKPOS;
2073 GetScrollInfo( descr->self, SB_HORZ, &info );
2074 LISTBOX_SetHorizontalPos( descr, info.nTrackPos );
2075 break;
2076 case SB_LEFT:
2078 break;
2079 case SB_RIGHT:
2081 descr->horz_extent - descr->width );
2082 break;
2083 }
2084 }
2085 return 0;
2086}
2087
2089{
2090 INT pulScrollLines = 3;
2091
2092 SystemParametersInfoW(SPI_GETWHEELSCROLLLINES,0, &pulScrollLines, 0);
2093
2094 /* if scrolling changes direction, ignore left overs */
2095 if ((delta < 0 && descr->wheel_remain < 0) ||
2096 (delta > 0 && descr->wheel_remain > 0))
2097 descr->wheel_remain += delta;
2098 else
2099 descr->wheel_remain = delta;
2100
2101 if (descr->wheel_remain && pulScrollLines)
2102 {
2103 int cLineScroll;
2104 if (descr->style & LBS_MULTICOLUMN)
2105 {
2106 pulScrollLines = min(descr->width / descr->column_width, pulScrollLines);
2107 pulScrollLines = max(1, pulScrollLines);
2108 cLineScroll = pulScrollLines * descr->wheel_remain / WHEEL_DELTA;
2109 descr->wheel_remain -= WHEEL_DELTA * cLineScroll / pulScrollLines;
2110 cLineScroll *= descr->page_size;
2111 }
2112 else
2113 {
2114 pulScrollLines = min(descr->page_size, pulScrollLines);
2115 cLineScroll = pulScrollLines * descr->wheel_remain / WHEEL_DELTA;
2116 descr->wheel_remain -= WHEEL_DELTA * cLineScroll / pulScrollLines;
2117 }
2118 LISTBOX_SetTopItem( descr, descr->top_item - cLineScroll, TRUE );
2119 }
2120 return 0;
2121}
2122
2123/***********************************************************************
2124 * LISTBOX_HandleLButtonDown
2125 */
2127{
2129
2130 TRACE("[%p]: lbuttondown %d,%d item %d, focus item %d\n",
2131 descr->self, x, y, index, descr->focus_item);
2132
2133 if (!descr->caret_on && (descr->in_focus)) return 0;
2134
2135 if (!descr->in_focus)
2136 {
2137 if( !descr->lphc ) SetFocus( descr->self );
2138 else SetFocus( (descr->lphc->hWndEdit) ? descr->lphc->hWndEdit : descr->lphc->self );
2139 }
2140
2141 if (index == -1) return 0;
2142
2143 if (!descr->lphc)
2144 {
2145 if (descr->style & LBS_NOTIFY )
2147 MAKELPARAM( x, y ) );
2148 }
2149
2150 descr->captured = TRUE;
2151 SetCapture( descr->self );
2152
2153 if (descr->style & (LBS_EXTENDEDSEL | LBS_MULTIPLESEL))
2154 {
2155 /* we should perhaps make sure that all items are deselected
2156 FIXME: needed for !LBS_EXTENDEDSEL, too ?
2157 if (!(keys & (MK_SHIFT|MK_CONTROL)))
2158 LISTBOX_SetSelection( descr, -1, FALSE, FALSE);
2159 */
2160
2161 if (!(keys & MK_SHIFT)) descr->anchor_item = index;
2162 if (keys & MK_CONTROL)
2163 {
2167 (descr->style & LBS_NOTIFY) != 0);
2168 }
2169 else
2170 {
2172
2173 if (descr->style & LBS_EXTENDEDSEL)
2174 {
2177 (descr->style & LBS_NOTIFY) != 0 );
2178 }
2179 else
2180 {
2183 (descr->style & LBS_NOTIFY) != 0 );
2184 }
2185 }
2186 }
2187 else
2188 {
2189 descr->anchor_item = index;
2192 TRUE, (descr->style & LBS_NOTIFY) != 0 );
2193 }
2194
2195 if (!descr->lphc)
2196 {
2198 {
2199 POINT pt;
2200
2201 pt.x = x;
2202 pt.y = y;
2203
2204 if (DragDetect( descr->self, pt ))
2205 SendMessageW( descr->owner, WM_BEGINDRAG, 0, 0 );
2206 }
2207 }
2208 return 0;
2209}
2210
2211
2212/*************************************************************************
2213 * LISTBOX_HandleLButtonDownCombo [Internal]
2214 *
2215 * Process LButtonDown message for the ComboListBox
2216 *
2217 * PARAMS
2218 * pWnd [I] The windows internal structure
2219 * pDescr [I] The ListBox internal structure
2220 * keys [I] Key Flag (WM_LBUTTONDOWN doc for more info)
2221 * x [I] X Mouse Coordinate
2222 * y [I] Y Mouse Coordinate
2223 *
2224 * RETURNS
2225 * 0 since we are processing the WM_LBUTTONDOWN Message
2226 *
2227 * NOTES
2228 * This function is only to be used when a ListBox is a ComboListBox
2229 */
2230
2232{
2233 RECT clientRect, screenRect;
2234 POINT mousePos;
2235
2236 mousePos.x = x;
2237 mousePos.y = y;
2238
2239 GetClientRect(descr->self, &clientRect);
2240
2241 if(PtInRect(&clientRect, mousePos))
2242 {
2243 /* MousePos is in client, resume normal processing */
2244 if (msg == WM_LBUTTONDOWN)
2245 {
2246 descr->lphc->droppedIndex = descr->nb_items ? descr->selected_item : -1;
2248 }
2249 else if (descr->style & LBS_NOTIFY)
2251 }
2252 else
2253 {
2254 POINT screenMousePos;
2255 HWND hWndOldCapture;
2256
2257 /* Check the Non-Client Area */
2258 screenMousePos = mousePos;
2259 hWndOldCapture = GetCapture();
2261 GetWindowRect(descr->self, &screenRect);
2262 ClientToScreen(descr->self, &screenMousePos);
2263
2264 if(!PtInRect(&screenRect, screenMousePos))
2265 {
2266 LISTBOX_SetCaretIndex( descr, descr->lphc->droppedIndex, FALSE );
2267 LISTBOX_SetSelection( descr, descr->lphc->droppedIndex, FALSE, FALSE );
2269 }
2270 else
2271 {
2272 /* Check to see the NC is a scrollbar */
2273 INT nHitTestType=0;
2275 /* Check Vertical scroll bar */
2276 if (style & WS_VSCROLL)
2277 {
2278 clientRect.right += GetSystemMetrics(SM_CXVSCROLL);
2279 if (PtInRect( &clientRect, mousePos ))
2280 nHitTestType = HTVSCROLL;
2281 }
2282 /* Check horizontal scroll bar */
2283 if (style & WS_HSCROLL)
2284 {
2285 clientRect.bottom += GetSystemMetrics(SM_CYHSCROLL);
2286 if (PtInRect( &clientRect, mousePos ))
2287 nHitTestType = HTHSCROLL;
2288 }
2289 /* Windows sends this message when a scrollbar is clicked
2290 */
2291
2292 if(nHitTestType != 0)
2293 {
2294 SendMessageW(descr->self, WM_NCLBUTTONDOWN, nHitTestType,
2295 MAKELONG(screenMousePos.x, screenMousePos.y));
2296 }
2297 /* Resume the Capture after scrolling is complete
2298 */
2299 if(hWndOldCapture != 0)
2300 SetCapture(hWndOldCapture);
2301 }
2302 }
2303 return 0;
2304}
2305
2306/***********************************************************************
2307 * LISTBOX_HandleLButtonUp
2308 */
2310{
2314 if (descr->captured)
2315 {
2316 descr->captured = FALSE;
2317 if (GetCapture() == descr->self) ReleaseCapture();
2318 if ((descr->style & LBS_NOTIFY) && descr->nb_items)
2320 }
2321 return 0;
2322}
2323
2324
2325/***********************************************************************
2326 * LISTBOX_HandleTimer
2327 *
2328 * Handle scrolling upon a timer event.
2329 * Return TRUE if scrolling should continue.
2330 */
2332{
2333 switch(dir)
2334 {
2335 case LB_TIMER_UP:
2336 if (descr->top_item) index = descr->top_item - 1;
2337 else index = 0;
2338 break;
2339 case LB_TIMER_LEFT:
2340 if (descr->top_item) index -= descr->page_size;
2341 break;
2342 case LB_TIMER_DOWN:
2344 if (index == descr->focus_item) index++;
2345 if (index >= descr->nb_items) index = descr->nb_items - 1;
2346 break;
2347 case LB_TIMER_RIGHT:
2348 if (index + descr->page_size < descr->nb_items)
2349 index += descr->page_size;
2350 break;
2351 case LB_TIMER_NONE:
2352 break;
2353 }
2354 if (index == descr->focus_item) return FALSE;
2356 return TRUE;
2357}
2358
2359
2360/***********************************************************************
2361 * LISTBOX_HandleSystemTimer
2362 *
2363 * WM_SYSTIMER handler.
2364 */
2366{
2367 if (!LISTBOX_HandleTimer( descr, descr->focus_item, LISTBOX_Timer ))
2368 {
2371 }
2372 return 0;
2373}
2374
2375
2376/***********************************************************************
2377 * LISTBOX_HandleMouseMove
2378 *
2379 * WM_MOUSEMOVE handler.
2380 */
2382 INT x, INT y )
2383{
2384 INT index;
2386
2387 if (!descr->captured) return;
2388
2389 if (descr->style & LBS_MULTICOLUMN)
2390 {
2391 if (y < 0) y = 0;
2392 else if (y >= descr->item_height * descr->page_size)
2393 y = descr->item_height * descr->page_size - 1;
2394
2395 if (x < 0)
2396 {
2398 x = 0;
2399 }
2400 else if (x >= descr->width)
2401 {
2403 x = descr->width - 1;
2404 }
2405 }
2406 else
2407 {
2408 if (y < 0) dir = LB_TIMER_UP; /* above */
2409 else if (y >= descr->height) dir = LB_TIMER_DOWN; /* below */
2410 }
2411
2413 if (index == -1) index = descr->focus_item;
2415
2416 /* Start/stop the system timer */
2417
2418 if (dir != LB_TIMER_NONE)
2420 else if (LISTBOX_Timer != LB_TIMER_NONE)
2423}
2424
2425
2426/***********************************************************************
2427 * LISTBOX_HandleKeyDown
2428 */
2430{
2431 INT caret = -1;
2432 BOOL bForceSelection = TRUE; /* select item pointed to by focus_item */
2433 if ((IS_MULTISELECT(descr)) || (descr->selected_item == descr->focus_item))
2434 bForceSelection = FALSE; /* only for single select list */
2435
2436 if (descr->style & LBS_WANTKEYBOARDINPUT)
2437 {
2438 caret = SendMessageW( descr->owner, WM_VKEYTOITEM,
2439 MAKEWPARAM(LOWORD(key), descr->focus_item),
2440 (LPARAM)descr->self );
2441 if (caret == -2) return 0;
2442 }
2443 if (caret == -1) switch(key)
2444 {
2445 case VK_LEFT:
2446 if (descr->style & LBS_MULTICOLUMN)
2447 {
2448 bForceSelection = FALSE;
2449 if (descr->focus_item >= descr->page_size)
2450 caret = descr->focus_item - descr->page_size;
2451 break;
2452 }
2453 /* fall through */
2454 case VK_UP:
2455 caret = descr->focus_item - 1;
2456 if (caret < 0) caret = 0;
2457 break;
2458 case VK_RIGHT:
2459 if (descr->style & LBS_MULTICOLUMN)
2460 {
2461 bForceSelection = FALSE;
2462 caret = min(descr->focus_item + descr->page_size, descr->nb_items - 1);
2463 break;
2464 }
2465 /* fall through */
2466 case VK_DOWN:
2467 caret = descr->focus_item + 1;
2468 if (caret >= descr->nb_items) caret = descr->nb_items - 1;
2469 break;
2470
2471 case VK_PRIOR:
2472 if (descr->style & LBS_MULTICOLUMN)
2473 {
2474 INT page = descr->width / descr->column_width;
2475 if (page < 1) page = 1;
2476 caret = descr->focus_item - (page * descr->page_size) + 1;
2477 }
2478 else caret = descr->focus_item-LISTBOX_GetCurrentPageSize(descr) + 1;
2479 if (caret < 0) caret = 0;
2480 break;
2481 case VK_NEXT:
2482 if (descr->style & LBS_MULTICOLUMN)
2483 {
2484 INT page = descr->width / descr->column_width;
2485 if (page < 1) page = 1;
2486 caret = descr->focus_item + (page * descr->page_size) - 1;
2487 }
2488 else caret = descr->focus_item + LISTBOX_GetCurrentPageSize(descr) - 1;
2489 if (caret >= descr->nb_items) caret = descr->nb_items - 1;
2490 break;
2491 case VK_HOME:
2492 caret = 0;
2493 break;
2494 case VK_END:
2495 caret = descr->nb_items - 1;
2496 break;
2497 case VK_SPACE:
2498 if (descr->style & LBS_EXTENDEDSEL) caret = descr->focus_item;
2499 else if (descr->style & LBS_MULTIPLESEL)
2500 {
2501 LISTBOX_SetSelection( descr, descr->focus_item,
2502 !is_item_selected(descr, descr->focus_item),
2503 (descr->style & LBS_NOTIFY) != 0 );
2504 }
2505 break;
2506 default:
2507 bForceSelection = FALSE;
2508 }
2509 if (bForceSelection) /* focused item is used instead of key */
2510 caret = descr->focus_item;
2511 if (caret >= 0)
2512 {
2513 if (((descr->style & LBS_EXTENDEDSEL) &&
2514 !(GetKeyState( VK_SHIFT ) & 0x8000)) ||
2516 descr->anchor_item = caret;
2517 LISTBOX_MoveCaret( descr, caret, TRUE );
2518
2519 if (descr->style & LBS_MULTIPLESEL)
2520 descr->selected_item = caret;
2521 else
2523 if (descr->style & LBS_NOTIFY)
2524 {
2525 if (descr->lphc && IsWindowVisible( descr->self ))
2526 {
2527 /* make sure that combo parent doesn't hide us */
2528 descr->lphc->wState |= CBF_NOROLLUP;
2529 }
2530 if (descr->nb_items) SEND_NOTIFICATION( descr, LBN_SELCHANGE );
2531 }
2532 }
2533 return 0;
2534}
2535
2536
2537/***********************************************************************
2538 * LISTBOX_HandleChar
2539 */
2541{
2542 INT caret = -1;
2543 WCHAR str[2];
2544
2545 str[0] = charW;
2546 str[1] = '\0';
2547
2548 if (descr->style & LBS_WANTKEYBOARDINPUT)
2549 {
2550 caret = SendMessageW( descr->owner, WM_CHARTOITEM,
2551 MAKEWPARAM(charW, descr->focus_item),
2552 (LPARAM)descr->self );
2553 if (caret == -2) return 0;
2554 }
2555 if (caret == -1)
2556 caret = LISTBOX_FindString( descr, descr->focus_item, str, FALSE);
2557 if (caret != -1)
2558 {
2559 if ((!IS_MULTISELECT(descr)) && descr->selected_item == -1)
2561 LISTBOX_MoveCaret( descr, caret, TRUE );
2562 if ((descr->style & LBS_NOTIFY) && descr->nb_items)
2564 }
2565 return 0;
2566}
2567
2568
2569/***********************************************************************
2570 * LISTBOX_Create
2571 */
2573{
2574 LB_DESCR *descr;
2576 RECT rect;
2577
2578 if (!(descr = HeapAlloc( GetProcessHeap(), 0, sizeof(*descr) )))
2579 return FALSE;
2580
2581 GetClientRect( hwnd, &rect );
2582 descr->self = hwnd;
2583 descr->owner = GetParent( descr->self );
2584 descr->style = GetWindowLongW( descr->self, GWL_STYLE );
2585 descr->width = rect.right - rect.left;
2586 descr->height = rect.bottom - rect.top;
2587 descr->u.items = NULL;
2588 descr->items_size = 0;
2589 descr->nb_items = 0;
2590 descr->top_item = 0;
2591 descr->selected_item = -1;
2592 descr->focus_item = 0;
2593 descr->anchor_item = -1;
2594 descr->item_height = 1;
2595 descr->page_size = 1;
2596 descr->column_width = 150;
2597 descr->horz_extent = 0;
2598 descr->horz_pos = 0;
2599 descr->nb_tabs = 0;
2600 descr->tabs = NULL;
2601 descr->wheel_remain = 0;
2602 descr->caret_on = !lphc;
2603 if (descr->style & LBS_NOSEL) descr->caret_on = FALSE;
2604 descr->in_focus = FALSE;
2605 descr->captured = FALSE;
2606 descr->font = 0;
2607 descr->locale = GetUserDefaultLCID();
2608 descr->lphc = lphc;
2609
2610 if( lphc )
2611 {
2612 TRACE("[%p]: resetting owner %p -> %p\n", descr->self, descr->owner, lphc->self );
2613 descr->owner = lphc->self;
2614 }
2615
2616 SetWindowLongPtrW( descr->self, 0, (LONG_PTR)descr );
2617
2618/* if (wnd->dwExStyle & WS_EX_NOPARENTNOTIFY) descr->style &= ~LBS_NOTIFY;
2619 */
2620 if (descr->style & LBS_EXTENDEDSEL) descr->style |= LBS_MULTIPLESEL;
2621 if (descr->style & LBS_MULTICOLUMN) descr->style &= ~LBS_OWNERDRAWVARIABLE;
2622 if (descr->style & LBS_OWNERDRAWVARIABLE) descr->style |= LBS_NOINTEGRALHEIGHT;
2624 descr->style &= ~LBS_NODATA;
2625 descr->item_height = LISTBOX_SetFont( descr, 0 );
2626
2627 if (descr->style & LBS_OWNERDRAWFIXED)
2628 {
2629 descr->style &= ~LBS_OWNERDRAWVARIABLE;
2630
2631 if( descr->lphc && (descr->lphc->dwStyle & CBS_DROPDOWN))
2632 {
2633 /* WinWord gets VERY unhappy if we send WM_MEASUREITEM from here */
2634 descr->item_height = lphc->fixedOwnerDrawHeight;
2635 }
2636 else
2637 {
2638 UINT id = (UINT)GetWindowLongPtrW( descr->self, GWLP_ID );
2639 mis.CtlType = ODT_LISTBOX;
2640 mis.CtlID = id;
2641 mis.itemID = -1;
2642 mis.itemWidth = 0;
2643 mis.itemData = 0;
2644 mis.itemHeight = descr->item_height;
2645 SendMessageW( descr->owner, WM_MEASUREITEM, id, (LPARAM)&mis );
2646 descr->item_height = mis.itemHeight ? mis.itemHeight : 1;
2647 }
2648 }
2649
2651
2652 TRACE("owner: %p, style: %08x, width: %d, height: %d\n", descr->owner, descr->style, descr->width, descr->height);
2653 return TRUE;
2654}
2655
2656
2657/***********************************************************************
2658 * LISTBOX_Destroy
2659 */
2661{
2662 HTHEME theme = GetWindowTheme( descr->self );
2663 CloseThemeData( theme );
2665 SetWindowLongPtrW( descr->self, 0, 0 );
2666 HeapFree( GetProcessHeap(), 0, descr );
2667 return TRUE;
2668}
2669
2670
2671/***********************************************************************
2672 * ListBoxWndProc_common
2673 */
2675{
2677 HEADCOMBO *lphc = NULL;
2678 HTHEME theme;
2679 LRESULT ret;
2680
2681 if (!descr)
2682 {
2683 if (!IsWindow(hwnd)) return 0;
2684
2685 if (msg == WM_CREATE)
2686 {
2688 if (lpcs->style & LBS_COMBOBOX) lphc = lpcs->lpCreateParams;
2689 if (!LISTBOX_Create( hwnd, lphc )) return -1;
2690 TRACE("creating hwnd %p descr %p\n", hwnd, (void *)GetWindowLongPtrW( hwnd, 0 ) );
2691 return 0;
2692 }
2693 /* Ignore all other messages before we get a WM_CREATE */
2694 return DefWindowProcW( hwnd, msg, wParam, lParam );
2695 }
2696 if (descr->style & LBS_COMBOBOX) lphc = descr->lphc;
2697
2698 TRACE("[%p]: msg %#x wp %08lx lp %08lx\n", descr->self, msg, wParam, lParam );
2699
2700 switch(msg)
2701 {
2702 case LB_RESETCONTENT:
2705 InvalidateRect( descr->self, NULL, TRUE );
2706 return 0;
2707
2708 case LB_ADDSTRING:
2709 {
2710 const WCHAR *textW = (const WCHAR *)lParam;
2713 }
2714
2715 case LB_INSERTSTRING:
2716 return LISTBOX_InsertString( descr, wParam, (const WCHAR *)lParam );
2717
2718 case LB_ADDFILE:
2719 {
2720 const WCHAR *textW = (const WCHAR *)lParam;
2723 }
2724
2725 case LB_DELETESTRING:
2727 return descr->nb_items;
2728 else
2729 {
2731 return LB_ERR;
2732 }
2733
2734 case LB_GETITEMDATA:
2735 if (((INT)wParam < 0) || ((INT)wParam >= descr->nb_items))
2736 {
2738 return LB_ERR;
2739 }
2740 return get_item_data(descr, wParam);
2741
2742 case LB_SETITEMDATA:
2743 if (((INT)wParam < 0) || ((INT)wParam >= descr->nb_items))
2744 {
2746 return LB_ERR;
2747 }
2749 /* undocumented: returns TRUE, not LB_OKAY (0) */
2750 return TRUE;
2751
2752 case LB_GETCOUNT:
2753 return descr->nb_items;
2754
2755 case LB_GETTEXT:
2757
2758 case LB_GETTEXTLEN:
2759 if ((INT)wParam >= descr->nb_items || (INT)wParam < 0)
2760 {
2762 return LB_ERR;
2763 }
2764 if (!HAS_STRINGS(descr)) return sizeof(ULONG_PTR);
2766
2767 case LB_GETCURSEL:
2768 if (descr->nb_items == 0)
2769 return LB_ERR;
2770 if (!IS_MULTISELECT(descr))
2771 return descr->selected_item;
2772 if (descr->selected_item != -1)
2773 return descr->selected_item;
2774 return descr->focus_item;
2775 /* otherwise, if the user tries to move the selection with the */
2776 /* arrow keys, we will give the application something to choke on */
2777 case LB_GETTOPINDEX:
2778 return descr->top_item;
2779
2780 case LB_GETITEMHEIGHT:
2782
2783 case LB_SETITEMHEIGHT:
2785
2786 case LB_ITEMFROMPOINT:
2787 {
2788 POINT pt;
2789 RECT rect;
2790 int index;
2791 BOOL hit = TRUE;
2792
2793 /* The hiword of the return value is not a client area
2794 hittest as suggested by MSDN, but rather a hittest on
2795 the returned listbox item. */
2796
2797 if(descr->nb_items == 0)
2798 return 0x1ffff; /* win9x returns 0x10000, we copy winnt */
2799
2800 pt.x = (short)LOWORD(lParam);
2801 pt.y = (short)HIWORD(lParam);
2802
2803 SetRect(&rect, 0, 0, descr->width, descr->height);
2804
2805 if(!PtInRect(&rect, pt))
2806 {
2807 pt.x = min(pt.x, rect.right - 1);
2808 pt.x = max(pt.x, 0);
2809 pt.y = min(pt.y, rect.bottom - 1);
2810 pt.y = max(pt.y, 0);
2811 hit = FALSE;
2812 }
2813
2815
2816 if(index == -1)
2817 {
2818 index = descr->nb_items - 1;
2819 hit = FALSE;
2820 }
2821 return MAKELONG(index, hit ? 0 : 1);
2822 }
2823
2824 case LB_SETCARETINDEX:
2825 if ((!IS_MULTISELECT(descr)) && (descr->selected_item != -1)) return LB_ERR;
2827 return LB_ERR;
2828 else if (ISWIN31)
2829 return wParam;
2830 else
2831 return LB_OKAY;
2832
2833 case LB_GETCARETINDEX:
2834 return descr->focus_item;
2835
2836 case LB_SETTOPINDEX:
2837 return LISTBOX_SetTopItem( descr, wParam, TRUE );
2838
2839 case LB_SETCOLUMNWIDTH:
2841
2842 case LB_GETITEMRECT:
2844
2845 case LB_FINDSTRING:
2846 return LISTBOX_FindString( descr, wParam, (const WCHAR *)lParam, FALSE );
2847
2848 case LB_FINDSTRINGEXACT:
2849 return LISTBOX_FindString( descr, wParam, (const WCHAR *)lParam, TRUE );
2850
2851 case LB_SELECTSTRING:
2852 {
2853 const WCHAR *textW = (const WCHAR *)lParam;
2854 INT index;
2855
2856 if (HAS_STRINGS(descr))
2857 TRACE("LB_SELECTSTRING: %s\n", debugstr_w(textW));
2858
2860 if (index != LB_ERR)
2861 {
2864 }
2865 return index;
2866 }
2867
2868 case LB_GETSEL:
2869 if (((INT)wParam < 0) || ((INT)wParam >= descr->nb_items))
2870 return LB_ERR;
2871 return is_item_selected(descr, wParam);
2872
2873 case LB_SETSEL:
2875 if (ret != LB_ERR && wParam)
2876 {
2877 descr->anchor_item = lParam;
2878 if (lParam != -1)
2880 }
2881 return ret;
2882
2883 case LB_SETCURSEL:
2884 if (IS_MULTISELECT(descr)) return LB_ERR;
2887 if (ret != LB_ERR) ret = descr->selected_item;
2888 return ret;
2889
2890 case LB_GETSELCOUNT:
2891 return LISTBOX_GetSelCount( descr );
2892
2893 case LB_GETSELITEMS:
2895
2896 case LB_SELITEMRANGE:
2897 if (LOWORD(lParam) <= HIWORD(lParam))
2899 HIWORD(lParam), wParam );
2900 else
2902 LOWORD(lParam), wParam );
2903
2904 case LB_SELITEMRANGEEX:
2905 if ((INT)lParam >= (INT)wParam)
2907 else
2909
2911 return descr->horz_extent;
2912
2915
2916 case LB_GETANCHORINDEX:
2917 return descr->anchor_item;
2918
2919 case LB_SETANCHORINDEX:
2920 if (((INT)wParam < -1) || ((INT)wParam >= descr->nb_items))
2921 {
2923 return LB_ERR;
2924 }
2925 descr->anchor_item = (INT)wParam;
2926 return LB_OKAY;
2927
2928 case LB_DIR:
2929 return LISTBOX_Directory( descr, wParam, (const WCHAR *)lParam, msg == LB_DIR );
2930
2931 case LB_GETLOCALE:
2932 return descr->locale;
2933
2934 case LB_SETLOCALE:
2935 {
2936 LCID ret;
2938 return LB_ERR;
2939 ret = descr->locale;
2940 descr->locale = (LCID)wParam;
2941 return ret;
2942 }
2943
2944 case LB_INITSTORAGE:
2945 return LISTBOX_InitStorage( descr, wParam );
2946
2947 case LB_SETCOUNT:
2948 return LISTBOX_SetCount( descr, (INT)wParam );
2949
2950 case LB_SETTABSTOPS:
2952
2953 case LB_CARETON:
2954 if (descr->caret_on)
2955 return LB_OKAY;
2956 descr->caret_on = TRUE;
2957 if ((descr->focus_item != -1) && (descr->in_focus))
2958 LISTBOX_RepaintItem( descr, descr->focus_item, ODA_FOCUS );
2959 return LB_OKAY;
2960
2961 case LB_CARETOFF:
2962 if (!descr->caret_on)
2963 return LB_OKAY;
2964 descr->caret_on = FALSE;
2965 if ((descr->focus_item != -1) && (descr->in_focus))
2966 LISTBOX_RepaintItem( descr, descr->focus_item, ODA_FOCUS );
2967 return LB_OKAY;
2968
2969 case LB_GETLISTBOXINFO:
2970 return descr->page_size;
2971
2972 case WM_DESTROY:
2973 return LISTBOX_Destroy( descr );
2974
2975 case WM_ENABLE:
2976 InvalidateRect( descr->self, NULL, TRUE );
2977 return 0;
2978
2979 case WM_SETREDRAW:
2981 return 0;
2982
2983 case WM_GETDLGCODE:
2985
2986 case WM_PRINTCLIENT:
2987 case WM_PAINT:
2988 {
2989 PAINTSTRUCT ps;
2990 HDC hdc = ( wParam ) ? ((HDC)wParam) : BeginPaint( descr->self, &ps );
2991 ret = LISTBOX_Paint( descr, hdc );
2992 if( !wParam ) EndPaint( descr->self, &ps );
2993 }
2994 return ret;
2995
2996 case WM_NCPAINT:
2997 LISTBOX_NCPaint( descr, (HRGN)wParam );
2998 break;
2999
3000 case WM_SIZE:
3002 return 0;
3003 case WM_GETFONT:
3004 return (LRESULT)descr->font;
3005 case WM_SETFONT:
3007 if (lParam) InvalidateRect( descr->self, 0, TRUE );
3008 return 0;
3009 case WM_SETFOCUS:
3010 descr->in_focus = TRUE;
3011 descr->caret_on = TRUE;
3012 if (descr->focus_item != -1)
3015 return 0;
3016 case WM_KILLFOCUS:
3017 LISTBOX_HandleLButtonUp( descr ); /* Release capture if we have it */
3018 descr->in_focus = FALSE;
3019 descr->wheel_remain = 0;
3020 if ((descr->focus_item != -1) && descr->caret_on)
3021 LISTBOX_RepaintItem( descr, descr->focus_item, ODA_FOCUS );
3023 return 0;
3024 case WM_HSCROLL:
3026 case WM_VSCROLL:
3028 case WM_MOUSEWHEEL:
3029 if (wParam & (MK_SHIFT | MK_CONTROL))
3030 return DefWindowProcW( descr->self, msg, wParam, lParam );
3032 case WM_LBUTTONDOWN:
3033 if (lphc)
3036 (INT16)HIWORD(lParam) );
3039 (INT16)HIWORD(lParam) );
3040 case WM_LBUTTONDBLCLK:
3041 if (lphc)
3044 (INT16)HIWORD(lParam) );
3045 if (descr->style & LBS_NOTIFY)
3047 return 0;
3048 case WM_MOUSEMOVE:
3049 if ( lphc && ((lphc->dwStyle & CBS_DROPDOWNLIST) != CBS_SIMPLE) )
3050 {
3051 BOOL captured = descr->captured;
3052 POINT mousePos;
3053 RECT clientRect;
3054
3055 mousePos.x = (INT16)LOWORD(lParam);
3056 mousePos.y = (INT16)HIWORD(lParam);
3057
3058 /*
3059 * If we are in a dropdown combobox, we simulate that
3060 * the mouse is captured to show the tracking of the item.
3061 */
3062 if (GetClientRect(descr->self, &clientRect) && PtInRect( &clientRect, mousePos ))
3063 descr->captured = TRUE;
3064
3065 LISTBOX_HandleMouseMove( descr, mousePos.x, mousePos.y);
3066
3067 descr->captured = captured;
3068 }
3069 else if (GetCapture() == descr->self)
3070 {
3072 (INT16)HIWORD(lParam) );
3073 }
3074 return 0;
3075 case WM_LBUTTONUP:
3076 if (lphc)
3077 {
3078 POINT mousePos;
3079 RECT clientRect;
3080
3081 /*
3082 * If the mouse button "up" is not in the listbox,
3083 * we make sure there is no selection by re-selecting the
3084 * item that was selected when the listbox was made visible.
3085 */
3086 mousePos.x = (INT16)LOWORD(lParam);
3087 mousePos.y = (INT16)HIWORD(lParam);
3088
3089 GetClientRect(descr->self, &clientRect);
3090
3091 /*
3092 * When the user clicks outside the combobox and the focus
3093 * is lost, the owning combobox will send a fake buttonup with
3094 * 0xFFFFFFF as the mouse location, we must also revert the
3095 * selection to the original selection.
3096 */
3097 if ( (lParam == (LPARAM)-1) || (!PtInRect( &clientRect, mousePos )) )
3099 }
3101 case WM_KEYDOWN:
3102 if( lphc && (lphc->dwStyle & CBS_DROPDOWNLIST) != CBS_SIMPLE )
3103 {
3104 /* for some reason Windows makes it possible to
3105 * show/hide ComboLBox by sending it WM_KEYDOWNs */
3106
3107 if( (!(lphc->wState & CBF_EUI) && wParam == VK_F4) ||
3108 ( (lphc->wState & CBF_EUI) && !(lphc->wState & CBF_DROPPED)
3109 && (wParam == VK_DOWN || wParam == VK_UP)) )
3110 {
3111 COMBO_FlipListbox( lphc, FALSE, FALSE );
3112 return 0;
3113 }
3114 }
3116 case WM_CHAR:
3117 return LISTBOX_HandleChar( descr, wParam );
3118
3119 case WM_SYSTIMER:
3121 case WM_ERASEBKGND:
3122 if ((IS_OWNERDRAW(descr)) && !(descr->style & LBS_DISPLAYCHANGED))
3123 {
3124 RECT rect;
3125 HBRUSH hbrush = (HBRUSH)SendMessageW( descr->owner, WM_CTLCOLORLISTBOX,
3126 wParam, (LPARAM)descr->self );
3127 TRACE("hbrush = %p\n", hbrush);
3128 if(!hbrush)
3130 if(hbrush)
3131 {
3132 GetClientRect(descr->self, &rect);
3134 }
3135 }
3136 return 1;
3137 case WM_DROPFILES:
3138 if( lphc ) return 0;
3139 return SendMessageW( descr->owner, msg, wParam, lParam );
3140
3141 case WM_NCDESTROY:
3142 if( lphc && (lphc->dwStyle & CBS_DROPDOWNLIST) != CBS_SIMPLE )
3143 lphc->hWndLBox = 0;
3144 break;
3145
3146 case WM_NCACTIVATE:
3147 if (lphc) return 0;
3148 break;
3149
3150 case WM_THEMECHANGED:
3151 theme = GetWindowTheme( hwnd );
3152 CloseThemeData( theme );
3154 break;
3155
3156 default:
3157 if ((msg >= WM_USER) && (msg < 0xc000))
3158 WARN("[%p]: unknown msg %04x wp %08lx lp %08lx\n",
3159 hwnd, msg, wParam, lParam );
3160 }
3161
3162 return DefWindowProcW( hwnd, msg, wParam, lParam );
3163}
3164
3166{
3167 WNDCLASSW wndClass;
3168
3169 memset(&wndClass, 0, sizeof(wndClass));
3172 wndClass.cbClsExtra = 0;
3173 wndClass.cbWndExtra = sizeof(LB_DESCR *);
3174 wndClass.hCursor = LoadCursorW(0, (LPWSTR)IDC_ARROW);
3175 wndClass.hbrBackground = NULL;
3176 wndClass.lpszClassName = WC_LISTBOXW;
3177 RegisterClassW(&wndClass);
3178}
3179
3181{
3182 static const WCHAR combolboxW[] = {'C','o','m','b','o','L','B','o','x',0};
3183 WNDCLASSW wndClass;
3184
3185 memset(&wndClass, 0, sizeof(wndClass));
3188 wndClass.cbClsExtra = 0;
3189 wndClass.cbWndExtra = sizeof(LB_DESCR *);
3190 wndClass.hCursor = LoadCursorW(0, (LPWSTR)IDC_ARROW);
3191 wndClass.hbrBackground = NULL;
3192 wndClass.lpszClassName = combolboxW;
3193 RegisterClassW(&wndClass);
3194}
3195
3196#ifdef __REACTOS__
3197void LISTBOX_Unregister(void)
3198{
3200}
3201
3202void COMBOLBOX_Unregister(void)
3203{
3204 static const WCHAR combolboxW[] = {'C','o','m','b','o','L','B','o','x',0};
3206}
3207#endif
static HRGN hrgn
static HBRUSH hbrush
signed short INT16
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:1082
static LRESULT LISTBOX_RemoveItem(LB_DESCR *descr, INT index)
Definition: listbox.c:1764
#define SEND_NOTIFICATION(descr, code)
Definition: listbox.c:111
static LRESULT LISTBOX_InsertString(LB_DESCR *descr, INT index, LPCWSTR str)
Definition: listbox.c:1701
static void LISTBOX_DrawFocusRect(LB_DESCR *descr, BOOL on)
Definition: listbox.c:775
static void LISTBOX_SetHorizontalPos(LB_DESCR *descr, INT pos)
Definition: listbox.c:1332
static LRESULT LISTBOX_HandleKeyDown(LB_DESCR *descr, DWORD key)
Definition: listbox.c:2429
static LRESULT LISTBOX_SetCaretIndex(LB_DESCR *descr, INT index, BOOL fully_visible)
Definition: listbox.c:1478
static BOOL LISTBOX_SetTabStops(LB_DESCR *descr, INT count, LPINT tabs)
Definition: listbox.c:815
static LRESULT LISTBOX_HandleLButtonUp(LB_DESCR *descr)
Definition: listbox.c:2309
#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:1736
static void LISTBOX_InvalidateItems(LB_DESCR *descr, INT index)
Definition: listbox.c:1243
static LRESULT LISTBOX_GetSelCount(const LB_DESCR *descr)
Definition: listbox.c:1053
static void LISTBOX_SetRedraw(LB_DESCR *descr, BOOL on)
Definition: listbox.c:715
static void LISTBOX_InvalidateItemRect(LB_DESCR *descr, INT index)
Definition: listbox.c:1267
static LRESULT LISTBOX_GetText(LB_DESCR *descr, INT index, LPWSTR buffer, BOOL unicode)
Definition: listbox.c:847
#define ISWIN31
Definition: listbox.c:115
static LRESULT LISTBOX_InitStorage(LB_DESCR *descr, INT nb_items)
Definition: listbox.c:802
static void LISTBOX_MakeItemVisible(LB_DESCR *descr, INT index, BOOL fully)
Definition: listbox.c:1439
static INT LISTBOX_FindFileStrPos(LB_DESCR *descr, LPCWSTR str)
Definition: listbox.c:949
static LRESULT LISTBOX_SetSelection(LB_DESCR *descr, INT index, BOOL on, BOOL send_notify)
Definition: listbox.c:1547
static LRESULT LISTBOX_HandleLButtonDownCombo(LB_DESCR *descr, UINT msg, DWORD keys, INT x, INT y)
Definition: listbox.c:2231
static LRESULT LISTBOX_HandleVScroll(LB_DESCR *descr, WORD scrollReq, WORD pos)
Definition: listbox.c:1958
#define IS_MULTISELECT(descr)
Definition: listbox.c:107
static void LISTBOX_ResetContent(LB_DESCR *descr)
Definition: listbox.c:1816
static LRESULT LISTBOX_HandleTimer(LB_DESCR *descr, INT index, TIMER_DIRECTION dir)
Definition: listbox.c:2331
#define HAS_STRINGS(descr)
Definition: listbox.c:103
static LRESULT LISTBOX_HandleMouseWheel(LB_DESCR *descr, SHORT delta)
Definition: listbox.c:2088
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:1360
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:1637
static void LISTBOX_MoveCaret(LB_DESCR *descr, INT index, BOOL fully_visible)
Definition: listbox.c:1590
static LRESULT LISTBOX_GetSelItems(const LB_DESCR *descr, INT max, LPINT array)
Definition: listbox.c:1069
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:1083
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:1408
static LRESULT LISTBOX_SetColumnWidth(LB_DESCR *descr, INT column_width)
Definition: listbox.c:1386
static LRESULT LISTBOX_HandleHScroll(LB_DESCR *descr, WORD scrollReq, WORD pos)
Definition: listbox.c:2002
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:1507
static void set_item_data(LB_DESCR *descr, UINT index, ULONG_PTR data)
Definition: listbox.c:180
void LISTBOX_Register(void)
Definition: listbox.c:3165
static void LISTBOX_RepaintItem(LB_DESCR *descr, INT index, UINT action)
Definition: listbox.c:742
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:993
static void insert_item_data(LB_DESCR *descr, UINT index)
Definition: listbox.c:226
static BOOL LISTBOX_Destroy(LB_DESCR *descr)
Definition: listbox.c:2660
#define LB_ARRAY_GRANULARITY
Definition: listbox.c:43
static void LISTBOX_NCPaint(LB_DESCR *descr, HRGN region)
Definition: listbox.c:1194
void COMBOLBOX_Register(void)
Definition: listbox.c:3180
static LRESULT LISTBOX_HandleSystemTimer(LB_DESCR *descr)
Definition: listbox.c:2365
#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:1875
static void LISTBOX_HandleMouseMove(LB_DESCR *descr, INT x, INT y)
Definition: listbox.c:2381
static LRESULT LISTBOX_GetItemHeight(const LB_DESCR *descr, INT index)
Definition: listbox.c:1278
#define LB_SCROLL_TIMEOUT
Definition: listbox.c:46
static INT LISTBOX_FindStringPos(LB_DESCR *descr, LPCWSTR str, BOOL exact)
Definition: listbox.c:905
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:887
#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:2540
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:1296
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:1836
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:2674
static BOOL LISTBOX_Create(HWND hwnd, LPHEADCOMBO lphc)
Definition: listbox.c:2572
static LRESULT LISTBOX_HandleLButtonDown(LB_DESCR *descr, DWORD keys, INT x, INT y)
Definition: listbox.c:2126
#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:4246
INT WINAPI CompareStringW(LCID lcid, DWORD flags, LPCWSTR str1, INT len1, LPCWSTR str2, INT len2)
Definition: locale.c:4017
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:53
static const WCHAR dotW[]
Definition: directory.c:80
#define WM_LBTRACKPOINT
Definition: msg.c:59
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
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
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:3287
HBRUSH hbrBackground
Definition: winuser.h:3285
int cbClsExtra
Definition: winuser.h:3280
UINT style
Definition: winuser.h:3278
WNDPROC lpfnWndProc
Definition: winuser.h:3279
int cbWndExtra
Definition: winuser.h:3281
HCURSOR hCursor
Definition: winuser.h:3284
Definition: copy.c:22
Definition: module.h:576
ULONG_PTR itemData1
Definition: winuser.h:3096
ULONG_PTR itemData2
Definition: winuser.h:3098
LPVOID lpCreateParams
Definition: winuser.h:3057
ULONG_PTR itemData
Definition: winuser.h:3146
ULONG_PTR itemData
Definition: winuser.h:3195
ULONG_PTR itemData
Definition: winuser.h:3748
long y
Definition: polytest.cpp:48
long x
Definition: polytest.cpp:48
Definition: windef.h:99
LONG right
Definition: windef.h:102
LONG bottom
Definition: windef.h:103
LONG top
Definition: windef.h:101
#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:94
#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
int WINAPI ExcludeClipRect(_In_ HDC, _In_ int, _In_ int, _In_ int, _In_ int)
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:4111
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:4931
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:4110
#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:2457
#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:5457
#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