Visual C++ and MFC Programming 2nd Edition

(Martin Jones) #1

Chapter 21: Tree and List Controls Visual C++ and MFC Fundamentals


LVS_EX_TRACKSELECT: When this style is set, if the user positions the mouse on
an item for a few seconds without clicking, the item would be automatically selected.

The items of a list control can display only within the control, if there are too many of
them or the total width of the items is larger than the control can display, it would be
equipped with either a vertical scroll bar, a horizontal scroll bar, or both. If you want to
prevent scroll bars from displaying even if the list’s items go beyond the allocated
rectangle, set the No Scroll property to True or create the control with the
LVS_NOSCROLL style.

Once the list has been created, the user can select an item by clicking it. To select more
than one item, the user can press and hold either Ctrl for random selection or Shift for
range selection. Here is an example of a random selection:

If you do not want the user to be able to select more than one item at a time, set the
Single Selection property to True or create the control with the LVS_SINGLESEL
style.

Any item that is selected is highlighted. When the user clicks another control or another
application, you can decide whether you want the item(s) selected to still show its (their)
selection. State. This characteristic is controlled at design time by the Show Selection
Always property. By default, it is set to False, meaning that when the control looses focus
or its parent application is deactivated, an item that is selected would not show it.
Otherwise, you can set this property to True to indicate the selected item even when the
control is not active. This property is available through the LVS_SHOWSELALWAYS
style.
Free download pdf