# Edit Library v1.1

Summary

Edit Library v1.1 |
Introduction | This library is designed for use on the standard edit control.
Issues/Consideration | A few considerations...
Credit | This library was inspired by the Edit mini-library created by Lexikos and the HiEditor library created by majkinetor.
Functions |
Edit_CanUndo | Returns TRUE if there are any actions in the edit control’s undo queue, otherwise FALSE.
Edit_CharFromPos | Gets information about the character and/or line closest to a specified point in the the client area of the edit control.
Edit_Clear | Delete (clear) the current selection, if any, from the edit control.
Edit_Convert2DOS | Converts Unix, DOS/Unix mix, and Mac file formats to DOS format.
Edit_Convert2Mac | Convert DOS, DOS/Unix mix, and Unix file formats to Mac format.
Edit_Convert2Unix | Convert DOS, DOS/Unix mix, and Mac formats to Unix format.
Edit_ConvertCase | Convert case of selected text.
Edit_Copy | Copy the current selection to the clipboard in CF_TEXT format.
Edit_Cut | Delete the current selection, if any, and copy the deleted text to the clipboard in CF_TEXT format.
Edit_EmptyUndoBuffer | Resets the undo flag of the edit control.
Edit_FindText | Find text within the edit control.
Edit_FmtLines | Sets a flag that determines whether a multiline edit control includes soft line-break characters.
Edit_GetFirstVisibleLine | Returns the zero-based index of the uppermost visible line.
Edit_GetLastVisibleLine | Returns the zero-based line index of the last visible line on the edit control.
Edit_GetLimitText | Returns the current text limit for the edit control.
Edit_GetLine | Get the text of the desired line from the edit control.
Edit_GetLineCount | Returns an integer specifying the total number of text lines in a multiline edit control.
Edit_GetMargins | Gets the widths of the left and right margins for the edit control.
Edit_GetModify | Gets the state of the edit control’s modification flag.
Edit_GetRect | Gets the formatting rectangle of the edit control.
Edit_GetSel | Gets the starting and ending character positions of the current selection in the edit control.
Edit_GetSelText | Returns the currently selected text (if any).
Edit_GetText | Returns all text from the control up to p_Length length.
Edit_GetTextLength | Returns the length, in characters, of the text in the edit control.
Edit_GetTextRange | Get a range of characters.
Edit_IsMultiline | Returns TRUE if the edit control is multiline, otherwise FALSE.
Edit_IsReadOnly | Returns TRUE if the ES_READONLY style has been set, otherwise FALSE.
Edit_IsStyle | Returns TRUE if the specified style has been set, otherwise FALSE.
Edit_SetStyle | Adds, removes, or toggles a style for an edit control.
Edit_LineFromChar | Gets the index of the line that contains the specified character index.
Edit_LineFromPos | This function is the same as Edit_CharFromPos except the line index (r_LineIdx) is returned.
Edit_LineIndex | Gets the character index of the first character of a specified line.
Edit_LineLength | Gets the length of a line.
Edit_LineScroll | Scrolls the text in the edit control for the current file.
Edit_LoadFile | Load the contents of a file to the edit control.
Edit_Paste | Copies the current content of the clipboard to the edit control at the current caret position.
Edit_PosFromChar | Gets the client area coordinates of a specified character in the edit control.
Edit_ReplaceSel | Replaces the selected text with the specified text.
Edit_SaveFile | Save the contents of the edit control to a file.
Edit_Scroll | Scrolls the text vertically in the edit control.
Edit_ScrollCaret | Scrolls the edit control until caret is visible.
Edit_SetLimitText | Sets the text limit of the edit control.
Edit_SetMargins | Sets the width of the left and/or right margin (in pixels) for the edit control.
Edit_SetModify | Sets or clears the modification flag for the edit control.
Edit_SetPasswordChar | Sets or removes the password character for a single-line edit control.
Edit_SetReadOnly | Sets or removes the read-only style (ES_READONLY) of the edit control.
Edit_SetRect | Sets the formatting rectangle of a multiline edit control.
Edit_SetTabStops | Sets the tab stops in a multiline edit control.
Edit_SetText | Set the text of the edit control.
Edit_SetSel | Selects a range of characters.
Edit_TextIsSelected | Returns TRUE if text is selected, otherwise FALSE.
Edit_Undo | Undo the last operation.
Edit_GetActiveHandles | Finds the handles for the active control and active window.

### Introduction

This library is designed for use on the standard edit control.

### Issues/Consideration

A few considerations...

