Window Class

 

 

About Window Class

 

Window class is mainly used for creating and managing windows.

 

Window Class Methods

 

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

 

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

 

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

 

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

ulong WindowIndex: zero-based index of the window.

 

Window.SetActive( long WindowHandle ) activates a window. The window must be attached to the calling thread’s message queue. If the function succeeds, the return value is the handle to the window that was previously active. If the function fails, the return value is 0.

long WindowHandle: window handle.

 

Window.GetActive() retrieves the window handle to the active window attached to the calling thread’s message queue. The return value is the handle to the active window attached to the calling thread’s message queue. Otherwise, the return value is 0.

 

Window.SetForeground( long WindowHandle ) brings the thread that created the specified window into the foreground and activates the window. Keyboard input is directed to the window, and various visual cues are changed for the user. The system assigns a slightly higher priority to the thread that created the foreground window than it does to other threads. If the window was brought to the foreground, the return value is true. If the window was not brought to the foreground, the return value is false.

long WindowHandle: window handle.

 

Window.GetForeground() retrieves a handle to the foreground window (the window with which the user is currently working). The system assigns a slightly higher priority to the thread that creates the foreground window than it does to other threads. The return value is a handle to the foreground window. The foreground window can be 0 in certain circumstances, such as when a window is losing activation.

 

Window.SetActivated( long WindowHandle, bool Activated ) activates or deactivates the specified window.

long WindowHandle: window handle.
bool Activated: activates (true) or deactivates (false) the specified window.

 

Window.GetActivated( long WindowHandle ) returns true if the specified window has been activated or false otherwise.

long WindowHandle: window handle.

 

Window.SetClosed( long WindowHandle, bool Closed ) sets the specified window as closed or not. When the user clicks on the X button of the window the closed state becames true. Note that for destroying the window you must call Control.Destroy() method.

long WindowHandle: window handle.
bool Closed: sets the specified window as closed (true) or not (false).

 

Window.GetClosed( long WindowHandle ) returns true if the specified window has been closed or false otherwise. When the user clicks on the X button of the window the closed state becames true. Note that for destroying the window you must call Control.Destroy() method.

long WindowHandle: window handle.

 

Window.SetIcon( long WindowHandle, long IconHandle, long IconType ) associates a new large or small icon with a window. The system displays the large icon in the ALT+TAB dialog box, and the small icon in the window caption. The return value is a handle to the previous large or small icon, depending on the value of IconSize. It is 0 if the window previously had no icon of the type indicated by IconType.

long WindowHandle: window handle.
long IconHandle: icon handle.
long IconType: the type of icon to be set.

IcomType parameter can be one of the following constants.

ICON_BIG Set the large icon for the window.

ICON_SMALL Set the small icon for the window.

 

Window.SetMenu( long WindowHandle, long MenuHandle ) assigns a new menu to the specified window. If the function succeeds, the return value is true. If the function fails, the return value is false. The window is redrawn to reflect the menu change. A menu can be assigned to any window that is not a child window. This function replaces the previous menu, if any, but it does not destroy it. An application should call the Menu.Delete() function to accomplish this task.

long WindowHandle: window handle.
long MenuHandle: menu handle.

 

Window.GetMenu( long WindowHandle ) returns a handle to the menu assigned to the specified window.

long WindowHandle: window handle.

 

Window.GetUnityWindowHandle() returns the Unity window handle or 0 if fails. (This method only works when you build and run the application!)

 

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, 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
}

void Update()
{

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

}

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

}

 

Window Class Members

 

Window.UnityWindowClassName member contains a string that identifies the class name of the Unity window. This member is used by the Window.GetUnityWindowHandle() method to retrieve the WindowHandle of the Unity window. You shouldn’t change this value unless the Unity developers change the class name.

 

Code Example

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

public class CodeExample : MonoBehaviour
{

void Start()
{
Debug.Log("UNITY WINDOW CLASS NAME: "+Window.UnityWindowClassName);
}

}

 

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.