Button Class

 

 

About Button Class

 

Button class is mainly used for creating and managing buttons.

 

Button Class Methods

 

Button.Create( long ParentHandle, long X, long Y, long Width, long Height, long Style, long ExStyle ) creates a button. 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 button styles.
long ExStyle: the extended style of the control being created. This parameter can be a combination of the extended window styles.

 

Button.Exists( long ButtonHandle ) returns true if the specified control was created with Button.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 ButtonHandle: button handle.

 

Button.Count() returns the total number of controls created with Button.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.

 

Button.GetHandleByIndex( ulong ButtonIndex ) returns the handle from an index if the specified control was created with Button.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. ButtonIndex parameter should be less or equal to Button.Count()-1.

ulong ButtonIndex: zero-based index of the button.

 

Button.SetChecked( long ButtonHandle, long Checked ) sets the check state of a radio button or check box.

long ButtonHandle: button handle.
long Checked: check state.

Checked argument can be one of the following constants.

BST_CHECKED Sets the button state to checked.

BST_INDETERMINATE Sets the button state to grayed, indicating an indeterminate state. Use this value only if the button has the BS_3STATE or BS_AUTO3STATE style.

BST_UNCHECKED
Sets the button state to cleared.

 

Button.GetChecked( long ButtonHandle ) Gets the check state of a radio button or check box.

long ButtonHandle: button handle.

The return value from a button created with the BS_AUTOCHECKBOX, BS_AUTORADIOBUTTON, BS_AUTO3STATE, BS_CHECKBOX, BS_RADIOBUTTON, or BS_3STATE style can be one of the following.

BST_CHECKED Button is checked.

BST_INDETERMINATE Button is grayed, indicating an indeterminate state (applies only if the button has the BS_3STATE or BS_AUTO3STATE style).

BST_UNCHECKED Button is cleared.

 

Button.SetHighlighted( long ButtonHandle, bool Highlighted ) sets the highlight state of a button. The highlight state indicates whether the button is highlighted as if the user had pushed it.

long ButtonHandle: button handle.
bool Highlighted: true to highlight the button; otherwise false.

 

Button.GetState( long ButtonHandle ) Retrieves the state of a button or check box. The return value specifies the current state of the button.

long ButtonHandle: button handle.

The return value is a combination of the following values.

BST_CHECKED The button is checked.

BST_DROPDOWNPUSHED Windows Vista. The button is in the drop-down state. Applies only if the button has the TBSTYLE_DROPDOWN style.

BST_FOCUS The button has the keyboard focus.

BST_HOT The button is hot; that is, the mouse is hovering over it.

BST_INDETERMINATE The state of the button is indeterminate. Applies only if the button has the BS_3STATE or BS_AUTO3STATE style.

BST_PUSHED The button is being shown in the pushed state.

BST_UNCHECKED No special state. Equivalent to zero.

 

Button.SetNote( long ButtonHandle, string Text ) sets the text of the note associated with a specified command link button. (This method only works on buttons with BS_COMMANDLINK or BS_DEFCOMMANDLINK style)

long ButtonHandle: button handle.
string Text: text of the note.

 

Button.GetNote( long ButtonHandle ) gets the text of the note associated with a command link button. (This method only works on buttons with BS_COMMANDLINK or BS_DEFCOMMANDLINK style)

long ButtonHandle: button handle.

 

Button.SetClicked( long ButtonHandle, bool Clicked ) sets the click state of a button.

long ButtonHandle: button handle.
bool Clicked: sets the button as clicked (true) or not (false).

 

Button.GetClicked( long ButtonHandle ) returns true if the user clicks on the given button or false otherwise.

long ButtonHandle: button handle.

 

Button.SetDoubleClicked( long ButtonHandle, bool DoubleClicked ) sets the double click state of a button.

long ButtonHandle: button handle.
bool DoubleClicked: sets the button as double clicked (true) or not (false).

 

Button.GetDoubleClicked( long ButtonHandle ) returns true if the user double clicks on the given button or false otherwise. (This method only works on buttons with BS_NOTIFY style)

long ButtonHandle: button handle.

 

Button.SetDropDownClicked( long ButtonHandle, bool DropDownClicked ) sets the drop down click state of a button.

long ButtonHandle: button handle.
bool DropDownClicked: sets the drop down click state (true) or not (false).

 

Button.GetDropDownClicked( long ButtonHandle ) returns true if the user clicks a drop down arrow on the given button or false otherwise. (This method only works on buttons with BS_SPLITBUTTON or BS_DEFSPLITBUTTON style)

long ButtonHandle: button handle.

 

Button.SetBitmap( long ButtonHandle, long BitmapHandle ) associates a new bitmap with the button. The return value is a handle to the bitmap previously associated with the button, if any; otherwise, it is 0.

long ButtonHandle: button handle.
long BitmapHandle: bitmap handle.

 

Button.GetBitmap( long ButtonHandle ) retrieves a handle to the bitmap associated with the button.

long ButtonHandle: button handle.

 

Button.SetIcon( long ButtonHandle, long IconHandle ) associates a new icon with the button. The return value is a handle to the icon previously associated with the button, if any; otherwise, it is 0.

long ButtonHandle: button handle.
long IconHandle: icon handle.

 

Button.GetIcon( long ButtonHandle ) retrieves a handle to the icon associated with the button.

long ButtonHandle: button 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 ButtonHandle = 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
ButtonHandle = Button.Create(WindowHandle, 10, 10, 150, 32, Constant.WS_VISIBLE | Constant.WS_CHILD, 0);//creates a new button
Control.SetText(ButtonHandle, "Click Me");//Sets a new text for the specified button
}

void Update()
{

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

//Checks if the specified button has been clicked
if(Button.GetClicked(ButtonHandle))
{
Debug.Log("BUTTON CLICKED!");
}

}

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.