|
Combobox control help
A combo box combines an edit box or static text and a list.
Function help:
Real API_Combobox_Create (Real Parent Handle, Real X, Real Y, Real Width, Real Height, Real Style Flags, Real Extended Style Flags);
This function creates a new combo 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:
CBS_AUTOHSCROLL
Automatically scrolls the text in an edit control to the right when the user types a character at the end of the line. If this style is not set, only text that fits within the rectangular boundary is allowed.
CBS_DISABLENOSCROLL
Shows a disabled vertical scroll bar in the list box when the box does not contain enough items to scroll. Without this style, the scroll bar is hidden when the list box does not contain enough items.
CBS_DROPDOWN
Similar to CBS_SIMPLE, except that the list box is not displayed unless the user selects an icon next to the edit control.
CBS_DROPDOWNLIST
Similar to CBS_DROPDOWN, except that the edit control is replaced by a static text item that displays the current selection in the list box.
CBS_HASSTRINGS
Specifies that an combo box contains items consisting of strings.
CBS_LOWERCASE
Converts to lowercase all text in both the selection field and the list.
CBS_NOINTEGRALHEIGHT
Specifies that the size of the combo box is exactly the size specified by the application when it created the combo box. Normally, the system sizes a combo box so that it does not display partial items.
CBS_SIMPLE
Displays the list box at all times. The current selection in the list box is displayed in the edit control.
CBS_SORT
Automatically sorts strings added to the list box.
CBS_UPPERCASE
Converts to uppercase all text in both the selection field and the list.
Style flags can be separated by a bitwise or '|' operator.
To create a default combobox, use CBS_HASSTRINGS|CBS_DROPDOWNLIST as style flags.
(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_Combobox_AddString ( Real Control ID, String Text )
This function adds a string to the end of the combo 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_Combobox_DeleteString ( Real Control ID, Real String Index )
This function deletes a string from a combobox.
Return value:
If this function succeeds, it returns the number of strings left in the combobox, otherwise, it returns -1.
Real API_Combobox_FindString ( Real Control ID, String Keyword)
This function searches a combobox 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_Combobox_GetCount ( Real Control ID )
This function returns the number of strings inside the combobox.
Return value:
If this function succeeds, it returns the number of items inside the comobobx, otherwise it returns -1.
String API_Combobox_GetText ( Real Control ID , Real String index)
This function returns the number of strings inside the combobox.
Return value:
If this function succeeds, it returns the text of the string, otherwise it returns an empty string ("").
Real API_Combobox_LimitText ( Real Control ID , Real Max Text Length )
Limits the length of the text the user may type into the edit control of a combo box.
If the combo box does not have the CBS_AUTOHSCROLL style, setting the text limit to be larger than the size of the edit control has no effect.
The CB_LIMITTEXT message limits only the text the user can enter. It has no effect on any text already in the edit control when the message is sent, nor does it affect the length of the text copied to the edit control when a string in the list box is selected.
The default limit to the text a user can enter in the edit control is 30,000.
Setting the Max Text Length to zero limits the text to 2147483646.
Return value:
If this function succeeds, it returns true (1), otherwise it returns false (0).
Real API_Combobox_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_Combobox_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_Combobox_ResetContent ( Real Control ID)
Removes all strings from the combo box.
Return value:
If this function succeeds, it returns true (1), otherwise it returns false (0).
Secondary check commands for combo boxes:
CBN_CLOSEUP - The list box is closed. ( Does not work with CBS_SIMPLE )
CBN_DBLCLK - The list box is closed. ( Only works with CBS_SIMPLE )
CBN_DROPDOWN- The list box is about to show. (only CBS_DROPDOWN or CBS_DROPDOWNLIST)
CBN_EDITCHANGE - The text in the edit control changed. (Does not work with CBS_DROPDOWNLIST)
CBN_EDITUPDATE - The text of the edit control is altered. (Does not work with CBS_DROPDOWNLIST)
CBN_KILLFOCUS - The combo box loosed focus.
CBN_SELCHANGE - The selection changed.
CBN_SELENDCANCEL - The user cancelled the selection.
CBN_SELENDOK- The user selected something.
CBN_SETFOCUS - The combo box gained focus.
Example:
Command = API_Check_Command (1);
if ( Command == Combobox1 )
{
Second = API_Check_SecondaryCommand (1);
if ( Second == CBN_SELCHANGE)
{
Sel = API_Combobox_GetSel ( Combobox1 );
show_message ("The selection of Combobox1 changed to "+string (Sel));
}
} |
Example code:
Combobox1 = API_Combobox_Create (Win,300,30,100,20,CBS_HASSTRINGS|CBS_DROPDOWNLIST);
API_Combobox_AddString (Combobox1,"String 0");
API_Combobox_AddString (Combobox1,"String 1 ");
API_Combobox_SetSel (Combobox1,0); |
is
Return to help index
|
|