                                       ListBoxes

--Intro

This is going to deal with listboxes, and I do not mean _AOL_Listbox and
_AOL_Combobox, I mean VB's listboxes, and _AOL_Tree type listboxes, because
if you have ever played around with _AOL_Listbox and combobox, the thing
described here do not work on them.


--VB's ListBox Controll

You can find all of this information in VB's help file if you search for
listbox, but it seems people cannot look in the help file before they start
asking questions about things like listboxes, and maybe some people just do
not understand, but I am still going to write this so I don't get a hundred
mails asking how to do things like add an item to a listbox

--Properties of a VB ListBox

This section will cover the basics of a listbox's properties that are in the
properties window.

Columns- you can change the number of columns to have in a listbox with this
property, which lets you have multiple listitems next to each other.

MultiSelect- Multiselect lets the user select multiple items in a listbox.
You can change this to none, simple, or extended.  None is just like a normal
listbox, and you can only select one item.  Simple lets you click on
multiplae ones, and they will stay highlited.  Extended lets you hold down
the shift button and select all the items from where the the first selection
was to where you click with the shift key down (an example of this is AOL's
mail window).

Sorted- This is used to make the list in alphabetical order, alphabetized if
sorted, normal if not sorted.


--Ways to deal with your own listboxes

If you are working with your own listboxes, there are many ways you can
additems to it, take them away, change certain items and so on.  These are
some of the things you can do with it.

List property-  You can change the text of any entry in a listbox by doing
something like this:
List1.List(0)

Text property-  You can get the text from the selected item in a listbox by
using the text property like so:

If List1.Text = "kewl" then
     Msgbox "You selected the listitem containing the caption of " &
list1.text
End If

Note:  The text property is read only, because it is the text of the entry in
the listbox the user has selected, so don't try and set it.  If you have a
listbox with any sort of multiple selection, the text property will be the
text of the last selected item.

ListIndex-  The ListIndex property is used to determine the number of the
currently selected item, like say, if the user selected the first item in a
listbox, the ListIndex would be 0.

Note:  The ListIndex starts at 0, and the first entry is 0

ListCount-  The ListCount property is used to get the current listcount of a
listbox, and remember ListBox's start at 0.

-Selected  The Selected property is used to find out if a listitem is
selected or not (it can is  read only)

-Clear  Use the clear property to clear the contents of a ListBox.


Now that we are past the VB listbox stuff, we will move into the capabilities
of listboxes when using API.

--Adding/Deleting items to a listbox using API

To add items to a listbox, you can use LB_ADDSTRING which will add an item to
the listbox, which if you are in your own application, you can also use the
Additem property.  When using LB_ADDSTRING you would have 0 for the wParam,
and the address of a String Buffer in the lParam.  To delete an item in a
listbox, you can send it a LB_DELETESTRING message with the number of the
entry to delete for the wParam and 0 for the lParam.


--Finding listbox items and selecting listbox items

To find a listbox item, you can use LB_FINDSTRING, which will look for a
string that has the same prefix as what is in lParam.  Send this message with
the number number to start searching from in the wParam and the address of a
string buffer with the prefix in which to search for in the lParam. 

You can also use LB_FINDSTRINGEXACT, which will find the exact string you are
looking for in a listbox.  If you use LB_FINDSTRINGEXACT, it looks for the
entire string which is in the lParam, and the search is NOT case sensitive.

LB_GETCURSEL may be used to get the text of the currently selected listbox
item.  
Note:  do NOT send this message to mulyi-select controlls.

LB_GETSEL can be used to determine if the item specified in the wParam is
selected or not.

LB_GETSELCOUNT this findsout how many items in a multi select listbox are
selected.

LB_GETSELITEMS retrieves all of the entry numbers of the selected items.  To
use this, you must give it an integer array to fill with the entry numbers,
so do something like the example below:
ReDim IntArray(10) as Integer
SendMessage(List1.hWnd, LB_GETSELITEMS, 10, IntArray(0))
Note:  Make sure to make the integer array atleast as high as the number
passed in the wParam.

LB_GETTEXTLEN  gets the length of the listbox entry specified in the wParam,
which is useful when making a string buffer for sending a LB_GETTEXT

LB_GETTEXT retrieves the text from the listbox entry passed in the wParam.
for the lParam give it the address of a string buffer

LB_INSERTSTRING  will insert a string at the space specified by the wParam
(-1 to set at last position, 0 for first)
Note:  this has no regard for sorted listboxes

LB_RESETCONTENT will clear the listbox

LB_SELECTSTRING will select a string with the prefix specified by a string
buffer in the lParam, it is not case sensitive

LB_SELITEMRANGE will select multiple entries in a multiselect listbox.
wParam is nonzero to select items, 0 to deselect.  The low 16 bits of the
lParam is the first entry, and the heigh being the last entry.

LB_SETCURSEL  is used to make selections in single selection listboxes.
Note:  Do NOT send it to a multiselect controll

LB_SETTOPINDEX scrolls the listbox untill the number in the wParam is at the
top of the listbox window, or as close to it as it can be.


--Summary

With this information, you should be able to do almost anything with a
listbox, except get a string from _AOL_Listbox or _AOL_Combobox windows.