- Although many of the functions work on all types of edit controls -- single-line, multiline, and combo boxes (contains a single-line edit control) -- there are several functions that only work on one type of edit control. See the documentation for each function for more information.
- AutoHotkey supports the creation and manipulation of the standard edit control. For this reason, there are a small number functions that were intentionally left out of this library because they provide no additional value to what the standard AutoHotkey commands provide.
- The edit control does not support several key messages that are needed by this library. Absent messages include EM_GETSELTEXT, EM_GETTEXTRANGE, and EM_FINDTEXT. These messages have been replaced with AutoHotkey commands or with other messages. Although the substitute code/messages are very capable, they are not quite as efficient (memory and/or speed) as the messages they replace (if they existed). These inefficiencies are not really noticable if the control only contains a limited amount of text (~512K or less), but they become more pronounced with increasing text sizes. Efficiency also depends on the where work in the control is being done. For example, extracting text from the top of the control uses less resources that extracting text from the end of the control.

### Credit

This library was inspired by the Edit mini-library created by Lexikos and the HiEditor library created by majkinetor. Some of the syntax and code ideas were extracted from these libraries. Thank to these authors for sharing their work.

### Functions

### Edit_CanUndo

> Edit_CanUndo( | hEdit | )

#### Description

Returns TRUE if there are any actions in the edit control’s undo queue, otherwise FALSE.

### Edit_CharFromPos

> Edit_CharFromPos( |  | hEdit, |  |
> |  | X, |  |
> |  | Y, |  |
> | ByRef | r_CharPos | = | "",
> | ByRef | r_LineIdx | = | "" | )

#### Description

Gets information about the character and/or line closest to a specified point in the the client area of the edit control.

#### Parameters

X, Y | The coordinates of a point in the edit control’s client area relative to the upper-left corner of the client area.
r_CharPos | The zero-based index of the character nearest the specified point. [Optional] This index is relative to the beginning of the control, not the beginning of the line. If the specified point is beyond the last character in the edit control, the return value indicates the last character in the control. See the Remarks section for more information.
r_LineIdx | Zero-based index of the line that contains the character. [Optional] For single-line edit controls, this value is zero. The index indicates the line delimiter if the specified point is beyond the last visible character in a line. See the Remarks section for more information.

#### Returns

The value of the r_CharPos variable.

#### Remarks

If the specified point is outside the bounds of the edit control, all output variables (Return, r_CharPos, and r_LineIdx) are set to -1.

### Edit_Clear

> Edit_Clear( | hEdit | )

#### Description

Delete (clear) the current selection, if any, from the edit control.

#### Remarks

Undo can be used to reverse this action.

### Edit_Convert2DOS

> Edit_Convert2DOS( | p_Text | )

#### Description

Converts Unix, DOS/Unix mix, and Mac file formats to DOS format.

### Edit_Convert2Mac

> Edit_Convert2Mac( | p_Text | )

#### Description

Convert DOS, DOS/Unix mix, and Unix file formats to Mac format.

### Edit_Convert2Unix

> Edit_Convert2Unix( | p_Text | )

#### Description

Convert DOS, DOS/Unix mix, and Mac formats to Unix format.

### Edit_ConvertCase

> Edit_ConvertCase( | hEdit,
> | p_Case | )

#### Description

Convert case of selected text.

#### Parameters

p_Case | Set to “Upper”, “Lower”, “Capitalize”, or “Toggle”.

### Edit_Copy

> Edit_Copy( | hEdit | )

#### Description

Copy the current selection to the clipboard in CF_TEXT format.

### Edit_Cut

> Edit_Cut( | hEdit | )

#### Description

Delete the current selection, if any, and copy the deleted text to the clipboard in CF_TEXT format.

### Edit_EmptyUndoBuffer

> Edit_EmptyUndoBuffer( | hEdit | )

#### Description

Resets the undo flag of the edit control. The undo flag is set whenever an operation within the edit control can be undone.

### Edit_FindText

> Edit_FindText( |  | hEdit, |  |
> |  | p_SearchText, |  |
> |  | p_Min | = | 0,
> |  | p_Max | = | -1,
> |  | p_Flags | = | "",
> | ByRef | r_RegExOut | = | "" | )

#### Description

Find text within the edit control.

#### Parameters

p_SearchText | Search text.
p_Min, p_Max | Zero-based search range within the edit control. p_Min is the character index of the first character in the range and p_Max is the character index immediately following the last character in the range. (Ex: To search the first 5 characters of the text, set p_Min to 0 and p_Max to 5) Set p_Max to -1 to search to the end of the text. To search backward, the roles and descriptions of the p_Min and p_Max are reversed. (Ex: To search the first 5 characters of the control in reverse, set p_Min to 5 and p_Max to 0)
p_Flags | Valid flags are as follows:

>     Flag        Description
>     ----        -----------
>     MatchCase   Search is case sensitive.  This flag is ignored if the
>                 "RegEx" flag is also defined.

>     RegEx       Regular expression search.

>     Static      [Advanced feature]
>                 Text collected from the edit control remains in memory is
>                 used to satisfy the search request.  The text remains in
>                 memory until the "Reset" flag is used or until the
>                 "Static" flag is not used.

>                 Advantages: Search time is reduced 10 to 60 percent
>                 (or more) depending on the size of the text in the control.
>                 There is no speed increase on the first use of the "Static"
>                 flag.

