# Function Reference

# _GUICtrlEdit_Create

Create an Edit control

#include <GuiEdit.au3>
_GUICtrlEdit_Create ( $hWnd, $sText, $iX, $iY [, $iWidth = 150 [, $iHeight = 150 [, $iStyle = 0x003010C4 [, $iExStyle = 0x00000200]]]] )

## Parameters

$hWnd | Handle to parent or owner window
$sText | Text to be displayed in the control
$iX | Horizontal position of the control
$iY | Vertical position of the control
$iWidth | [optional] Control width
$iHeight | [optional] Control height
$iStyle | [optional] Control styles: $ES_AUTOHSCROLL - Automatically scrolls text to the right by 10 characters when the user types a character at the end of the line. $ES_AUTOVSCROLL - Automatically scrolls text up one page when the user presses the ENTER key on the last line. $ES_CENTER - Centers text in an 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. $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. $ES_OEMCONVERT - Converts text entered in the edit control. $ES_READONLY - Prevents the user from typing or editing text in the edit control. $ES_RIGHT - Right-aligns text 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. $ES_PASSWORD - Displays an asterisk (*) for each character that is typed into the edit control Default: $ES_MULTILINE, $ES_WANTRETURN, $WS_VSCROLL, $WS_HSCROLL, $ES_AUTOVSCROLL, $ES_AUTOHSCROLL Forced : WS_CHILD, $WS_VISIBLE, $WS_TABSTOP only if not using $ES_READONLY
$iExStyle | [optional] Control extended style. These correspond to the standard $WS_EX_* constants. See Extended Style Table.

## Return Value

Success: | the handle to the Edit control.
Failure: | 0.

## Remarks

This function is for Advanced users and for learning how the control works.

## Related

_GUICtrlEdit_Destroy

## Example

### Example 1 : _GUICtrlEdit_AppendText()

    #include "Extras\WM_NOTIFY.au3"

    #include <GUIConstantsEx.au3>
    #include <GuiEdit.au3>
    #include <WinAPIConv.au3>
    #include <WindowsNotifsConstants.au3>

    Global $g_hEdit

    Example()

    Func Example()
        ; Create GUI
        Local $hGUI = GUICreate("Edit Create (v" & @AutoItVersion & ")", 400, 300)
        $g_hEdit = _GUICtrlEdit_Create($hGUI, "This is a test" & @CRLF & "Another Line", 2, 2, 394, 268)
        GUISetState(@SW_SHOW)

        GUIRegisterMsg($WM_COMMAND, "WM_COMMAND")

        _GUICtrlEdit_AppendText($g_hEdit, @CRLF & "Append to the end?")

        ; Loop until the user exits.
        Do
        Until GUIGetMsg() = $GUI_EVENT_CLOSE
        GUIDelete()
    EndFunc   ;==>Example

    Func WM_COMMAND($hWnd, $iMsg, $wParam, $lParam)
        #forceref $hWnd, $iMsg
        Local $hWndEdit = $g_hEdit
        If Not IsHWnd($g_hEdit) Then $hWndEdit = GUICtrlGetHandle($g_hEdit)
        Local $hWndFrom = $lParam
        Local $iIDFrom = _WinAPI_LoWord($wParam)
        Local $iCode = _WinAPI_HiWord($wParam)
        Switch $hWndFrom
            Case $g_hEdit, $hWndEdit
                Switch $iCode
                    Case $EN_ALIGN_LTR_EC ; Sent when the user has changed the edit control direction to left-to-right
                        _WM_NOTIFY_DebugInfo("$EN_ALIGN_LTR_EC", "hWndFrom,IDFrom", $hWndFrom, $iIDFrom)
                        ; no return value
                    Case $EN_ALIGN_RTL_EC ; Sent when the user has changed the edit control direction to right-to-left
                        _WM_NOTIFY_DebugInfo("$EN_ALIGN_RTL_EC", "hWndFrom,IDFrom", $hWndFrom, $iIDFrom)
                        ; no return value
                    Case $EN_CHANGE ; Sent when the user has taken an action that may have altered text in an edit control
                        _WM_NOTIFY_DebugInfo("$EN_CHANGE", "hWndFrom,IDFrom", $hWndFrom, $iIDFrom)
                        ; no return value
                    Case $EN_ERRSPACE ; Sent when an edit control cannot allocate enough memory to meet a specific request
                        _WM_NOTIFY_DebugInfo("$EN_ERRSPACE", "hWndFrom,IDFrom", $hWndFrom, $iIDFrom)
                        ; no return value
                    Case $EN_HSCROLL ; Sent when the user clicks an edit control's horizontal scroll bar
                        _WM_NOTIFY_DebugInfo("$EN_HSCROLL", "hWndFrom,IDFrom", $hWndFrom, $iIDFrom)
                        ; no return value
                    Case $EN_KILLFOCUS ; Sent when an edit control loses the keyboard focus
                        _WM_NOTIFY_DebugInfo("$EN_KILLFOCUS", "hWndFrom,IDFrom", $hWndFrom, $iIDFrom)
                        ; no return value
                    Case $EN_MAXTEXT ; Sent when the current text insertion has exceeded the specified number of characters for the edit control
                        _WM_NOTIFY_DebugInfo("$EN_MAXTEXT", "hWndFrom,IDFrom", $hWndFrom, $iIDFrom)
                        ; This message is also sent when an edit control does not have the $ES_AUTOHSCROLL style and the number of characters to be
                        ; inserted would exceed the width of the edit control.
                        ; This message is also sent when an edit control does not have the $ES_AUTOVSCROLL style and the total number of lines resulting
                        ; from a text insertion would exceed the height of the edit control

                        ; no return value
                    Case $EN_SETFOCUS ; Sent when an edit control receives the keyboard focus
                        _WM_NOTIFY_DebugInfo("$EN_SETFOCUS", "hWndFrom,IDFrom", $hWndFrom, $iIDFrom)
                        ; no return value
                    Case $EN_UPDATE ; Sent when an edit control is about to redraw itself
                        _WM_NOTIFY_DebugInfo("$EN_UPDATE", "hWndFrom,IDFrom", $hWndFrom, $iIDFrom)
                        ; no return value
                    Case $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
                        _WM_NOTIFY_DebugInfo("$EN_VSCROLL", "hWndFrom,IDFrom", $hWndFrom, $iIDFrom)
                        ; no return value
                EndSwitch
        EndSwitch
        Return $GUI_RUNDEFMSG
    EndFunc   ;==>WM_COMMAND

