|
Listbox control help
Function help:
Real API_Listbox_Create (Real Parent Handle, Real X, Real Y, Real Width, Real Height, Real Style Flags, Real Extended Style Flags);
This function creates a new list box control.
Argument list:
(0) Parent Handle: Identifies the window handle of the window to create this control on.
(1) X: The horizontal position of the control in pixels, relative to the parent window.
(2) Y: The vertical position of the control in pixels, relative to the parent window.
(3) Width: The horizontal size of the control in pixels.
(4) Height: The vertical size of the control in pixels.
(5) Style Flags: The style flags, supports the Global Control Styles and the following styles:
LBS_DISABLENOSCROLL
Shows a disabled vertical scroll bar for the list box when the 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.
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.
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_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_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_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.
Style flags can be separated by a bitwise or '|' operator.
(6) Extended Style Flags: This can be any combination of the Global Extended Control Styles.
Return value:
If this function succeeds, it returns the Control ID of the control, otherwise it returns 0.
Real API_Listbox_AddString ( Real Control ID, String Text )
This function adds a string to the end of the list box.
Return value:
If this function succeeds, it returns the zero based index ( 0 = the first item) of the string, otherwise, it returns -1.
Real API_Listbox_DeleteString ( Real Control ID, Real String Index )
This function deletes a string from a list box.
Return value:
If this function succeeds, it returns the number of strings left in the list box, otherwise, it returns -1.
Real API_Listbox_FindString ( Real Control ID, String Keyword)
This function searches a list box using a string.
Return value:
If a string is found, it returns the zero based index ( 0 = the first item ) of the string, otherwise, it returns -1.
Real API_Listbox_GetCount ( Real Control ID )
This function returns the number of strings inside the list box.
Return value:
If this function succeeds, it returns the number of items inside the list box, otherwise it returns -1.
String API_Listbox_GetText ( Real Control ID , Real String index)
This function returns the number of strings inside the list box.
Return value:
If this function succeeds, it returns the text of the string, otherwise it returns an empty string ("").
Real API_Listbox_SetSel ( Real Control ID , Real String Index )
Changes the selection to the specified string.
Return value:
If this function succeeds, it returns true (1), otherwise it returns false (0).
Real API_Listbox_GetSel ( Real Control ID)
Returns the zero based index of the selected string.
Return value:
If this function succeeds, it returns the zero based index, otherwise it returns -1.
Real API_Listbox_ResetContent ( Real Control ID)
Removes all strings from the list box.
Return value:
If this function succeeds, it returns true (1), otherwise it returns false (0).
Real API_Listbox_GetSelected ( Real Control ID, Real Zero Based String Index)
This function returns wether a specified item is selected in a multiple-selection list box.
Only works when the LBS_EXTENDEDSEL style or the LBS_MULTIPLESEL is specified.
Return value:
When the item is selected, it returns 1, otherwise it returns 0.
Real API_Listbox_SetSelected ( Real Control ID, Real Zero Based String Index, Real Is Selected )
This function sets wether a specified item is selected in a multiple-selection list box.
Set argument2 to 1 to make the item selected, set argument2 to 0 to make the item not selected.
Only works when the LBS_EXTENDEDSEL style or the LBS_MULTIPLESEL is specified.
Return value:
If this function succeeds, it returns true (1), otherwise it returns false (0).
Real API_Listbox_GetSelCount ( Real Control ID)
This function returns the number of items selected
in a multiple-selection list box.
Only works when the LBS_EXTENDEDSEL style or the LBS_MULTIPLESEL is specified.
Return value:
When succesful, it returns the number of selected items, or -1 when failed.
Real API_Listbox_GetSelItem ( Real Control ID, Real Zero Based Selection number, Real Is The first item )
This function returns the string number of the selected item.
Use 1 for argument2 when you are checking the selection for the first time ( the first item).
Only works when the LBS_EXTENDEDSEL style or the LBS_MULTIPLESEL is specified.
Return value:
Returns the zero based item number.
Items = API_Listbox_GetSelCount (Listbox1);
Current = 0;
while ( Current < Items )
{
if (Current == 0)
Item [Current+1] = API_Listbox_GetSelItem (Listbox1,Current,1);
else
Item [Current+1] = API_Listbox_GetSelItem (Listbox1,Current,0);
Current += 1;
} |
is
Secondary check commands for list boxes:
LBN_KILLFOCUS - The list box loosed focus.
LBN_SETFOCUS - The list box gained focus.
LBN_DBLCLK - The user double clicks a string in the list box. LBS_NOTIFY must be specified.
LBN_SELCANCEL - The user cancels selecting a string. LBS_NOTIFY must be specified.
LBN_SELCHANGE- The selection changed. LBS_NOTIFY must be specified.
Example:
Command = API_Check_Command (1);
if ( Command == Listbox1 )
{
Sel = API_Listbox_GetSel ( Listbox1 );
show_message ("The selection of Listbox1 changed to "+string (Sel));
} |
Example code:
Listbox1 = API_Listbox_Create (Win,300,30,100,20,0,WS_EX_CLIENTEDGE);
API_Listbox_AddString (Listbox1,"String 0");
API_Listbox_AddString (Listbox1,"String 1 ");
API_Listbox_SetSel (Listbox1,0); |
is
Return to help index
|
|