>                 Disadvantages: Any changes in the edit control are not
>                 reflected in the search.

>                 Bottom line: Don't use this flag unless performing multiple
>                 search requests on a control that will not be modified
>                 while searching.

>     Reset       [Advanced feature]
>                 Clears the saved text created by the "Static" flag so that
>                 the next use of the "Static" flag will get the text directly
>                 from the edit control.  To clear the saved memory without
>                 performing a search, use the following syntax:

>                     Edit_FindText("","",0,0,"Reset")

r_RegExOutput | Variable that contains the part of the source text that matched the RegEx pattern. [Optional]

#### Returns

Zero-based character index of the first character of the match or -1 if no match is found.

#### Programming Notes

Searching using regular expressions (RegEx) can produce results that have a dynamic number of characters. For this reason, searching for the “next” pattern (forward or backward) may produce different results from developer developer depending on how values of p_Min and p_Max are determined.

### Edit_FmtLines

> Edit_FmtLines( | hEdit,
> | p_Flag | )

#### Description

Sets a flag that determines whether a multiline edit control includes soft line-break characters. A soft line break consists of two carriage returns and a line feed and is inserted at the end of a line that is broken because of word wrapping.

#### Parameters

p_Flag | Set to TRUE to insert soft line-break characters characters, FALSE to removes them.

#### Returns

The value of p_Flag.

#### Remarks

This message has no effect on the display of the text within the edit control. It affects the buffer returned by the EM_GETHANDLE message and the text returned by the WM_GETTEXT message. Since the WM_GETTEXT message is used by other functions in this library, be sure to un-format the text as soon as possible. Example of use:

>     Edit_FmtLines(hEdit,True)
>     FormattedText:=Edit_GetText(hEdit)
>     Edit_FmtLines(hEdit,False)

### Edit_GetFirstVisibleLine

> Edit_GetFirstVisibleLine( | hEdit | )

#### Description

Returns the zero-based index of the uppermost visible line. For single-line edit controls, the return value is the zero-based index of the first visible character.

### Edit_GetLastVisibleLine

> Edit_GetLastVisibleLine( | hEdit | )

#### Description

Returns the zero-based line index of the last visible line on the edit control.

#### Remarks

To calculate the total number of visible lines, use the following...

>     Edit_GetLastVisibleLine(hEdit) - Edit_GetFirstVisibleLine(hEdit) + 1

### Edit_GetLimitText

> Edit_GetLimitText( | hEdit | )

#### Description

Returns the current text limit for the edit control.

#### Remarks

Windows NT+: The maximum text length is 0x7FFFFFFE characters for single-line edit controls and -1 for multiline edit controls.

### Edit_GetLine

> Edit_GetLine( | hEdit, |  |
> | p_LineIdx | = | -1,
> | p_Length | = | -1 | )

#### Description

Get the text of the desired line from the edit control.

#### Parameters

p_LineIdx | The zero-based index of the line to retrieve. [Optional] Use -1 (the default) to get the current line. This parameter is ignored if used for a single-line edit control.
p_Length | Length of the line or length of the text to be extracted. [Optional] Use -1 (the default) to automatically determine the length of the line.

#### Returns

The text of the specified line. The return value is an empty string if the line number specified by the p_LineIdx parameter is greater than the number of lines in the Edit control.

### Edit_GetLineCount

> Edit_GetLineCount( | hEdit | )

#### Description

Returns an integer specifying the total number of text 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.

#### Remarks

The value returned is for the number of lines in the edit control. Very long lines (>1024) or word wrap may introduce additional lines to the control.

### Edit_GetMargins

> Edit_GetMargins( |  | hEdit, |  |
> | ByRef | r_LeftMargin | = | "",
> | ByRef | r_RightMargin | = | "" | )

#### Description

Gets the widths of the left and right margins for the edit control. If defined, these values are returned in the r_LeftMargin and r_RightMargin variables.

#### Parameters

r_LeftMargin | Left margin, in pixels. [Optional]
r_RightMargin | Right margin, in pixels. [Optional]

#### Returns

The edit control’s left margin

### Edit_GetModify

> Edit_GetModify( | hEdit | )

#### Description

Gets the state of the edit control’s modification flag. The flag indicates whether the contents of the edit control have been modified. Returns TRUE if the control has been modified, otherwise FALSE.

### Edit_GetRect

> Edit_GetRect( |  | hEdit, |  |
> | ByRef | r_Left | = | "",
> | ByRef | r_Top | = | "",
> | ByRef | r_Right | = | "",
> | ByRef | r_Bottom | = | "" | )

#### Description

Gets the formatting rectangle of the edit control.

#### Parameters

r_Left..r_Bottom | Output variables. [Optional]

#### Returns

Space separated rectangle.

### Edit_GetSel

> Edit_GetSel( |  | hEdit, |  |
> | ByRef | r_StartSelPos | = | "",
> | ByRef | r_EndSelPos | = | "" | )

#### Description

