Microsoft KB Archive/71759

{|
 * width="100%"|

HOWTO: Determine Selected Items in a Multiselection List Box

 * }

Q71759

-

The information in this article applies to:


 * Microsoft Win32 Application Programming Interface (API), used with:
 * Microsoft Windows 95
 * Microsoft Windows 98
 * the operating system: Microsoft Windows NT 3.51
 * the operating system: Microsoft Windows 2000

-

SUMMARY
To obtain the indexes of all the selected items in a multiselection list box, the LB_GETSELITEMS message should be sent to the list box.

The message LB_GETCURSEL cannot be used for this purpose because it is designed for use in single-selection list boxes.

Another approach is to send one LB_GETSEL message for every item of the multiselection list box to get its selection state. If the item is selected, LB_GETSEL returns a positive number. The indexes can be built into an array of selected items.

Additional query words:

Keywords : kbCtrl kbListBox kbOSWinNT351 kbOSWin2000 kbGrpDSUser kbOSWin95 kbOSWin98

Issue type : kbhowto

Technology : kbAudDeveloper kbWin32sSearch kbWin32API