ComboBox  Class

 

 

About ComboBox Class

 

ComboBox class is mainly used for creating and managing combo boxes.

 

ComboBox Class Methods

 

ComboBox.Create( long ParentHandle, long X, long Y, long Width, long Height, long Style, long ExStyle ) creates a combo box. If the function succeeds, the return value is a handle to the new control. If the function fails, the return value is 0.

long ParentHandle: a handle to the parent or owner control of the control being created.
long X: x coordinate. You can also use CW_USEDEFAULT constant for this argument.
long Y: y coordinate. You can also use CW_USEDEFAULT constant for this argument.
long Width: width. You can also use CW_USEDEFAULT constant for this argument.
long Height: height. You can also use CW_USEDEFAULT constant for this argument.
long Style: the style of the control being created. This parameter can be a combination of the window styles and combo box styles.
long ExStyle: the extended style of the control being created. This parameter can be a combination of the extended window styles.

 

ComboBox.Exists( long ComboBoxHandle ) returns true if the specified control was created with ComboBox.Create() method and not destroyed yet or false otherwise. Note that all child controls are destroyed when parent control is destroyed. You can also call Control.Destroy() method for destroying a specific control with all of its children.

long ComboBoxHandle: combo box handle.

 

ComboBox.Count() returns the total number of controls created with ComboBox.Create() method and not destroyed yet. Note that all child controls are destroyed when parent control is destroyed. You can also call Control.Destroy() method for destroying a specific control with all of its children.

 

ComboBox.GetHandleByIndex( ulong ComboBoxIndex ) returns the handle from an index if the specified control was created with ComboBox.Create() method and not destroyed yet or 0 otherwise. Note that all child controls are destroyed when parent control is destroyed. You can also call Control.Destroy() method for destroying a specific control with all of its children. ComboBoxIndex parameter should be less or equal to ComboBox.Count()-1.

ulong ComboBoxIndex: zero-based index of the combo box.

 