Gets the starting and ending character positions of the current selection in the edit control. If defined, these values are returned in the r_StartSelPos and r_EndSelPos variables.

#### Parameters

r_StartSelPos | Starting position of the selection. [Optional]
r_EndSelPos | Ending position of the selection. [Optional]

#### Returns

Starting position of the selection.

### Edit_GetSelText

> Edit_GetSelText( | hEdit | )

#### Description

Returns the currently selected text (if any).

#### Remarks

Since the edit control does not support the EM_GETSELTEXT message, the EM_GETLINE (if the selection is on one line) and the WM_GETTEXT messages are used instead.

### Edit_GetText

> Edit_GetText( | hEdit, |  |
> | p_Length | = | -1 | )

#### Description

Returns all text from the control up to p_Length length. If p_Length=-1 (the default), all text is returned.

#### Remarks

This function is similar to the AutoHotkey GUIControlGet command (for AHK GUI’s) and the ControlGetText command except that end-of-line (EOL) characters from the retrieved text are not automatically converted (CR+LF to LF). If needed, use the Edit_Convert2Unix function to convert the text to the AutoHotkey text format.

### Edit_GetTextLength

> Edit_GetTextLength( | hEdit | )

#### Description

Returns the length, in characters, of the text in the edit control.

### Edit_GetTextRange

> Edit_GetTextRange( | hEdit, |  |
> | p_Min | = | 0,
> | p_Max | = | -1 | )

#### Description

Get a range of characters.

#### Parameters

p_Min | Character position index immediately preceding the first character in the range.
p_Max | Character position immediately following the last character in the range. Set to -1 to indicate the end of the text.

#### Remarks

Since the edit control does not support the EM_GETTEXTRANGE message, the Edit_GetText function (WM_GETTEXT message) is used to collect the desired range of characters.

### Edit_IsMultiline

> Edit_IsMultiline( | hEdit | )

#### Description

Returns TRUE if the edit control is multiline, otherwise FALSE.

### Edit_IsReadOnly

> Edit_IsReadOnly( | hEdit | )

#### Description

Returns TRUE if the ES_READONLY style has been set, otherwise FALSE.

### Edit_IsStyle

> Edit_IsStyle( | hEdit,
> | p_Style | )

#### Description

Returns TRUE if the specified style has been set, otherwise FALSE.

#### Parameters

p_Style | Style of the edit control.

Some common edit control styles...

>     ES_LEFT       :=0x0         ;-- Can't actually check this style.  It's the lack of ES_CENTER or ES_RIGHT.
>     ES_CENTER     :=0x1
>     ES_RIGHT      :=0x2
>     ES_MULTILINE  :=0x4
>     ES_UPPERCASE  :=0x8
>     ES_LOWERCASE  :=0x10
>     ES_PASSWORD   :=0x20        ;-- Single-line edit control only
>     ES_AUTOVSCROLL:=0x40
>     ES_AUTOHSCROLL:=0x80
>     ES_NOHIDESEL  :=0x100
>     ES_COMBO      :=0x200
>     ES_OEMCONVERT :=0x400
>     ES_READONLY   :=0x800
>     ES_WANTRETURN :=0x1000
>     ES_NUMBER     :=0x2000
>     WS_TABSTOP    :=0x10000
>     WS_HSCROLL    :=0x100000
>     WS_VSCROLL    :=0x200000

### Edit_SetStyle

> Edit_SetStyle( | hEdit, |  |
> | p_Style, |  |
> | p_Option | = | "+" | )

#### Description

Adds, removes, or toggles a style for an edit control.

#### Parameters

p_Style | Style to set.
p_Option | Use “+” (the default) to add, “-” to remove, and “^” to toggle.

#### Returns

TRUE if the request completed successfully, otherwise FALSE.

#### Remarks

Styles that can be modified after the edit control has been created include the following:

>     ES_UPPERCASE  :=0x8
>     ES_LOWERCASE  :=0x10
>     ES_PASSWORD   :=0x20    ;-- Use the Edit_SetPasswordChar function
>     ES_OEMCONVERT :=0x400
>     ES_READONLY   :=0x800   ;-- Use the Edit_SetReadOnly function
>     ES_WANTRETURN :=0x1000
>     ES_NUMBER     :=0x2000

Use the Edit_IsStyle function to determine if a style is currently set.

### Edit_LineFromChar

> Edit_LineFromChar( | hEdit, |  |
> | p_CharPos | = | -1 | )

#### Description

Gets the index of the line that contains the specified character index.

#### Parameters

p_CharPos | The character index of the character contained in the line whose number is to be retrieved. [Optional] If –1 (the default), the function retrieves either the line number of the current line (the line containing the caret) or, if there is a selection, the line number of the line containing the beginning of the selection.

#### Returns

The zero-based line number of the line containing the character index specified by p_CharPos.

### Edit_LineFromPos

