Edit control help

Function help:

Real API_Edit_Create (Real Parent Handle, Real X, Real Y, Real Width, Real Height, Real Style Flags, Real Extended Style Flags);

This function creates a new edit control.

Argument list:
(0) Parent Handle: Identifies the window handle of the window to create this control on.
(1) X: The horizontal position of the control in pixels, relative to the parent window.
(2) Y: The vertical position of the control in pixels, relative to the parent window.
(3) Width: The horizontal size of the control in pixels.
(4) Height: The vertical size of the control in pixels.
(5) Style Flags: The style flags, supports the Global Control Styles and the following styles:

ES_AUTOHSCROLL
Automatically scrolls text to the right by 10 characters when the user types a character at the end of the line. When the user presses the ENTER key, the control scrolls all text back to position zero.

ES_AUTOVSCROLL
Automatically scrolls text up one page when the user presses the ENTER key on the last line.

ES_CENTER
Windows 98/Me, Windows 2000/XP: Centers text in a single-line or multiline edit control.
Windows 95, Windows NT 4.0 and earlier: Centers text in a multiline edit control.

ES_LEFT
Aligns text with the left margin.

ES_LOWERCASE
Converts all characters to lowercase as they are typed into the edit control.

ES_MULTILINE
Designates a multiline edit control. The default is single-line edit control.

ES_NOHIDESEL
Negates the default behavior for an edit control. The default behavior hides the selection when the control loses the input focus and inverts the selection when the control receives the input focus. If you specify ES_NOHIDESEL, the selected text is inverted, even if the control does not have the focus.

ES_NUMBER
Allows only digits to be entered into the edit control. Note that, even with this set, it is still possible to paste non-digits into the edit control.

ES_PASSWORD
Displays an asterisk (*) for each character typed into the edit control. This style is valid only for single-line edit controls.

ES_READONLY
Prevents the user from typing or editing text in the edit control.

ES_RIGHT
Windows 98/Me, Windows 2000/XP: Right-aligns text in a single-line or multiline edit control. Windows 95, Windows NT 4.0 and earlier: Right aligns text in a multiline edit control.

ES_UPPERCASE
Converts all characters to uppercase as they are typed into the edit control.

Style flags can be separated by a bitwise or '|' operator.

(6) Extended Style Flags: This can be any combination of the Global Extended Control Styles.

Return value:
If this function succeeds, it returns the Control ID of the control, otherwise it returns 0.


Real API_Edit_SetSel ( Real Control ID, Real Start Pos, Real End Pos);

This function changes the selected text of an edit control using the specified start and end position of the selection.

Return value:
Always returns zero (0).
Real API_Edit_GetSel ( Real Control ID, Real Selection type );

This function returns the selection of an edit control.

(0) Control ID, returned by API_Edit_Create.
(1) Selection type:
0 - Return the start position of the selection
1 - Return the end position of the selection

Return value:
Returns the position of the selection.
Real API_Edit_Undo ( Real Control ID);

This function undoes the last edit control operation.

Return value:
Returns true (1) when succesful, or false (0) otherwise.
Real API_Edit_CanUndo ( Real Control ID);

This function returns wether the edit control can undo.

Return value:
Returns true (1) when undoing is possible, or false (0) otherwise.
Real API_Edit_SetPasswordChar ( Real Control ID, Real ASCI code val);

This function changes the password character of an edit control with the ES_PASSWORD style to your specified character.
The normal character is an asterisk (*).
You can use Game Maker's chr() function to convert a string character to ASCI code.

Return value:
Always returns zero (0).
Real API_Edit_GetPasswordChar ( Real Control ID);

This function gets the password character of an edit control with the ES_PASSWORD style.

Return value:
Returns the ASCI val of the password character.
Real API_Edit_GetLines ( Real Control ID);

Returns the number of lines inside a multiline edit control.

Return value:
Returns the number of lines.
String API_Edit_GetLine ( Real Control ID, Real Zero Based Line number );

Returns the text inside the specified line in an edit control.

Return value:
Returns the text in the line.
Real API_Edit_ReplaceSelection ( Real Control ID, Real Can Be Undone, String Text );

This function replaces the text selected in the edit control with the specified text.

Return value:
Always returns zero (0).

Real API_Edit_SetReadOnly ( Real Control ID, Real Is Read Only );

This function changes the ES_READONLY style of the edit control.

(0) Control ID, returned by API_Edit_Create.
(1) Use 1 to make the control read only, use 0 to make the control not read only.

Return value:
Returns true (1) when succesful, or false (0) otherwise.

Secondary check commands for edit controls:

EN_CHANGE
Sent when the user has taken an action that may have altered text in an edit control.

EN_HSCROLL
Sent when the user clicks an edit control's horizontal scroll bar.

EN_VSCROLL
Sent when the user clicks an edit control's vertical scroll bar or when the user scrolls the mouse wheel over the edit control.

EN_KILLFOCUS
Notifies that the control has lost the input focus.

EN_SETFOCUS
Notifies that the control has received the input focus.

Example:

Command = API_Check_Command (1); // Check commands for check handle 1

if ( Command == Edit1 ) // Edit1 sends a command
{
Second = API_Check_SecondaryCommand (1); // Check the command type

if ( Second == EN_SETFOCUS) // The focus is set to the edit control
{
show_message ("The focus is set to the edit control.");
}

}



Example code:

is
Edit1 =API_Edit_Create(Win,300,60,300,20,ES_PASSWORD);

API_Edit_SetPasswordChar (Edit1,chr ("A"));

Return to help index