ComboBox.AddItem( long ComboBoxHandle, long ItemIndex, string 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. If an error occurs, the return value is CB_ERR. If there is insufficient space to store the new string, the return value is CB_ERRSPACE.

long ComboBoxHandle: combo box handle.
long ItemIndex: zero-based index of the item or –1 to add it to the end of the list.
string ItemText: item text.

 

ComboBox.GetItem( long ComboBoxHandle, long ItemIndex ) returns a string from a list in a combo box.

long ComboBoxHandle: combo box handle.
long ItemIndex: zero-based index of the item.

 

ComboBox.GetItemCount( long ComboBoxHandle ) returns the number of items in the list box of a combo box.

long ComboBoxHandle: combo box handle.

 

ComboBox.SetItemSelected( long ComboBoxHandle, long ItemIndex ) sets the currently selected item in a combo box. If an error occurs, the return value is CB_ERR. If the ItemIndex parameter is –1, the return value is CB_ERR even though no error occurred.

long ComboBoxHandle: combo box handle.
long ItemIndex: zero-based index of the item.

 

ComboBox.GetItemSelected( long ComboBoxHandle ) returns the index of the currently selected item in a combo box.

long ComboBoxHandle: combo box handle.

 

ComboBox.DeleteItem( long ComboBoxHandle, long 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. The return value is CB_ERR if the ItemIndex parameter specifies an index greater than the number of items in the list.

long ComboBoxHandle: combo box handle.
long ItemIndex: zero-based index of the item.

 

ComboBox.Reset( long ComboBoxHandle ) removes all items from the list box and edit control of a combo box. Always returns CB_OKAY.

long ComboBoxHandle: combo box handle.

 

ComboBox.SetDropDown( long ComboBoxHandle, long Show ) Shows or hides the list in a combo box.

long ComboBoxHandle: combo box handle.
long Show: shows (true) or hides (false) the dropdown.

 

ComboBox.GetDropDown( long ComboBoxHandle ) returns true if the drop list is visible or false otherwise.

long ComboBoxHandle: combo box handle.

 

ComboBox.SetEditTextLimit( long ComboBoxHandle, long Limit ) limits the length of the text the user may type into the edit control of a combo box.

long ComboBoxHandle: combo box handle.
long Limit: the maximum number of characters.

 

ComboBox.SetEditCueBannerText( long ComboBoxHandle, string Text ) sets the cue banner text that is displayed for the edit control of a combo box. The cue banner is text that is displayed in the edit control of a combo box when there is no selection.

long ComboBoxHandle: combo box handle.
long Text: cue banner text.

 

ComboBox.GetEditCueBannerText( long ComboBoxHandle ) returns the cue banner text displayed in the edit control of a combo box. The cue banner is text that is displayed in the edit control of a combo box when there is no selection. (This method can retrieve up to 256 characters!)

long ComboBoxHandle: combo box handle.

 

ComboBox.SetEditSelection( long ComboBoxHandle, long StartingPosition, long EndingPosition ) select characters in the edit control of a combo box. The positions are zero-based. The first character of the edit control is in the zero position. The first character after the last selected character is in the ending position. For example, to select the first four characters of the edit control, use a starting position of 0 and an ending position of 4.

long ComboBoxHandle: combo box handle.
long StartingPosition: specifies the starting position. If this parameter is –1, the selection, if any, is removed.
long EndingPosition: specifies the ending position. If this parameter is –1, all text from the starting position to the last character in the edit control is selected.

 

ComboBox.GetEditSelection( long ComboBoxHandle, long StartingOrEndingPosition ) returns the starting or ending character positions of the current selection in the edit control of a combo box.

long ComboBoxHandle: combo box handle.
long StartingOrEndingPosition: returns the starting (false) or ending (true) position.

 

ComboBox.SetEditChanged( long ComboBoxHandle, bool Changed ) sets the edit control of a combo box as changed.

long ComboBoxHandle: combo box handle.
bool Changed: sets the edit control of a combo box as changed (true) or not (false).

 

ComboBox.GetEditChanged( long ComboBoxHandle ) returns true after the user has taken an action that may have altered the text in the edit control portion of a combo box or false otherwise.

long ComboBoxHandle: combo box handle.

 

ComboBox.SetSelectionChanged( long ComboBoxHandle, bool Changed ) sets the current selection in the list box of a combo box as changed.

long ComboBoxHandle: combo box handle.
bool Changed: sets the current selection in the list box of a combo box as changed (true) or not (false).

 

ComboBox.GetSelectionChanged( long ComboBoxHandle ) returns true when the user changes the current selection in the list box of a combo box or false otherwise.

long ComboBoxHandle: combo box handle.

 

Code Example

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Giavapps.Windows.API;

public class CodeExample : MonoBehaviour
{

private long WindowHandle = 0;
private long ComboBoxHandle = 0;

void Start()
{
Plugin.Initialize();//Initializes Giavapps Windows API
WindowHandle = Window.Create(0, 100, 100, 400, 400, Constant.WS_VISIBLE | Constant.WS_SYSMENU | Constant.WS_MINIMIZEBOX | Constant.WS_MAXIMIZEBOX | Constant.WS_SIZEBOX, Constant.WS_EX_TOPMOST);//Creates a new window
Control.SetText(WindowHandle, "Giavapps Windows API");//Sets a new title for the specified window
ComboBoxHandle = ComboBox.Create(WindowHandle, 10, 10, 150, 150, Constant.WS_VISIBLE | Constant.WS_CHILD | Constant.CBS_SIMPLE, 0);//Creates a new combo box
ComboBox.AddItem(ComboBoxHandle, –1, "Item "+ComboBox.GetItemCount(ComboBoxHandle));//Adds a new item to the combo box
ComboBox.AddItem(ComboBoxHandle, –1, "Item "+ComboBox.GetItemCount(ComboBoxHandle));//Adds a new item to the combo box
ComboBox.AddItem(ComboBoxHandle, –1, "Item "+ComboBox.GetItemCount(ComboBoxHandle)); //Adds a new item to the combo box
}

void Update()
{

//Checks if the specified window has been closed
if(Window.GetClosed(WindowHandle))
{
Control.Destroy(WindowHandle);//Destroys the specified window
}

//Checks if the edit control of the specified combo box has changed
if(ComboBox.GetEditChanged(ComboBoxHandle))
{
Debug.Log("COMBO BOX EDIT HAS CHANGED!");
}

//Checks if the current selection in the list box of the specified combo box has changed
if(ComboBox.GetSelectionChanged(ComboBoxHandle))
{
Debug.Log("COMBO BOX SELECTION HAS CHANGED!");
}

}

void OnApplicationQuit()
{
Plugin.Deinitialize();//Deinitializes Giavapps Windows API
}

}

 

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.

Comments are closed.