> Edit_LineFromPos( |  | hEdit, |  |
> |  | X, |  |
> |  | Y, |  |
> | ByRef | r_CharPos | = | "",
> | ByRef | r_LineIdx | = | "" | )

#### Description

This function is the same as Edit_CharFromPos except the line index (r_LineIdx) is returned.

### Edit_LineIndex

> Edit_LineIndex( | hedit, |  |
> | p_LineIdx | = | -1 | )

#### Description

Gets the character index of the first character of a specified line.

#### Parameters

p_LineIdx | Zero-based line number. [Optional] Use -1 (the default) for the current line.

#### Returns

The character index of the specified line or -1 if the specified line is greater than the total number of lines in the edit control.

### Edit_LineLength

> Edit_LineLength( | hEdit, |  |
> | p_LineIdx | = | -1 | )

#### Description

Gets the length of a line.

#### Parameters

p_LineIdx | The zero-based line index of the desired line. Use -1 (the default) for the current line.

#### Returns

The length, in characters, of the specified line. If p_LineIndex is greater than the total number of lines in the edit control, the length of the last (or only) line is returned.

### Edit_LineScroll

> Edit_LineScroll( | hEdit, |  |
> | xScroll | = | 0,
> | yScroll | = | 0 | )

#### Description

Scrolls the text in the edit control for the current file.

#### Parameters

xScroll | The number of characters to scroll horizontally. Use a negative number to scroll to the left and a positive number to scroll to the right.
yScroll | The number of lines to scroll vertically. Use a negative number to scroll up and a positive number to scroll down.

#### Returns

TRUE if sent to a multiline edit control, otherwise FALSE.

### Edit_LoadFile

> Edit_LoadFile( |  | hEdit, |  |
> |  | p_FileName, |  |
> |  | p_Convert2DOS | = | False,
> | ByRef | r_FileFormat | = | "" | )

#### Description

Load the contents of a file to the edit control.

#### Parameters

p_FileName | The full path and name of the file.
p_Convert2DOS | If TRUE, the text will be converted from Unix, DOS/Unix mix, or Mac format, to DOS format before it is loaded to the edit control. [Optional]
r_FileFormat | Contains the file format variable. [Optional] This variable
is set to the file format of loaded file | ”DOS”, “Unix”, or “Mac”. This information is useful if the contents of the edit control will be be converted back to the original file format when the file is saved.

#### Returns

TRUE if successful, otherwise FALSE.

#### Remarks

This request will replace the entire edit control with the contents of the the requested file. Consequently, the Undo buffer is flushed.

### Edit_Paste

> Edit_Paste( | hEdit | )

#### Description

Copies the current content of the clipboard to the edit control at the current caret position. Data is inserted only if the clipboard contains data in CF_TEXT format.

### Edit_PosFromChar

> Edit_PosFromChar( |  | hEdit,
> |  | p_CharPos,
> | ByRef | X,
> | ByRef | Y | )

#### Description

Gets the client area coordinates of a specified character in the edit control.

#### Parameters

p_CharPos | The zero-based index of the character.
X, Y | These parameters, which must contain valid variable names, are used to return the x/y-coordinates of a point in the Edit control’s client relative to the upper-left corner of the client area.

#### Remarks

If p_CharPos is greater than the index of the last character in the control, the returned coordinates are of the position just past the last character of the control.

### Edit_ReplaceSel

> Edit_ReplaceSel( | hEdit, |  |
> | p_Text | = | "",
> | p_CanUndo | = | True | )

#### Description

Replaces the selected text with the specified text. If there is no selection, the replacement text is inserted at the caret.

#### Parameters

p_Text | Text to replace selection with.
p_CanUndo | If TRUE (the default), replace can be undone.

### Edit_SaveFile

> Edit_SaveFile( | hEdit, |  |
> | p_FileName, |  |
> | p_Convert | = | "" | )

#### Description

Save the contents of the edit control to a file. If the file does not exist, it will be created.

#### Parameters

p_FileName | The full path and name of the file.
p_Convert | Convert file format. [Optional] Set to “M” or “Mac” to convert to Mac. Set to “U” or “Unix” to convert to Unix.

#### Returns

TRUE if successful, otherwise FALSE.

### Edit_Scroll

> Edit_Scroll( | hEdit, |  |
> | p_Pages | = | 0,
> | p_Lines | = | 0 | )

#### Description

Scrolls the text vertically in the edit control.

#### Parameters

p_Pages | The number of pages to scroll. Use a negative number to scroll up and a positive number to scroll down.
p_Lines | The number of lines to scroll. Use a negative number to scroll up and a positive number to scroll down.

#### Returns

The number of lines that the command scrolls. The value will be negative if scrolling up and positive if scrolling down.

### Edit_ScrollCaret

> Edit_ScrollCaret( | hEdit | )

#### Description

Scrolls the edit control until caret is visible.

### Edit_SetLimitText

> Edit_SetLimitText( | hEdit,
> | p_Limit | )

#### Description

Sets the text limit of the edit control.

#### Parameters

