Control Class

 

About Control Class

 

Control class stores global controls functions so you can use these functions on different kind of controls (windows, buttons, combo boxes etc.).

 

Control Class Methods

 

Control.Destroy( long ControlHandle ) this function destroys the specified control. If the function succeeds, the return value is true. If the function fails, the return value is false.

long ControlHandle: any control handle (WindowHandle, ButtonHandle, ComboBoxHandle, etc.).

 

Control.Show( long ControlHandle, long State ) sets the specified control’s show state. If the control was previously visible, the return value is true. If the control was previously hidden, the return value is false.

long ControlHandle: any control handle (WindowHandle, ButtonHandle, ComboBoxHandle, etc.).
long State: controls how the control is to be shown.

State can be one of the following constants.

SW_FORCEMINIMIZE Minimizes a control, even if the thread that owns the control is not responding. This flag should only be used when minimizing controls from a different thread.

SW_HIDE Hides the control or window and activates another control.

SW_MAXIMIZE Maximizes the specified control.

SW_MINIMIZE Minimizes the specified control and activates the next top-level control in the Z order.

SW_RESTORE Activates and displays the control. If the control is minimized or maximized, the system restores it to its original size and position. An application should specify this flag when restoring a minimized control.

SW_SHOW Activates the control and displays it in its current size and position.

SW_SHOWDEFAULT Sets the show state based on the program that started the application.

SW_SHOWMAXIMIZED Activates the control and displays it as a maximized control.

SW_SHOWMINIMIZED Activates the control and displays it as a minimized control.

SW_SHOWMINNOACTIVE Displays the control as a minimized control. This value is similar to SW_SHOWMINIMIZED, except the control is not activated.

SW_SHOWNA Displays the control in its current state. The active control remains active.

SW_SHOWNOACTIVATE Displays a control in its most recent size and position. The active control remains active.

SW_SHOWNORMAL Activates and displays a control. If the control is minimized or maximized, the system restores it to its original size and position. An application should specify this flag when displaying the control for the first time.

 

Control.SetMinimized( long ControlHandle ) minimizes the specified control and activates the next top-level control in the Z order.

long ControlHandle: any control handle (WindowHandle, ButtonHandle, ComboBoxHandle, etc.).

 

Control.GetMinimized( long ControlHandle ) If the control is minimized, the return value is true. If the control is not minimized, the return value is false.

long ControlHandle: any control handle (WindowHandle, ButtonHandle, ComboBoxHandle, etc.).

 

Control.SetMaximized( long ControlHandle ) maximizes the specified control.

long ControlHandle: any control handle (WindowHandle, ButtonHandle, ComboBoxHandle, etc.).

 

Control.GetMaximized( long ControlHandle ) If the control is maximized, the return value is true. If the control is not maximized, the return value is false.

long ControlHandle: any control handle (WindowHandle, ButtonHandle, ComboBoxHandle, etc.).

 

Control.SetFont( long ControlHandle, long FontHandle ) sets the font that a control is to use when drawing text.

long ControlHandle: any control handle (WindowHandle, ButtonHandle, ComboBoxHandle, etc.).
long FontHandle: font handle.

 

Control.GetFont( long ControlHandle ) retrieves the font with which the control is currently drawing its text. The return value is a handle to the font used by the control, or 0 if the control is using the system font.

long ControlHandle: any control handle (WindowHandle, ButtonHandle, ComboBoxHandle, etc.).

 

Control.SetText( long ControlHandle, string Text ) changes the text of the specified window’s title bar (if it has one). If the specified handle is a control, the text of the control is changed.

long ControlHandle: any control handle (WindowHandle, ButtonHandle, ComboBoxHandle, etc.).
string Text: the new title or control text.

 

Control.GetText( long ControlHandle ) returns a string that contains the title or control text.

long ControlHandle: any control handle (WindowHandle, ButtonHandle, ComboBoxHandle, etc.).

 

