List Box – Giavapps Windows API

 

 

api_listbox_create(ParentHandle, X, Y, W, H, Flags, ExFlags) This function creates a list box.

ParentHandle: parent handle.
X: x coordinate.
Y: y coordinate.
W: width.
H: height.
Flags: Flags of the control. Flags must be separated with the symbol "|".
ExFlags: extended flags of the control. Flags must be separated with the symbol "|".

 

Flags

 

This control supports the Window Styles and you can specify any of the styles listed below:

 

LBS_DISABLENOSCROLL Shows a disabled horizontal or vertical scroll bar when the list box does not contain enough items to scroll. If you do not specify this style, the scroll bar is hidden when the list box does not contain enough items. This style must be used with the WS_VSCROLL or WS_HSCROLL style.

LBS_EXTENDEDSEL Allows multiple items to be selected by using the SHIFT key and the mouse or special key combinations.

LBS_HASSTRINGS Specifies that a list box contains items consisting of strings. By default, all list boxes except owner-drawn list boxes have this style. You can create an owner-drawn list box either with or without this style.

LBS_MULTIPLESEL Turns string selection on or off each time the user clicks or double-clicks a string in the list box. The user can select any number of strings.

LBS_NODATA Specifies a no-data list box. Specify this style when the count of items in the list box will exceed one thousand. A no-data list box must also have the LBS_OWNERDRAWFIXED style, but must not have the LBS_SORT or LBS_HASSTRINGS style.

LBS_NOINTEGRALHEIGHT Specifies that the size of the list box is exactly the size specified by the application when it created the list box. Normally, the system sizes a list box so that the list box does not display partial items.

LBS_NOREDRAW Specifies that the list box’s appearance is not updated when changes are made.

LBS_NOSEL Specifies that the list box contains items that can be viewed but not selected.

LBS_NOTIFY Notifies the parent window with an input message whenever the user clicks or double-clicks a string in the list box.

LBS_OWNERDRAWFIXED Specifies that the owner of the list box is responsible for drawing its contents and that the items in the list box are the same height.

LBS_OWNERDRAWVARIABLE Specifies that the owner of the list box is responsible for drawing its contents and that the items in the list box are variable in height.

LBS_SORT Sorts strings in the list box alphabetically.

LBS_STANDARD Sorts strings in the list box alphabetically. The parent window receives an input message whenever the user clicks or double-clicks a string. The list box has borders on all sides.

LBS_USETABSTOP Enables a list box to recognize and expand tab characters when drawing its strings.

LBS_WANTKEYBOARDINPUT This enables an application to perform special processing on the keyboard input.

 

Extended Flags

 

This control supports the Extended Window Styles.

 

Return Value

 

If the function succeeds, the return value is a handle to the new list box.

If the function fails, the return value is false.

To get extended error information, call api_control_get_last_error().

 

Control Functions

 

api_listbox_add_item(ListBoxHandle, ItemIndex, ItemText) Adds a string to a list box at the specified location. The return value is the zero-based index of the string in the list.

ListBoxHandle: it must be a ListBoxHandle.
ItemIndex: the zero-based index at which to insert the string, or –1 to add it to the end of the list.
ItemText: string to add.

 

api_listbox_get_item(ListBoxHandle, ItemIndex) Returns a string from a list box.

ListBoxHandle: it must be a ListBoxHandle.
ItemIndex: the zero-based index of the item.

 

api_listbox_set_item_selection(ListBoxHandle,ItemIndex) Selects an item and scrolls it into view, if necessary. When the new item is selected, the list box removes the highlight from the previously selected item.

ListBoxHandle: it must be a ListBoxHandle.
ItemIndex: the zero-based index of the item.

 

api_listbox_get_item_selection(ListBoxHandle) Returns the ItemIndex of the currently selected item in a single-selection list box. The function returns -1 if there is no selection.

ListBoxHandle: it must be a ListBoxHandle.

 

api_listbox_set_item_multi_selection(ListBoxHandle, ItemIndex, Selected) Selects an item in a multiple-selection list box and, if necessary, scrolls the item into view.

ListBoxHandle: it must be a ListBoxHandle.
ItemIndex: the zero-based index of the item.
Selected: specifies how to set the selection. If this parameter is true, the item is selected and highlighted., if it is false, the highlight is removed and the item is no longer selected.

 

api_listbox_get_item_multi_selection(ListBoxHandle, ItemIndex) If an item is selected, the return value is true, otherwise, it is false.

ListBoxHandle: it must be a ListBoxHandle.
ItemIndex: the zero-based index of the item.

 

api_listbox_get_item_selection_count(ListBoxHandle) Returns the total number of selected items in a multiple-selection list box.

ListBoxHandle: it must be a ListBoxHandle.

 

api_listbox_get_item_count(ListBoxHandle) Returns the number of items in the list box.

ListBoxHandle: it must be a ListBoxHandle.

 

api_listbox_set_item_size(ListBoxHandle, Width, Height) Sets the size of all items in a list box.

ListBoxHandle: it must be a ListBoxHandle.
Width: the width, in pixels, of all columns in a multiple-column list box.
Height: the height, in pixels, of all items in a list box.

 

api_listbox_get_item_width(ListBoxHandle) Returns the width of all the items in a list box.

ListBoxHandle: it must be a ListBoxHandle.

 

api_listbox_get_item_height(ListBoxHandle) Returns the height of all the items in a list box.

ListBoxHandle: it must be a ListBoxHandle.

 

api_listbox_delete_item(ListBoxHandle, ItemIndex) Deletes the item at the specified location in a list box. The return value is a count of the strings remaining in the list.

ListBoxHandle: it must be a ListBoxHandle.
ItemIndex: the zero-based index of the item.

 

api_listbox_reset(ListBoxHandle) Removes all items from a list box.

ListBoxHandle: it must be a ListBoxHandle.

 

Code Examples

 

Creating a List Box

 

listbox = api_listbox_create(window,10,10,200,200,WS_VISIBLE | WS_CHILD | WS_BORDER | WS_VSCROLL,0);

 

Adding Items

 

item1 = api_listbox_add_item(listbox,-1,“Item 1”);
item2 = api_listbox_add_item(listbox,-1,“Item 2”);
item3 = api_listbox_add_item(listbox,-1,“Item 3”);

 

Deleting Items

 

api_listbox_delete_item(listbox,item2);

 

I am Luigi Piscopo, also known as DJ GiDeejay / Producer / Remixer in the music world. I am a Producer with a lot of experience in photo editing, video editing, audio editing, graphic design, web design, programming and promotion.

Leave a Reply

Il tuo indirizzo email non sarà pubblicato. I campi obbligatori sono contrassegnati *

*