p_Limit | The maximum number of characters the user can enter. Windows NT+: If this parameter is zero, the text length is set to 0x7FFFFFFE characters for single-line edit controls or –1 for multiline edit controls.

#### Remarks

- This message limits only the text the user can enter. It does not affect any text already in the edit control when the message is sent, nor does it affect the length of the text copied to the edit control by the WM_SETTEXT message. For more information:

http://msdn.microsoft.com/en-us/library/bb761607(VS.85).aspx

- For AutoHotkey GUI’s, use the +Limitnn and -Limit options.
- Although this message can be sent to any edit control, not all programs will respond well to a limit change.

### Edit_SetMargins

> Edit_SetMargins( | hEdit, |  |
> | p_LeftMargin | = | "",
> | p_RightMargin | = | "" | )

#### Description

Sets the width of the left and/or right margin (in pixels) for the edit control. The message automatically redraws the control to reflect the new margins.

#### Parameters

p_LeftMargin | Left margin, in pixels. If blank, the left margin is not set. Specify the EC_USEFONTINFO value (0xFFFF or 65535) to set the left margin to a narrow width calculated using the text metrics of the control’s current font. If no font has been set for the control, the margin is set to zero.
p_RightMargin | Right margin, in pixels. If blank, the right margin is not set. Specify the EC_USEFONTINFO value (0xFFFF or 65535) to set the right margin to a narrow width calculated using the text metrics of the control’s current font. If no font has been set for the control, the margin is set to zero.

### Edit_SetModify

> Edit_SetModify( | hEdit,
> | p_Flag | )

#### Description

Sets or clears the modification flag for the edit control. The modification flag indicates whether the text within the control has been modified.

#### Parameters

p_Flag | Set to TRUE to set the modification flag. Set to FALSE to clear the modification flag.

### Edit_SetPasswordChar

> Edit_SetPasswordChar( | hEdit, |  |
> | p_Char | = | "*" | )

#### Description

Sets or removes the password character for a single-line edit control.

#### Parameters

p_Char | The character that is displayed in place of the characters typed by the user. [Optional] The default is an asterisk (“*”). Set to null (“”) to remove the password character.

#### Returns

Documented: This message does not return a value. Undocumented and/or does not apply to all OS versions: Returns TRUE if successful or “FAIL” if unsuccessful.

#### Remarks

- This request adds or removes the ES_Password style to/from a single-line edit control. Use the Edit_IsStyle function to determine if the ES_PASSWORD style has been set.
- Observation: On Windows 2000+, the ES_Password style cannot be removed once added unless the request is made from the same process that created the control.
- For AutoHotkey GUI’s, use the +Password and -Password options to add/remove ES_PASSWORD style unless a password character other than “*” is desired.

### Edit_SetReadOnly

> Edit_SetReadOnly( | hEdit,
> | p_Flag | )

#### Description

Sets or removes the read-only style (ES_READONLY) of the edit control.

#### Parameters

p_Flag | Set to TRUE to add the ES_READONLY style. Set to FALSE to remove the ES_READONLY style.

#### Returns

TRUE if successful, otherwise FALSE.

#### Remarks

For AutoHotkey GUIs, this is same as using the +ReadOnly or -ReadOnly option when creating the Edit control or using the GUIControl command after the edit control has been created. For example:

>     GUIControl +ReadOnly,Edit1

### Edit_SetRect

> Edit_SetRect( | hEdit,
> | p_Left,
> | p_Top,
> | p_Right,
> | p_Bottom | )

#### Description

Sets the formatting rectangle of a multiline edit control. The formatting rectangle is the limiting rectangle into which the control draws the text. The limiting rectangle is independent of the size of the edit control window.

#### Parameters

p_Left..p_Bottom | Coordinates.

#### Remarks

Advanced feature. For additional information, see the following...

http://msdn.microsoft.com/en-us/library/bb761657(VS.85).aspx

### Edit_SetTabStops

> Edit_SetTabStops( | hEdit, |  |
> | p_NbrOfTabStops | = | 0,
> | p_DTU | = | 32 | )

#### Description

Sets the tab stops in a multiline edit control. When text is copied to the control, any tab character in the text causes space to be generated up to the next tab stop.

#### Parameters

p_NbrOfTabStops | Number of tab stops. [Optional] Set to 0 (the default) to set the tab stops to the system default. Set to 1 to have all tab stops set to the value of the p_DTU parameter or 32 if p_DTU is not defined. Any value greater than 1 will set that number of tab stops.
p_DTU | Dialog Template Units. [Optional] If p_NbrOfTabStops=0, this parameter is ignored. If this parameter contains a single value (Ex: 21), all tab stops will be set to a factor of this value (Ex: 21, 42, 63, etc.). Otherwise, this parameter should contain values for all requested tab stops each separated by a comma “,” (Ex: “20,45,70,125”).

#### Returns

TRUE if all the tabs are set, otherwise FALSE.

### Edit_SetText

