List Box and Combo Box Capacity Limits

Last reviewed: July 22, 1997
Article ID: Q67678
3.00 3.10 WINDOWS kbprg

The information in this article applies to:

  • Microsoft Windows Software Development Kit (SDK) for Windows versions 3.0 and 3.1

SUMMARY

In the Microsoft Windows graphical environment, the storage capacity of a list box or combo box is limited by the total amount of text. Each item is stored in memory as a NULL-terminated string.

The maximum amount of memory that a list box or combo box can use to store text depends on the version of Windows in use. In Windows versions 2.x, the amount of free memory in the user module's data segment limits available storage.

Beginning with Windows 3.0, each list box or combo box has its own data segment, which allows it to store 64K of text. If a list box or combo box in an application must store more text, the application can store up to 8160 items in an owner-draw list box or combo box that does not have the LBS_HASSTRINGS list box or CBS_HASSTRINGS combo box style. In this case, the application stores and manages the item text separately.

MORE INFORMATION

An owner-draw list box or owner-draw combo box is limited to 64K of data storage, as are regular (nonowner draw) list boxes and combo boxes. Because the application manages the text when the list box or combo box do not have the LBS_HASSTRINGS or CBS_HASSTRINGS styles, each item in an owner-draw list box or owner-draw combo box require 8 bytes, 4 of which store the application-supplied 32-bit item-identifier value.

The list box (or combo box) uses 256 bytes of the 64K segment for internal storage, and uses the rest for items. This yields room for 8160 items, as follows:

   (64K segment - 256 bytes) / (8 bytes per item)

NOTE: In a list box with the LBS_HASSTRINGS style or combo box with the CBS_HASSTRINGS style, the text pointed to by the pointer passed in the lParam of LB_ADDSTRING or CB_ADDSTRING (or LB_INSERTSTRING or CB_INSERTSTRING) is stored in the list box's or combo box's storage area. An additional 32-bit storage value can be associated with each item with the LB_SETITEMDATA or CB_SETITEMDATA styles.

When the LBS_HASSTRINGS or CBS_HASSTRINGS styles are not present, Windows no longer stores text for the list box or combo box. Instead of storing the text pointed to by the lParam of LB_ADDSTRING or CB_ADDSTRING (or LB_INSERTSTRING or CB_INSERTSTRING), only the 32-bit value itself is stored, thus dramatically reducing the needed storage. When the owner-draw list box or owner-draw combo box receive the WM_DRAWITEM message, it is up to the drawing routine to interpret the 32-bit value.


Additional reference words: 3.00 3.10 listbox combobox list-box combo-box
KBCategory: kbprg
KBSubcategory: UsrCtl
Keywords : kb16bitonly


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: July 22, 1997
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.