Static Class

 

 

About Static Class

 

Static class is mainly used for creating and managing static controls.

 

Static Class Methods

 

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

 

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

 

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

 

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

ulong StaticIndex: zero-based index of the static control.

 

Static.SetBitmap( long StaticHandle, long BitmapHandle ) associates a new bitmap with a static control. The return value is a handle to the image previously associated with the static control, if any; otherwise, it is 0. (This method only works on static controls with SS_BITMAP style)

long StaticHandle: static control handle.
long BitmapHandle: bitmap handle.

 

Static.GetBitmap( long StaticHandle ) returns a handle to the bitmap associated with a static control. (This method only works on static controls with SS_BITMAP style)

long StaticHandle: static control handle.

 

Static.SetCursor( long StaticHandle, long CursorHandle ) associates a new cursor with a static control. The return value is a handle to the image previously associated with the static control, if any; otherwise, it is 0. (This method only works on static controls with SS_ICON style)

long StaticHandle: static control handle.
long CursorHandle: cursor handle.

 

Static.GetCursor( long StaticHandle ) returns a handle to the cursor associated with a static control. (This method only works on static controls with SS_ICON style)

long StaticHandle: static control handle.

 

Static.SetIcon( long StaticHandle, long IconHandle ) associates a new icon with a static control. The return value is a handle to the image previously associated with the static control, if any; otherwise, it is 0. (This method only works on static controls with SS_ICON style)

long StaticHandle: static control handle.
long IconHandle: icon handle.

 

Static.GetIcon( long StaticHandle ) returns a handle to the icon associated with a static control. (This method only works on static controls with SS_ICON style)

long StaticHandle: static control handle.

 

Static.SetClicked( long StaticHandle, bool Clicked ) sets the click state of a static control.

long StaticHandle: static control handle.
bool Clicked: sets the static control as clicked (true) or not (false).

 

Static.GetClicked( long StaticHandle ) returns true if the user clicks on the given static control or false otherwise. (This method only works on static controls with SS_NOTIFY style)

long StaticHandle: static control handle.

 

Static.SetDoubleClicked( long StaticHandle, bool DoubleClicked ) sets the double click state of a static control.

long StaticHandle: static control handle.
bool DoubleClicked: sets the static control as double clicked (true) or not (false).

 

Static.GetDoubleClicked( long StaticHandle ) returns true if the user double clicks on the given static control or false otherwise. (This method only works on static controls with SS_NOTIFY style)

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

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 static control has been clicked
if(Static.GetClicked(StaticHandle))
{
Debug.Log("STATIC CLICKED!");
}

//Checks if the specified static control has been double clicked
if(Static.GetDoubleClicked(StaticHandle))
{
Debug.Log("STATIC DOUBLE CLICKED!");
}

}

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

}

 

Comments are closed.