> Edit_SetText( | hEdit,
> | p_Text | )

#### Description

Set the text of the edit control. Returns TRUE if successful, otherwise FALSE.

#### Remarks

- The system automatically resets the undo flag whenever an edit control receives a WM_SETTEXT message. Use the Edit_SetSel (select all) and Edit_ReplaceSel functions to populate the control if undo is desired.
- This function is the same as the AutoHotkey ControlSetText command except there is no delay after the command has executed.

### Edit_SetSel

> Edit_SetSel( | hEdit, |  |
> | p_StartSelPos | = | 0,
> | p_EndSelPos | = | -1 | )

#### Description

Selects a range of characters.

#### Parameters

p_StartSelPos | Starting character position of the selection. If set to -1, the current selection (if any) will be deselected.
p_EndSelPos | Ending character position of the selection. Set to -1 to use the position of the last character in the control.

### Edit_TextIsSelected

> Edit_TextIsSelected( | hEdit | )

#### Description

Returns TRUE if text is selected, otherwise FALSE.

### Edit_Undo

> Edit_Undo( | hEdit | )

#### Description

Undo the last operation. Returns TRUE if the Undo operation succeeds, otherwise FALSE.

#### Returns

For a single-line edit control, the return value is always TRUE. For a multiline edit control, the return value is TRUE if the undo operation is successful, otherwise FALSE.

### Edit_GetActiveHandles

> Edit_GetActiveHandles( | ByRef | hEdit | = | "",
> | ByRef | hWindow | = | "",
> |  | p_MsgBox | = | False | )

#### Description

Finds the handles for the active control and active window.

#### Parameters

hEdit | Variable that contains the handle of the active edit control. [Optional] Value is zero if the active control is not an edit control.
hWindow | Variable that contains the handle of the active window. [Optional]
p_MsgBox | Display error message. [Optional] If TRUE, an error MsgBox is displayed if the active control is not an edit control.

#### Returns

Handle of the active edit control or FALSE (0) if the active control is not an edit control.

> Edit_CanUndo( | hEdit | )

Returns TRUE if there are any actions in the edit control’s undo queue, otherwise FALSE.

> Edit_CharFromPos( |  | hEdit, |  |
> |  | X, |  |
> |  | Y, |  |
> | ByRef | r_CharPos | = | "",
> | ByRef | r_LineIdx | = | "" | )

Gets information about the character and/or line closest to a specified point in the the client area of the edit control.

> Edit_Clear( | hEdit | )

Delete (clear) the current selection, if any, from the edit control.

> Edit_Convert2DOS( | p_Text | )

Converts Unix, DOS/Unix mix, and Mac file formats to DOS format.

> Edit_Convert2Mac( | p_Text | )

Convert DOS, DOS/Unix mix, and Unix file formats to Mac format.

> Edit_Convert2Unix( | p_Text | )

Convert DOS, DOS/Unix mix, and Mac formats to Unix format.

> Edit_ConvertCase( | hEdit,
> | p_Case | )

Convert case of selected text.

> Edit_Copy( | hEdit | )

Copy the current selection to the clipboard in CF_TEXT format.

> Edit_Cut( | hEdit | )

Delete the current selection, if any, and copy the deleted text to the clipboard in CF_TEXT format.

> Edit_EmptyUndoBuffer( | hEdit | )

Resets the undo flag of the edit control.

> Edit_FindText( |  | hEdit, |  |
> |  | p_SearchText, |  |
> |  | p_Min | = | 0,
> |  | p_Max | = | -1,
> |  | p_Flags | = | "",
> | ByRef | r_RegExOut | = | "" | )

Find text within the edit control.

> Edit_FmtLines( | hEdit,
> | p_Flag | )

Sets a flag that determines whether a multiline edit control includes soft line-break characters.

> Edit_GetFirstVisibleLine( | hEdit | )

Returns the zero-based index of the uppermost visible line.

> Edit_GetLastVisibleLine( | hEdit | )

Returns the zero-based line index of the last visible line on the edit control.

> Edit_GetLimitText( | hEdit | )

Returns the current text limit for the edit control.

> Edit_GetLine( | hEdit, |  |
> | p_LineIdx | = | -1,
> | p_Length | = | -1 | )

Get the text of the desired line from the edit control.

> Edit_GetLineCount( | hEdit | )

Returns an integer specifying the total number of text lines in a multiline edit control.

> Edit_GetMargins( |  | hEdit, |  |
> | ByRef | r_LeftMargin | = | "",
> | ByRef | r_RightMargin | = | "" | )

Gets the widths of the left and right margins for the edit control.

> Edit_GetModify( | hEdit | )

Gets the state of the edit control’s modification flag.

> Edit_GetRect( |  | hEdit, |  |
> | ByRef | r_Left | = | "",
> | ByRef | r_Top | = | "",
> | ByRef | r_Right | = | "",
> | ByRef | r_Bottom | = | "" | )

Gets the formatting rectangle of the edit control.

