Home   Index   About
Ultimate Pack


Custom Search
Messages to List Boxes

A dialog box procedure can send messages to a list box to add, delete, examine, and change list box items. For example, a dialog box procedure could send an LB_ADDSTRING message to a list box to add an item, and an LB_GETSEL message to determine whether the item is selected. Other messages set and retrieve information about the size, appearance, and behavior of the list box. For example, the LB_SETHORIZONTALEXTENT message sets the scrollable width of a list box. A dialog box procedure can send any message to a list box by using the SendMessage or SendDlgItemMessage function.

A list box item is often referenced by its index, an integer that represents the item's position in the list box. The index of the first item in a list box is 0, the index of the second item is 1, and so on.

The following table describes how the predefined list box procedure responds to list box messages.

Message
Response
LB_ADDFILE
Inserts a file into a directory list box filled by the DlgDirList function and retrieves the list box index of the inserted item.
LB_ADDSTRING
Adds a string to a list box and returns its index.
LB_DELETESTRING
Removes a string from a list box and returns the number of strings remaining in the list.
LB_DIR
Adds a list of filenames to a list box and returns the index of the last filename added.
LB_FINDSTRING
Returns the index of the first string in the list box that matches a given prefix.
LB_FINDSTRINGEXACT
Returns the index of the string that is equivalent to or prefixed by a given prefix.
LB_GETANCHORINDEX
Returns the index of the item that the mouse last selected.
LB_GETCARETINDEX
Returns the index of the item that has the focus rectangle.
LB_GETCOUNT
Returns the number of items in the list box.
LB_GETCURSEL
Returns the index of the currently selected item.
LB_GETHORIZONTALEXTENT
Returns the scrollable width, in pixels, of a list box.
LB_GETITEMDATA
Returns the 32-bit value associated with the given item.
LB_GETITEMHEIGHT
Returns the height, in pixels, of an item in a list box.
LB_GETITEMRECT
Retrieves the client coordinates of the given list box item.
LB_GETLOCALE
Retrieves the locale of the list box. The high-order word contains the country code and the low-order word contains the language identifier.
LB_GETSEL
Returns the selection state of a list box item.
LB_GETSELCOUNT
Returns the number of selected items in a multiple-selection list box.
LB_GETSELITEMS
Creates an array of the indexes of all selected items in a multiple-selection list box and returns the total number of selected items.
LB_GETTEXT
Retrieves the string associated with a given item and the length of the string.
LB_GETTEXTLEN
Returns the length, in characters, of the string associated with a given item.
LB_GETTOPINDEX
Returns the index of the first visible item in a list box.
LB_INITSTORAGE
Allocates memory for the specified number of items and their associated strings.
LB_INSERTSTRING
Inserts a string at a given index in a list box.
LB_ITEMFROMPOINT
Retrieves the zero-based index of the item nearest the specified point in a list box.
LB_RESETCONTENT
Removes all items from a list box.
LB_SELECTSTRING
Selects the first string it finds that matches a given prefix.
LB_SELITEMRANGE
Selects a given range of items in a list box.
LB_SELITEMRANGEEX
Selects a given range of items if the index of the first item in the range is less than the index of the last item in the range. Cancels the selection in the range if the index of the first item is greater than the last.
LB_SETANCHORINDEX
Sets the item that the mouse last selected to a given item.
LB_SETCARETINDEX
Sets the focus rectangle to a given list box item.
LB_SETCOLUMNWIDTH
Sets the width, in pixels, of all columns in a list box.
LB_SETCOUNT
Sets the number of items in a list box.
LB_SETCURSEL
Selects a given list box item.
LB_SETHORIZONTALEXTENT
Sets the scrollable width, in pixels, of a list box.
LB_SETITEMDATA
Associates a 32-bit value with a list box item.
LB_SETITEMHEIGHT
Sets the height, in pixels, of an item or items in a list box.
LB_SETLOCALE
Sets the locale of a list box and returns the previous locale identifier.
LB_SETSEL
Selects an item in a multiple-selection list box.
LB_SETTABSTOPS
Sets the tab stops to those specified in a given array.
LB_SETTOPINDEX
Scrolls the list box so the specified item is at the top of the visible range.


Last news from Greatis Software

Nostalgia .Net     Nostalgia .Net     .Net is powerful, but not all-powerful, so sometimes we need to use Win32 API for our .Net applications. It's simple enough with Platform Invoke if you have Win32 skill, but we do not always have time to dig the ancient documentation, declare the special types that are compatible with Win32, find the values of the Win32's constants and so on. Nostalgia .Net offers several simple-to-use classes, and components that will allow you to forget about the headache of Win32 and just use the power of Win32 in your application the same way as you use the native. Net classes.  More »

Recommended software for developers

Ultimate Pack for Delphi and C++ Builder     Ultimate Pack     Component pack for Delphi and C++ Builder that contains runtime form designer, runtime object inspector, print suite and much more for the very special price.  More »

Form Designer .Net     Form Designer .Net     Unique runtime form design solution that allows to edit any form in .Net WinForms application at runtime with full source codes for only 300 euro!  More »

Print Suite .Net     Print Suite .Net     Print Suite .Net is a set of components for easy printing texts, images and grids from your WinForms applications. Full C# source codes are available  More »

Gradient Controls .Net     Gradient Controls .Net     Gradient Controls .Net offers controls with gradient background feature. Labels, panels and so on... Full C# source codes are available  More »

iGrid     Greatis iGrid     iGrid plots drawing grid right over your desktop, so you can use it everywhere, with any drawing application without any special plugins for different graphic editors.  More »


All the contacts and projects

Dmitry Vasiliev (just.dmitry)

Related Links

Software for Visual Studio .NET developers
Software for Delphi and C++ Builder developers
Software for Visual Basic 6 developers
Delphi Tips&Tricks
MegaDetailed.NET

More Online Helps

Win32 Programmer's Reference
Win32 Multimedia Programmer's Reference
OLE Programmer's Reference
Microsoft Windows Pen API Programmer's Reference
Microsoft Windows Sockets 2 Reference
Microsoft Windows Telephony API (TAPI) Programmer's Reference
Unix Manual Pages

Free Tech Secrets ;) Copyright © 2008-2012 Free Tech Secrets ;) greatis just4fun network just4fun