Tuesday, December 12

Windows List Box Styles

Google+ Pinterest LinkedIn Tumblr +

Windows Predefined Controls – Part 16
Volume – Windows User Interface

Introduction
This is part 16 of my series, Windows Predefined Controls. In order to understand this tutorial, you most have read all the previous tutorials of the series. In this part of the series, we look at Windows List Box Styles.

Note: If you cannot see the code or if you think anything is missing (broken link, image absent), just contact me at forchatrans@yahoo.com. That is, contact me for the slightest problem you have about what you are reading.

Styles
The appearance and outward behavior of a control is given by its styles. These styles include the WS_CHILD. Styles can be combined with the | operator as value for the dwStyle argument of the CreateWindowEx function. | means and/or at that position. The items you type as the dwStyle value are identifiers of constants. I now give you the style constants and their meanings.

Constant: Meaning
LBS_COMBOBOX: This style notifies a list box that it is part of a combo box (see later).

LBS_DISABLENOSCROLL: This style shows a disabled horizontal or vertical scroll bar when the list box does not contain enough items to scroll. If you do not specify this style, the scroll bar is hidden when the list box does not contain enough items. This style must be used with the WS_VSCROLL or WS_HSCROLL style.

LBS_EXTENDEDSEL: This style allows multiple items in the list to be selected by using the SHIFT key and the mouse or special key combinations.

LBS_HASSTRINGS: This style specifies that a list box contains items consisting of text strings. The list box maintains the memory and addresses for the strings so that the application can use the LB_GETTEXT message to retrieve the text for a particular item. By default, all list boxes have this style.

LBS_MULTICOLUMN:  It is possible to have a multi-column list box. This style specifies a multi-column list box that can be scrolled horizontally. The list box automatically calculates the width of the columns, or an application can set the width by using the LB_SETCOLUMNWIDTH message (see later). Note: A list box with the LBS_MULTICOLUMN style cannot scroll vertically and it ignores any WM_VSCROLL messages it receives.

LBS_MULTIPLESEL: This style turns string selection on or off each time the user clicks or double-clicks a string in the list box. The user can select any number of strings.

LBS_NODATA: This style specifies a no-data list box. Specify this style when the count of items in the list box will exceed one thousand. A no-data list box must also have the LBS_OWNERDRAWFIXED style, but must not have the LBS_SORT or LBS_HASSTRINGS style. There is more to this style, which I will not address in this series; consult some other document for that.

LBS_NOINTEGRALHEIGHT: Normally, the operating system sizes a list box so that the list box does not display partial items. This style specifies that the size of the list box is exactly the size specified by the application when it created the list box with the CreateWindowEx function.

LBS_NOREDRAW: This style specifies that the list box’s appearance is not updated when changes are made. To change the redraw state of the control, use the WM_SETREDRAW message.

LBS_NOSEL: This style specifies that the list box contains items that can be viewed but not selected.

LBS_NOTIFY: This style causes the list box to send a notification code to the parent window whenever the user clicks a list box item (LBN_SELCHANGE), double-clicks an item (LBN_DBLCLK), or cancels the selection (LBN_SELCANCEL).

LBS_SORT: This style sorts strings (items) in the list box alphabetically (watch out for the character set).

LBS_STANDARD: This style combines the LBS_NOTIFY, LBS_SORT, WS_VSCROLL, and WS_BORDER styles. The parent window receives a notification message whenever the user clicks a list box item, double-clicks an item, or cancels the selection. The list box has a vertical scroll bar, and it has borders on all sides.

LBS_USETABSTOPS: This style enables a list box to recognize and expand (display) tab characters when drawing its strings (items). You can use the LB_SETTABSTOPS message to specify tab stop positions. The default tab positions are 32 dialog template units (see later) apart. Dialog template units are the device-independent units used in dialog box templates.

That is it for this part of the series. We stop here and continue in the next part.

Chrys

To arrive at any of the parts of this series, just type the corresponding title below in the Search Box of this page and click Search (use menu if available):

Static Control Styles
Windows List Box
Windows List Box Styles
Windows List Box Notifications
Windows List Box Messages
Creating a List Box
List Box Functions
 

Share.

About Author

Leave A Reply