### Example 2 : _GUICtrlEdit_SetText()

    #include "Extras\WM_NOTIFY.au3"

    #include <GUIConstantsEx.au3>
    #include <GuiEdit.au3>
    #include <WinAPIConv.au3>
    #include <WindowsNotifsConstants.au3>

    Global $g_hEdit

    Example()

    Func Example()
        ; Create GUI
        Local $hGUI = GUICreate("Edit Create (v" & @AutoItVersion & ")", 400, 300)
        $g_hEdit = _GUICtrlEdit_Create($hGUI, "", 2, 2, 394, 268)
        GUISetState(@SW_SHOW)

        GUIRegisterMsg($WM_COMMAND, "WM_COMMAND")

        _GUICtrlEdit_SetText($g_hEdit, "This is a test" & @CRLF & "Another Line")

        ; Loop until the user exits.
        Do
        Until GUIGetMsg() = $GUI_EVENT_CLOSE
        GUIDelete()
    EndFunc   ;==>Example

    Func WM_COMMAND($hWnd, $iMsg, $wParam, $lParam)
        #forceref $hWnd, $iMsg
        Local $hWndEdit = $g_hEdit
        If Not IsHWnd($g_hEdit) Then $hWndEdit = GUICtrlGetHandle($g_hEdit)
        Local $hWndFrom = $lParam
        Local $iIDFrom = _WinAPI_LoWord($wParam)
        Local $iCode = _WinAPI_HiWord($wParam)
        Switch $hWndFrom
            Case $g_hEdit, $hWndEdit
                Switch $iCode
                    Case $EN_ALIGN_LTR_EC ; Sent when the user has changed the edit control direction to left-to-right
                        _WM_NOTIFY_DebugInfo("$EN_ALIGN_LTR_EC", "hWndFrom,IDFrom", $hWndFrom, $iIDFrom)
                        ; no return value
                    Case $EN_ALIGN_RTL_EC ; Sent when the user has changed the edit control direction to right-to-left
                        _WM_NOTIFY_DebugInfo("$EN_ALIGN_RTL_EC", "hWndFrom,IDFrom", $hWndFrom, $iIDFrom)
                        ; no return value
                    Case $EN_CHANGE ; Sent when the user has taken an action that may have altered text in an edit control
                        _WM_NOTIFY_DebugInfo("$EN_CHANGE", "hWndFrom,IDFrom", $hWndFrom, $iIDFrom)
                        ; no return value
                    Case $EN_ERRSPACE ; Sent when an edit control cannot allocate enough memory to meet a specific request
                        _WM_NOTIFY_DebugInfo("$EN_ERRSPACE", "hWndFrom,IDFrom", $hWndFrom, $iIDFrom)
                        ; no return value
                    Case $EN_HSCROLL ; Sent when the user clicks an edit control's horizontal scroll bar
                        _WM_NOTIFY_DebugInfo("$EN_HSCROLL", "hWndFrom,IDFrom", $hWndFrom, $iIDFrom)
                        ; no return value
                    Case $EN_KILLFOCUS ; Sent when an edit control loses the keyboard focus
                        _WM_NOTIFY_DebugInfo("$EN_KILLFOCUS", "hWndFrom,IDFrom", $hWndFrom, $iIDFrom)
                        ; no return value
                    Case $EN_MAXTEXT ; Sent when the current text insertion has exceeded the specified number of characters for the edit control
                        _WM_NOTIFY_DebugInfo("$EN_MAXTEXT", "hWndFrom,IDFrom", $hWndFrom, $iIDFrom)
                        ; This message is also sent when an edit control does not have the $ES_AUTOHSCROLL style and the number of characters to be
                        ; inserted would exceed the width of the edit control.
                        ; This message is also sent when an edit control does not have the $ES_AUTOVSCROLL style and the total number of lines resulting
                        ; from a text insertion would exceed the height of the edit control

                        ; no return value
                    Case $EN_SETFOCUS ; Sent when an edit control receives the keyboard focus
                        _WM_NOTIFY_DebugInfo("$EN_SETFOCUS", "hWndFrom,IDFrom", $hWndFrom, $iIDFrom)
                        ; no return value
                    Case $EN_UPDATE ; Sent when an edit control is about to redraw itself
                        _WM_NOTIFY_DebugInfo("$EN_UPDATE", "hWndFrom,IDFrom", $hWndFrom, $iIDFrom)
                        ; no return value
                    Case $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
                        _WM_NOTIFY_DebugInfo("$EN_VSCROLL", "hWndFrom,IDFrom", $hWndFrom, $iIDFrom)
                        ; no return value
                EndSwitch
        EndSwitch
        Return $GUI_RUNDEFMSG
    EndFunc   ;==>WM_COMMAND