Edit Class

 

 

About Edit Class

 

Edit class is mainly used for creating and managing edit controls.

 

Edit Class Methods

 

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

 

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

 

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

 

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

ulong EditIndex: zero-based index of the edit control.

 

Edit.CanUndo( long EditHandle ) determines whether there are any actions in the undo queue of an edit control. This method returns true if there are actions in the undo queue; otherwise false.

long EditHandle: edit control handle.

 

Edit.Undo( long EditHandle ) undoes the last operation in the undo queue of an edit or rich edit control. For a single-line control, the return value is always true. For a multiline control, the return value is true if the undo operation is successful, or false otherwise.

long EditHandle: edit control handle.

 

Edit.ResetUndo( long EditHandle ) resets the undo flag of an edit control. The undo flag is set whenever an operation within the edit control can be undone.

long EditHandle: edit control handle.

 

Edit.Scroll( long EditHandle, long Horizontal, long Vertical ) scrolls the text vertically in a multiline edit control.

long EditHandle: edit control handle.

 

Edit.SetCueBannerText( long EditHandle, string Text ) sets the textual cue, or tip, that is displayed by the edit control to prompt the user for information. If this method succeeds, it returns true. Otherwise it returns false.

long EditHandle: edit control handle.
string Text: string that contains the text to display as the textual cue.

 

Edit.GetCueBannerText( long EditHandle ) returns the text that is displayed as the textual cue, or tip, in an edit control. (This method can retrieve up to 256 characters!)

long EditHandle: edit control handle.

 

Edit.SetTextLimit( long EditHandle, long Limit ) sets the text limit of an edit control. The text limit is the maximum amount of characters that the user can type into the edit control.

long EditHandle: edit control handle.
long Limit: the maximum number of characters the user can enter. If this parameter is zero, the text length is set to 2147483646 characters for single-line edit controls or –1 for multiline edit controls.

 

Edit.GetTextLimit( long EditHandle ) returns the current text limit for an edit control.

long EditHandle: edit control handle.

 

Edit.GetLineCount( long EditHandle ) returns the number of lines in a multiline edit control. If the control has no text, the return value is 1. The return value will never be less than 1.

long EditHandle: edit control handle.

 

Edit.SetReadOnly( long EditHandle, bool ReadOnly ) sets or removes the read-only style ES_READONLY of an edit control.

long EditHandle: edit control handle.
bool ReadOnly: sets (true) or removes (false) the read-only style.

 

Edit.GetReadOnly( long EditHandle ) returns true if the read-only style ES_READONLY is set on the given edit control or false otherwise.

long EditHandle: edit control handle.

 

Edit.SetPasswordChar( long EditHandle, char Char ) Sets or removes the password character for an edit control. When a password character is set, that character is displayed in place of the characters typed by the user.

long EditHandle: edit control handle.
char Char: the character to be displayed in place of the characters typed by the user. If this parameter is ‘\0’, the control removes the current password character and displays the characters typed by the user.

 

Edit.GetPasswordChar( long EditHandle ) returns the password character that an edit control displays when the user enters text.

long EditHandle: edit control handle.

 

Edit.SetSelection( long EditHandle, long StartingPosition, long EndingPosition ) select characters in the edit control. 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 EditHandle: edit control 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.

 

Edit.GetSelection( long EditHandle, long StartingOrEndingPosition ) returns the starting or ending character positions of the current selection in the edit control.

long EditHandle: edit control handle.
long StartingOrEndingPosition: returns the starting (false) or ending (true) position.

 

Edit.SetChanged( long EditHandle, bool Changed ) sets the edit control as changed.

long EditHandle: edit control handle.
bool Changed: sets the edit control as changed (true) or not (false).

 

Edit.GetChanged( long EditHandle ) returns true after the user has taken an action that may have altered the text in the edit control or false otherwise.

long EditHandle: edit 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 EditHandle = 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
EditHandle = Edit.Create(WindowHandle, 10, 10, 150, 150, Constant.WS_VISIBLE | Constant.WS_CHILD | Constant.WS_HSCROLL | Constant.WS_VSCROLL | Constant.ES_AUTOHSCROLL | Constant.ES_AUTOVSCROLL | Constant.ES_MULTILINE, Constant.WS_EX_CLIENTEDGE);//creates a new edit control
Control.SetCueBannerText(EditHandle, "Type here…");//Sets a cue banner text for the specified edit 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 edit control has changed
if(Edit.GetChanged(EditHandle))
{
Debug.Log("EDIT CONTROL 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.