> Edit_GetSel( |  | hEdit, |  |
> | ByRef | r_StartSelPos | = | "",
> | ByRef | r_EndSelPos | = | "" | )

Gets the starting and ending character positions of the current selection in the edit control.

> Edit_GetSelText( | hEdit | )

Returns the currently selected text (if any).

> Edit_GetText( | hEdit, |  |
> | p_Length | = | -1 | )

Returns all text from the control up to p_Length length.

> Edit_GetTextLength( | hEdit | )

Returns the length, in characters, of the text in the edit control.

> Edit_GetTextRange( | hEdit, |  |
> | p_Min | = | 0,
> | p_Max | = | -1 | )

Get a range of characters.

> Edit_IsMultiline( | hEdit | )

Returns TRUE if the edit control is multiline, otherwise FALSE.

> Edit_IsReadOnly( | hEdit | )

Returns TRUE if the ES_READONLY style has been set, otherwise FALSE.

> Edit_IsStyle( | hEdit,
> | p_Style | )

Returns TRUE if the specified style has been set, otherwise FALSE.

> Edit_SetStyle( | hEdit, |  |
> | p_Style, |  |
> | p_Option | = | "+" | )

Adds, removes, or toggles a style for an edit control.

> Edit_LineFromChar( | hEdit, |  |
> | p_CharPos | = | -1 | )

Gets the index of the line that contains the specified character index.

> Edit_LineFromPos( |  | hEdit, |  |
> |  | X, |  |
> |  | Y, |  |
> | ByRef | r_CharPos | = | "",
> | ByRef | r_LineIdx | = | "" | )

This function is the same as Edit_CharFromPos except the line index (r_LineIdx) is returned.

> Edit_LineIndex( | hedit, |  |
> | p_LineIdx | = | -1 | )

Gets the character index of the first character of a specified line.

> Edit_LineLength( | hEdit, |  |
> | p_LineIdx | = | -1 | )

Gets the length of a line.

> Edit_LineScroll( | hEdit, |  |
> | xScroll | = | 0,
> | yScroll | = | 0 | )

Scrolls the text in the edit control for the current file.

> Edit_LoadFile( |  | hEdit, |  |
> |  | p_FileName, |  |
> |  | p_Convert2DOS | = | False,
> | ByRef | r_FileFormat | = | "" | )

Load the contents of a file to the edit control.

> Edit_Paste( | hEdit | )

Copies the current content of the clipboard to the edit control at the current caret position.

> Edit_PosFromChar( |  | hEdit,
> |  | p_CharPos,
> | ByRef | X,
> | ByRef | Y | )

Gets the client area coordinates of a specified character in the edit control.

> Edit_ReplaceSel( | hEdit, |  |
> | p_Text | = | "",
> | p_CanUndo | = | True | )

Replaces the selected text with the specified text.

> Edit_SaveFile( | hEdit, |  |
> | p_FileName, |  |
> | p_Convert | = | "" | )

Save the contents of the edit control to a file.

> Edit_Scroll( | hEdit, |  |
> | p_Pages | = | 0,
> | p_Lines | = | 0 | )

Scrolls the text vertically in the edit control.

> Edit_ScrollCaret( | hEdit | )

Scrolls the edit control until caret is visible.

> Edit_SetLimitText( | hEdit,
> | p_Limit | )

Sets the text limit of the edit control.

> Edit_SetMargins( | hEdit, |  |
> | p_LeftMargin | = | "",
> | p_RightMargin | = | "" | )

Sets the width of the left and/or right margin (in pixels) for the edit control.

> Edit_SetModify( | hEdit,
> | p_Flag | )

Sets or clears the modification flag for the edit control.

> Edit_SetPasswordChar( | hEdit, |  |
> | p_Char | = | "*" | )

Sets or removes the password character for a single-line edit control.

> Edit_SetReadOnly( | hEdit,
> | p_Flag | )

Sets or removes the read-only style (ES_READONLY) of the edit control.

> Edit_SetRect( | hEdit,
> | p_Left,
> | p_Top,
> | p_Right,
> | p_Bottom | )

Sets the formatting rectangle of a multiline edit control.

> Edit_SetTabStops( | hEdit, |  |
> | p_NbrOfTabStops | = | 0,
> | p_DTU | = | 32 | )

Sets the tab stops in a multiline edit control.

> Edit_SetText( | hEdit,
> | p_Text | )

Set the text of the edit control.

> Edit_SetSel( | hEdit, |  |
> | p_StartSelPos | = | 0,
> | p_EndSelPos | = | -1 | )

Selects a range of characters.

> Edit_TextIsSelected( | hEdit | )

Returns TRUE if text is selected, otherwise FALSE.

> Edit_Undo( | hEdit | )

Undo the last operation.

> Edit_GetActiveHandles( | ByRef | hEdit | = | "",
> | ByRef | hWindow | = | "",
> |  | p_MsgBox | = | False | )

Finds the handles for the active control and active window.
Close