Edit – Giavapps Windows API

 

 

api_edit_create(ParentHandle, X, Y, W, H, Flags, ExFlags) This function creates an edit control.

ParentHandle: parent handle.
X: x coordinate.
Y: y coordinate.
W: width.
H: height.
Flags: Flags of the control. Flags must be separated with the symbol “|”.
ExFlags: extended flags of the control. Flags must be separated with the symbol “|”.
 

Flags

 

This control supports the Window Styles and you can specify any of the styles listed below:

 

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 Centers text in a single-line or 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_OEMCONVERT Converts text entered in the edit control. The text is converted from the Windows character set to the OEM character set and then back to the Windows character set. This style is most useful for edit controls that contain file names that will be used on file systems that do not support Unicode.

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 Right-aligns text in a single-line or multiline edit control.

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

ES_WANTRETURN Specifies that a carriage return be inserted when the user presses the ENTER key while entering text into a multiline edit control in a dialog box. If you do not specify this style, pressing the ENTER key has the same effect as pressing the dialog box’s default push button. This style has no effect on a single-line edit control.

 

Extended Flags

 

This control supports the Extended Window Styles.

 

Return Value

 

If the function succeeds, the return value is a handle to the new edit control.

If the function fails, the return value is false.

To get extended error information, call api_control_get_last_error().
 

Control Functions

 

api_edit_undo(EditHandle) Undoes the last operation in the undo queue of an 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.

EditHandle: it must be an EditHandle.

 

api_edit_reset_undo(EditHandle) Resets the undo flag of an edit control. The undo flag is automatically reset when you use api_control_set_text() on the specified edit control.

EditHandle: it must be an EditHandle.

 

api_edit_can_undo(EditHandle) Determines whether there are any actions in the undo queue of an edit control. The function returns true if there are actions in the undo queue; otherwise false.

EditHandle: it must be an EditHandle.

 

api_edit_scroll(EditHandle, Horizontal, Vertical) Scrolls the text in a multiline edit control.

EditHandle: it must be an EditHandle.
Horizontal: the number of characters to scroll horizontally.
Vertical: the number of lines to scroll vertically.

 

api_edit_set_text_limit(EditHandle,TextLimit) Limits the length of text that can be entered into an edit control.

EditHandle: it must be an EditHandle.
TextLimit: maximum nunber of characters.

 

api_edit_get_text_limit(EditHandle) Returns the maximum number of characters that can be entered into an edit control.

EditHandle: it must be an EditHandle.

 

api_edit_get_linecount(EditHandle) Returns the total number of text lines in the multiline edit control.

EditHandle: it must be an EditHandle.

 

api_edit_set_readonly(EditHandle,ReadOnly) Sets or removes the read-only style ES_READONLY of an edit control.

EditHandle: it must be an EditHandle.
ReadOnly: Sets (true) or removes (false) the ES_READONLY style.

 

api_edit_get_readonly(EditHandle) Returns true when the ES_READONLY style is set or false otherwise.

EditHandle: it must be an EditHandle.

 

api_edit_set_modified(EditHandle, Modified) Sets the modified state of the edit control.

EditHandle: it must be an EditHandle.
Modified: modified (true) or unmodified (false).

 

api_edit_get_modified(EditHandle) Returns true whether the contents of the edit control have been modified or false otherwise.

EditHandle: it must be an EditHandle.

 

api_edit_set_selection(EditHandle,StartingPosition,EndingPosition) Selects a range of characters in an edit control. The selection is not visible if the ES_NOHIDESEL style flag isn’t set.

EditHandle: it must be an EditHandle.
StartingPosition: the starting position. If the StartingPosition is –1, the selection, if any, is removed.
EndingPosition: the ending position. If the EndingPosition is –1, all text from the starting position to the last character in the edit control is selected.

 

api_edit_get_selection(EditHandle,StartingOrEndingPosition) Returns the starting or ending character positions of the current selection in an edit control. The selection is not visible if the ES_NOHIDESEL style flag isn’t set.

EditHandle: it must be an EditHandle.
StartingOrEndingPosition: the function returns the starting position (false) or the ending position (true).

 

Code Examples

 

Creating a Single Line Edit Control which has a Border

 

edit = api_edit_create(window,10,10,160,21,WS_VISIBLE | WS_CHILD | WS_BORDER,0);

 

Creating a Multi Line Edit Control which has a Sunken Edge and Scroll Bars

 

edit = api_edit_create(window,10,10,200,200,WS_VISIBLE | WS_CHILD | WS_HSCROLL | WS_VSCROLL | ES_MULTILINE | ES_AUTOHSCROLL | ES_AUTOVSCROLL,WS_EX_CLIENTEDGE);

 

Undoing Modifications

 

if(api_edit_can_undo(edit))
{
api_edit_undo(edit);
api_edit_reset_undo(edit);
}

 

Checking Modifications

 

Step Event:

 

if(api_edit_get_modified(edit))
{
api_messagebox(window,“MODIFIED!”,“INFO”,MB_OK);
}

 

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.

Leave a Reply

Il tuo indirizzo email non sarà pubblicato. I campi obbligatori sono contrassegnati *

*