Control.GetTextLength( long ControlHandle ) retrieves the length, in characters, of the title or control text.

long ControlHandle: any control handle (WindowHandle, ButtonHandle, ComboBoxHandle, etc.).

 

Control.SetFocus( long ControlHandle ) sets the keyboard focus to the specified control. The control must be attached to the calling thread’s message queue. If the function succeeds, the return value is the handle to the control that previously had the keyboard focus.

long ControlHandle: any control handle (WindowHandle, ButtonHandle, ComboBoxHandle, etc.).

 

Control.GetFocus() retrieves the handle to the control that has the keyboard focus, if the control is attached to the calling thread’s message queue.

 

Control.SetParent( long ControlHandle, long ParentHandle ) Changes the parent control of the specified child control. If the function succeeds, the return value is a handle to the previous parent control. If the function fails, the return value is 0.

long ControlHandle: any control handle (WindowHandle, ButtonHandle, ComboBoxHandle, etc.).
long ParentHandle: a handle to the new parent control. If this parameter is 0, the desktop window becomes the new parent window.

 

Control.GetParent( long ControlHandle ) retrieves a handle to the specified control’s parent or owner. If the control is a child window, the return value is a handle to the parent window. If the window is a top-level window with the WS_POPUP style, the return value is a handle to the owner window. If the function fails, the return value is 0.

long ControlHandle: any control handle (WindowHandle, ButtonHandle, ComboBoxHandle, etc.).

 

Control.SetStyle( long ControlHandle, long Style ) sets a new control style.

long ControlHandle: any control handle (WindowHandle, ButtonHandle, ComboBoxHandle, etc.).
long Style: control style.

 

Control.GetStyle( long ControlHandle ) returns the style of the given control.

long ControlHandle: any control handle (WindowHandle, ButtonHandle, ComboBoxHandle, etc.).

 

Control.SetExStyle( long ControlHandle, long ExStyle ) sets a new extended control style.

long ControlHandle: any control handle (WindowHandle, ButtonHandle, ComboBoxHandle, etc.).
long ExStyle: extended control style.

 

Control.GetExStyle( long ControlHandle ) returns the extended style of the given control.

long ControlHandle: any control handle (WindowHandle, ButtonHandle, ComboBoxHandle, etc.).

 

Control.SetEnabled( long ControlHandle, bool Enabled ) enables or disables mouse and keyboard input to the specified control. When input is disabled, the control does not receive input such as mouse clicks and key presses. When input is enabled, the control receives all input. If the control was previously disabled, the return value is true. If the control was not previously disabled, the return value is false.

long ControlHandle: any control handle (WindowHandle, ButtonHandle, ComboBoxHandle, etc.).
bool Enabled: enables (true) or disables (false) the specified control.

 

Control.GetEnabled( long ControlHandle ) determines whether the specified control is enabled for mouse and keyboard input. If the control is enabled, the return value is true. If the control is not enabled, the return value is false.

long ControlHandle: any control handle (WindowHandle, ButtonHandle, ComboBoxHandle, etc.).

 

Control.SetRect( long ControlHandle, long X, long Y, long Width, long Height ) changes the position and dimensions of the specified control. For a top-level control, the position and dimensions are relative to the upper-left corner of the screen. For a child control, they are relative to the upper-left corner of the parent control’s client area. If the function succeeds, the return value is true. If the function fails, the return value is false.

long ControlHandle: any control handle (WindowHandle, ButtonHandle, ComboBoxHandle, etc.).
long X: the new position of the left side of the control.
long Y: the new position of the top side of the control.
long Width: the new width of the control.
long Height: the new height of the control.

 

Control.SetPosition( long ControlHandle, long X, long Y ) changes the position of the specified control. For a top-level control, the position are relative to the upper-left corner of the screen. For a child control, they are relative to the upper-left corner of the parent control’s client area. If the function succeeds, the return value is true. If the function fails, the return value is false.

