Combo Box – Giavapps Windows API

 

 

api_combobox_create(ParentHandle, X, Y, W, H, Flags, ExFlags) This function creates a combo 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:

 

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 owner-drawn 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_OEMCONVERT Converts text entered in the combo box edit control from the Windows character set to the OEM character set and then back to the Windows character set. This style is most useful for combo boxes that contain file names and applies only to combo boxes created with the CBS_SIMPLE or CBS_DROPDOWN style.

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

CBS_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.

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.

 

Extended Flags

 

This control supports the Extended Window Styles.

 

Return Value

 

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

If the function fails, the return value is false.

To get extended error information, call api_control_get_last_error().

 

Control Functions

 

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

ComboBoxHandle: it must be a ComboBoxHandle.
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_combobox_get_item(ComboBoxHandle, ItemIndex) Returns a string from a list in a combo box.

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

 

api_combobox_set_item_selection(ComboBoxHandle, ItemIndex) Sets the currently selected item in a combo box.

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

 

api_combobox_get_item_selection(ComboBoxHandle) Returns a zero-based index of the currently selected item in a combo box.

ComboBoxHandle: it must be a ComboBoxHandle.

 

api_combobox_get_item_count(ComboBoxHandle) Returns the number of items in the list box of a combo box.

ComboBoxHandle: it must be a ComboBoxHandle.

 

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

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

 

api_combobox_reset(ComboBoxHandle) Removes all items from a list in a combo box.

ComboBoxHandle: it must be a ComboBoxHandle.

 

api_combobox_set_dropdown(ComboBoxHandle, DropDownState) Specifies whether the drop-down list box is to be shown or hidden.

ComboBoxHandle: it must be a ComboBoxHandle.
DropDownState: A value of true shows the list box; a value of false hides it.

 

api_combobox_get_dropdown(ComboBoxHandle) Determines whether the list box of a combo box is dropped down. If the list box is visible, the return value is true; otherwise, it is false.

ComboBoxHandle: it must be a ComboBoxHandle.

 

api_combobox_set_edit_text_limit(ComboBoxHandle, TextLimit) Limits the length of the text the user may type into the edit control of a combo box.

ComboBoxHandle: it must be a ComboBoxHandle.
TextLimit: maximun number of characters allowed for the edit control of the specified combo box.

 

api_combobox_set_edit_selection(ComboBoxHandle, StartingPosition, EndingPosition) select characters in the edit control of a combo box.

ComboBoxHandle: it must be a ComboBoxHandle.
StartingPosition: the starting position. If the StartingPosition is –1, the selection, if any, is removed.
EndingPosition: the ending position. If the EndingPosition is –1, all text from the starting position to the last character in the edit control is selected.

 

api_combobox_get_edit_selection(ComboBoxHandle, StartingOrEndingPosition) Gets the starting and ending character positions of the current selection in the edit control of a combo box.

ComboBoxHandle: it must be a ComboBoxHandle.
StartingOrEndingPosition: the function returns the starting position (false) or the ending position (true).

 

api_combobox_get_modified(ComboBoxHandle) Returns true when the user changes the current selection in the list box of a combo box or false otherwise. The user can change the selection by clicking in the list box or by using the arrow keys.

ComboBoxHandle: it must be a ComboBoxHandle.

 

Code Examples

 

Creating a Simple Combo Box

 

combobox = api_combobox_create(window,10,10,100,100,WS_VISIBLE|WS_CHILD|CBS_SIMPLE,0);

 

Adding Items

 

item1 = api_combobox_add_item(combobox,-1,“Item 1”);
item2 = api_combobox_add_item(combobox,-1,“Item 2”);
item3 = api_combobox_add_item(combobox,-1,“Item 3”);

 

Deleting Items

 

api_combobox_delete_item(combobox,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 *

*