windows_programming_notes.nbk: Home | Index | Next Page: Using Messages and Message Queues | Previous Page: Using Edit Controls in a Window


 Using List Box Controls

Abstract

This article is a complete reference for list box controls. It describes all list box control styles, messages, and notifications in more detail than found in the Microsoft® Windows® version 3.x Software Development Kit (SDK) documentation.

Introduction

List box controls display a list of items from which the user can choose one or more items. List box controls can be either single column (one column of choices) or multiple column (one or more columns of choices), single selection (allowing only one item to be selected at a time) or multiple selection (allowing one or more items to be selected at a time).

Limits of List Box Controls

Several factors limit a list box control:

The control structure of a list box and its tab stop settings are allocated from the USER heap. If the USER heap does not have enough free space for these structures, the list box will not be able to operate.

In Microsoft® Windows™ version 3.0, the control structure is 66 bytes in length; in Windows version 3.1, it's 64 bytes in length.

Windows allocates an integer to store the position of each tab stop and an integer to store the number of tab stops.

List boxes store all the strings in the list box in one globally allocated segment. Windows limits the total amount of text in a list box to 64 kilobytes (K). If the average string length in a list box is 100 bytes, for example, the list box will be able to display about 650 strings. Space for strings in a list box is allocated in multiples of 256 bytes.

List boxes maintain information about each item in the list box. Storage space for this information is globally allocated, in multiples of 32 items, and limited to a total of 32K. The following information is kept for each item in a list box:

No individual string item can be greater than 32K in length. The above values lead to the item limits in the following table.

List Box Control Styles

List box controls implement the styles in the sections that follow.

List Box Control Messages

List box controls implement the messages in the sections that follow.

Notification Messages

The parent window of a list box receives notification messages through WM_COMMAND messages.

The wParam parameter specifies the identifier of the list box, and the lParam parameter specifies the handle to the list box in the low-order word and the notification code in the high-order word.

Selection Messages

A list box control sends the following messages to its owner window when the list box has the LBS_WANTKEYBOARDINPUT style.

Owner-Drawn Messages

Windows version 3.1 changed the way the wParam parameter is used in the owner-drawn messages sent from list boxes to their parent windows. In Windows version 3.1 and later, the wParam parameter contains the list box identifier; in earlier versions of Windows, the wParam parameter contained zero.


windows_programming_notes.nbk: Home | Index | Next Page: Using Messages and Message Queues | Previous Page: Using Edit Controls in a Window


Notebook exported on Monday, 7 July 2008, 18:56:50 PM Eastern Daylight Time