long ControlHandle: any control handle (WindowHandle, ButtonHandle, ComboBoxHandle, etc.).
long X: the new position of the left side of the control.
long Y: the new position of the top side of the control.

 

Control.GetX( long ControlHandle ) returns the x position of the control.

long ControlHandle: any control handle (WindowHandle, ButtonHandle, ComboBoxHandle, etc.).

 

Control.GetY( long ControlHandle ) returns the y position of the control.

long ControlHandle: any control handle (WindowHandle, ButtonHandle, ComboBoxHandle, etc.).

 

Control.SetSize( long ControlHandle, long Width, long Height ) changes the dimensions of the specified control. For a top-level control, the dimensions are relative to the upper-left corner of the screen. For a child control, they are relative to the upper-left corner of the parent control’s client area. If the function succeeds, the return value is true. If the function fails, the return value is false.

long ControlHandle: any control handle (WindowHandle, ButtonHandle, ComboBoxHandle, etc.).
long Width: the new width of the control.
long Height: the new height of the control.

 

Control.GetWidth( long ControlHandle ) returns the width of the control.

long ControlHandle: any control handle (WindowHandle, ButtonHandle, ComboBoxHandle, etc.).

 

Control.GetHeight( long ControlHandle ) returns the height of the control.

long ControlHandle: any control handle (WindowHandle, ButtonHandle, ComboBoxHandle, etc.).

 

Control.SetZOrder( long ControlHandle, long ControlHandleInsertAfter ) changes the z order of the specified control. Controls are ordered according to their appearance on the screen. The topmost control receives the highest rank and is the first control in the Z order. If the function succeeds, the return value is true. If the function fails, the return value is false.

long ControlHandle: any control handle (WindowHandle, ButtonHandle, ComboBoxHandle, etc.).
long ControlHandleInsertAfter: any control handle (WindowHandle, ButtonHandle, ComboBoxHandle, etc.) to precede the positioned control in the Z order.

The ControlHandleInsertAfter parameter must be a control handle or one of the following constants.

HWND_BOTTOM Places the window at the bottom of the Z order. If the ControlHandle parameter identifies a topmost control, the control loses its topmost status and is placed at the bottom of all other controls.

HWND_NOTOPMOST Places the control above all non-topmost controls (that is, behind all topmost controls). This flag has no effect if the control is already a non-topmost control.

HWND_TOP Places the control at the top of the Z order.

HWND_TOPMOST Places the control above all non-topmost controls. The control maintains its topmost position even when it is deactivated.

 

Control.GetClassName( long ControlHandle ) returns the class name of the given control or an empty string otherwise.

long ControlHandle: any control handle (WindowHandle, ButtonHandle, ComboBoxHandle, etc.).

 

Control.Find( string ClassName, string ControlName ) retrieves a handle to the top-level control whose class name and control name match the specified strings. This function does not search child controls. This function does not perform a case-sensitive search. f the function succeeds, the return value is a handle to the control that has the specified class name and control name. If the function fails, the return value is 0.

string ClassName: class name. If this parameter is an empty string, it finds any control whose title matches the ControlName parameter.
string ControlName: control name (control’s title). If this parameter is an empty string, all control names match.

 

Control.DisableVisualStyles( long ControlHandle ) turns off visual styles for the given control.

long ControlHandle: any control handle (WindowHandle, ButtonHandle, ComboBoxHandle, etc.).

 

Control.GetSystemMetrics( long SystemMetric ) retrieves the specified system metric or system configuration setting.

long SystemMetric: the system metric or configuration setting to be retrieved.

 

Code Example

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

public class CodeExample : MonoBehaviour
{

private long WindowHandle = 0;

void Start()
{
Plugin.Initialize();//Initializes Giavapps Windows API
WindowHandle = Window.Create(0, 100, 100, 200, 200, 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, "My Text");//Sets a new text for the specified control
}

void Update()
{
//Other function calls could be here…
}

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.