An edit control is a rectangular control window typically used in a dialog box to permit the user to enter and edit text by typing on the keyboard.
Edit controls support both the Unicode character set in which characters are two bytes, and ANSI character sets in which characters are one byte.
An edit control is selected and receives the input focus when a user clicks
the mouse inside it or presses the TAB key. After it is selected, the edit
control displays its text (if any) and a flashing caret that indicates the
insertion point. The user can then enter text, move the insertion point, or
select text to be edited by using the keyboard or the mouse. An edit control can
send notification messages to its parent window in the form of
A combo box is a control that combines much of the functionality of an edit
control and a list box. In a combo box, the edit control displays the current
selection and the list box presents options a user can select. For more
information about combo boxes, see
Styles
The system stores edit control text in a buffer and copies it to the control, as necessary.
When the system creates an edit control, it automatically creates a text
buffer, sets its initial size, and increases the size as necessary. The size can
be up to a predefined limit of approximately 32 kilobyte (KB) for single-line
edit controls. Because this limit can change, it is called a soft limit. An
application can set a hard limit to the buffer size by sending an
The system typically creates an edit control buffer in a dialog box, using
memory outside the application's data segment. An application can suppress this
default allocation behavior and create the buffer from its local heap by using
the DS_LOCALEDIT style (see "Dialog Box Template Styles" in
To save the current buffer and obtain a new one:
The EM_SETHANDLE and EM_GETHANDLE messages apply only to multiline edit controls.
An application that uses the default allocation behavior (that is, does not use the DS_LOCALEDIT style (see "Dialog Box Template Styles" in About Dialog Boxes)) must not send EM_SETHANDLE and EM_GETHANDLE messages to the edit control.
Sending an EM_SETHANDLE message has several side effects: it clears
the undo flag (making the
An application can initialize or reinitialize an edit control's text buffer
by calling the
For each edit control, the system maintains a read-only flag that indicates
whether the control's text is read-write (the default) or read-only. An
application can set the read-write flag or the read-only flag for the text by
sending the control an
The visibility of an edit control's text is governed by the dimensions of its window rectangle and its formatting rectangle. The window rectangle is the client area of the window containing the edit control. The formatting rectangle is a construct maintained by the system for formatting the text displayed in the window rectangle. When an edit control is first displayed, the two rectangles are identical on the screen. An application can make the formatting rectangle larger than the window rectangle (thereby limiting the visibility of the edit control's text) or smaller than the window rectangle (thereby creating extra white space around the text).
An application can set the coordinates of an edit control's formatting
rectangle by sending it an
The user makes editing requests by using the keyboard and mouse. The system sends each request to the edit control's parent window in the form of a WM_COMMAND message. The message includes the edit control identifier in the low-order word of the wParam parameter, the handle of the edit control in the lParam parameter, and an edit control notification message corresponding to the user's action in the high-order word of the wParam parameter.
An application should examine each notification message and respond appropriately. The following table lists each edit control notification message and the action that generates it.
| Notification message | User action |
|---|---|
| The user has modified text in an edit control. The system updates the
display before sending this message (unlike |
|
| EN_ERRSPACE | The edit control cannot allocate enough memory to meet a specific request. |
| The user has clicked the edit control's horizontal scroll bar. The system sends this message before updating the screen. | |
| The user has selected another control. | |
| While inserting text, the user has exceeded the specified number of characters for the edit control. Insertion has been truncated. This message is also sent either when an edit control does not have the ES_AUTOHSCROLL style and the number of characters to be inserted exceeds the width of the edit control or when an edit control does not have the ES_AUTOVSCROLL style and the total number of lines to be inserted exceeds the height of the edit control. | |
| The user has selected this edit control. | |
| EN_UPDATE | The user has altered the text in the edit control and the system is about to display the new text. The system sends this message after formatting the text, but before displaying it, so that the application can resize the edit control window. |
| The user has clicked the edit control's vertical scroll bar or has scrolled the mouse wheel over the edit control. The system sends this message before updating the screen. |
In addition, the system sends a