LB_INITSTORAGE

This message allocates memory for storing list box items. An application sends this message before adding a large number of items to a list box.

At a Glance

Header file: Winuser.h
Windows CE versions: 1.0 and later

Syntax

LB_INITSTORAGE wParam = (WPARAM)(int) cItems;
lParam = (LPARAM)(DWORD) cb;

Parameters

cItems

Specifies the number of items to add.

Windows 95 and Windows 98: The wParam parameter is limited to 16-bit values. This means list boxes cannot contain more than 32,767 items. Although the number of items is restricted, the total size in bytes of the items in a list box is limited only by available memory.

cb

Specifies the amount of memory, in bytes, to allocate for item strings.

Return Values

The total number of items for which memory has been preallocated—that is, the total number of items added by all successful LB_INITSTORAGE messages—indicates success. LB_ERRSPACE indicates failure.

Windows NT

For Windows NT version 4.0, this message does not allocate the specified amount of memory; however, it always returns the value specified in the cItems parameter. For Windows NT version 5.0, the message allocates memory and returns the success and error values described above.

Remarks

The lParam parameter is unused in Windows CE.

The LB_INITSTORAGE message helps speed up the initialization of list boxes that have a large number of items (more than 100). It reserves the specified amount of memory so that subsequent LB_ADDSTRING, LB_INSERTSTRING, LB_DIR, and LB_ADDFILE messages take the shortest possible time. You can use estimates for the cItems and cb parameters. If you overestimate, the extra memory is allocated; if you underestimate, the normal allocation is used for items that exceed the requested amount.

See Also

LB_ADDSTRING, LB_INSERTSTRING