Edit Control

This section contains information about the programming elements used with edit controls. 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.

Overviews

TopicContents
About Edit Controls

An edit control is a rectangular control window typically used in a dialog box to enable the user to enter and edit text.

Edit Control Text Operations

The system automatically processes all user-initiated text operations and notifies the application when the operations are completed.

Using Edit Controls

Edit controls are typically used in dialog boxes, but you can use them in the client area of a standard window as well. Single-line edit controls are useful for retrieving a single string from the user. Multiline edit controls make it easy for your application to implement most of the features of a simple word processor.

 

Functions

TopicContents
EditWordBreakProc

An application-defined callback function used with the EM_SETWORDBREAKPROC message. A multiline edit control or a rich edit control calls an EditWordBreakProc function to break a line of text.

The EDITWORDBREAKPROC type defines a pointer to this callback function. EditWordBreakProc is a placeholder for the application-defined function name.

 

Macros

TopicContents
Edit_CanUndo

Determines whether there are any actions in the undo queue of an edit or rich edit control. You can use this macro or send the EM_CANUNDO message explicitly.

Edit_EmptyUndoBuffer

Resets the undo flag of an edit or rich edit control. The undo flag is set whenever an operation within the edit control can be undone. You can use this macro or send the EM_EMPTYUNDOBUFFER message explicitly.

Edit_Enable

Enables or disables an edit control.

Edit_FmtLines

Sets a flag that determines whether text retrieved from 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 wordwrapping. You can use this macro or send the EM_FMTLINES message explicitly.

Edit_GetCueBannerText

Gets the text that is displayed as a textual cue, or tip, in an edit control. You can use this macro or send the EM_GETCUEBANNER message explicitly.

Edit_GetFirstVisibleLine

Gets the index of the uppermost visible line in a multiline edit or rich edit control. You can use this macro or send the EM_GETFIRSTVISIBLELINE message explicitly.

Edit_GetHandle

Gets a handle to the memory currently allocated for the text of a multiline edit control. You can use this macro or send the EM_GETHANDLE message explicitly.

Edit_GetHilite

Not implemented.

Edit_GetLine

Retrieves a line of text from an edit or rich edit control. You can use this macro or send the EM_GETLINE message explicitly.

Edit_GetLineCount

Gets the number of lines in the text of an edit control. You can use this macro or send the EM_GETLINECOUNT message explicitly.

Edit_GetModify

Gets the state of an edit or rich edit control's modification flag. The flag indicates whether the contents of the control have been modified. You can use this macro or send the EM_GETMODIFY message explicitly.

Edit_GetPasswordChar

Gets the password character for an edit or rich edit control. You can use this macro or send the EM_GETPASSWORDCHAR message explicitly.

Edit_GetRect

Gets the formatting rectangle of an edit control. You can use this macro or send the EM_GETRECT message explicitly.

Edit_GetSel

Gets the starting and ending character positions of the current selection in an edit or rich edit control. You can use this macro or send the EM_GETSEL message explicitly.

Edit_GetText

Gets the text of an edit control.

Edit_GetTextLength

Gets the number of characters in the text of an edit control.

Edit_GetWordBreakProc

Retrieves the address of an edit or rich edit control's Wordwrap function. You can use this macro or send the EM_GETWORDBREAKPROC message explicitly.

Edit_HideBalloonTip

Hides any balloon tip associated with an edit control. You can use this macro or send the EM_HIDEBALLOONTIP message explicitly.

Edit_LimitText

Limits the length of text that can be entered into an edit control. You can use this macro or send the EM_LIMITTEXT message explicitly.

Edit_LineFromChar

Gets the index of the line that contains the specified character index in a multiline edit or rich edit control. You can use this macro or send the EM_LINEFROMCHAR message explicitly.

Edit_LineIndex

Gets the character index of the first character of a specified line in a multiline edit or rich edit control. You can use this macro or send the EM_LINEINDEX message explicitly.

Edit_LineLength

Retrieves the length, in characters, of a line in an edit or rich edit control. You can use this macro or send the EM_LINELENGTH message explicitly.

Edit_NoSetFocus

Intended for internal use; not recommended for use in applications.

Prevents a single-line edit control from receiving keyboard focus. You can use this macro or send the EM_NOSETFOCUS message explicitly.

Edit_ReplaceSel

Replaces the selected text in an edit control or a rich edit control with the specified text. You can use this macro or send the EM_REPLACESEL message explicitly.

Edit_Scroll

Scrolls the text vertically in a multiline edit or rich edit control. You can use this macro or send the EM_SCROLL message explicitly.

Edit_ScrollCaret

Scrolls the caret into view in an edit or rich edit control. You can use this macro or send the EM_SCROLLCARET message explicitly.

Edit_SetCueBannerText

Sets the text that is displayed as the textual cue, or tip, for an edit control. You can use this macro or send the EM_SETCUEBANNER message explicitly.

Edit_SetCueBannerTextFocused

Sets the text that is displayed as the textual cue, or tip, for an edit control. You can use this macro or send the EM_SETCUEBANNER message explicitly.

Edit_SetHandle

Sets the handle of the memory that will be used by a multiline edit control. You can use this macro or send the EM_SETHANDLE message explicitly.

Edit_SetHilite

Not implemented.

Edit_SetModify

Sets or clears the modification flag for an edit control. The modification flag indicates whether the text within the edit control has been modified. You can use this macro or send the EM_SETMODIFY message explicitly.

Edit_SetPasswordChar

Sets or removes the password character for an edit or rich edit control. When a password character is set, that character is displayed in place of the characters typed by the user. You can use this macro or send the EM_SETPASSWORDCHAR message explicitly.

Edit_SetReadOnly

Sets or removes the read-only style (ES_READONLY) of an edit or rich edit control. You can use this macro or send the EM_SETREADONLY message explicitly.

Edit_SetRect

Sets the formatting rectangle of an edit control. You can use this macro or send the EM_SETRECT message explicitly.

Edit_SetRectNoPaint

Sets the formatting rectangle of a multiline edit control. This macro is equivalent to Edit_SetRect, except that it does not redraw the edit control window. You can use this macro or send the EM_SETRECTNP message explicitly.

Edit_SetSel

Selects a range of characters in an edit or rich edit control. You can use this macro or send the EM_SETSEL message explicitly.

Edit_SetTabStops

Sets the tab stops in a multiline edit or rich 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. You can use this macro or send the EM_SETTABSTOPS message explicitly.

Edit_SetText

Sets the text of an edit control.

Edit_SetWordBreakProc

Replaces an edit control's default Wordwrap function with an application-defined Wordwrap function. You can use this macro or send the EM_SETWORDBREAKPROC message explicitly.

Edit_ShowBalloonTip

Displays a balloon tip associated with an edit control. You can use this macro or send the EM_SHOWBALLOONTIP message explicitly.

Edit_TakeFocus

Intended for internal use; not recommended for use in applications.

Forces a single-line edit control to receive keyboard focus. You can use this macro or send the EM_TAKEFOCUS message explicitly.

Edit_Undo

Undoes the last operation in the undo queue of an edit or rich edit control. You can use this macro or send the EM_UNDO message explicitly.

 

Messages

TopicContents
EM_CANUNDO

Determines whether there are any actions in an edit control's undo queue. You can send this message to either an edit control or a rich edit control.

EM_CHARFROMPOS

Gets information about the character closest to a specified point in the client area of an edit control. You can send this message to either an edit control or a rich edit control.

EM_EMPTYUNDOBUFFER

Resets the undo flag of an edit control. The undo flag is set whenever an operation within the edit control can be undone. You can send this message to either an edit control or a rich edit control.

EM_FMTLINES

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 wordwrapping.

EM_GETCUEBANNER

Gets the text that is displayed as the textual cue, or tip, in an edit control.

EM_GETFIRSTVISIBLELINE

Gets the zero-based index of the uppermost visible line in a multiline edit control. You can send this message to either an edit control or a rich edit control.

EM_GETHANDLE

Gets a handle of the memory currently allocated for a multiline edit control's text.

EM_GETHILITE

Not implemented.

EM_GETIMESTATUS

Gets a set of status flags that indicate how the edit control interacts with the Input Method Editor (IME).

EM_GETLIMITTEXT

Gets the current text limit for an edit control. You can send this message to either an edit control or a rich edit control.

EM_GETLINE

Copies a line of text from an edit control and places it in a specified buffer. You can send this message to either an edit control or a rich edit control.

EM_GETLINECOUNT

Gets the number of lines in a multiline edit control. You can send this message to either an edit control or a rich edit control.

EM_GETMARGINS

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

EM_GETMODIFY

Gets the state of an edit control's modification flag. The flag indicates whether the contents of the edit control have been modified. You can send this message to either an edit control or a rich edit control.

EM_GETPASSWORDCHAR

Gets the password character that an edit control displays when the user enters text. You can send this message to either an edit control or a rich edit control.

EM_GETRECT

Gets the formatting rectangle of an 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. You can send this message to either an edit control or a rich edit control.

EM_GETSEL

Gets the starting and ending character positions (in TCHARs) of the current selection in an edit control. You can send this message to either an edit control or a rich edit control.

EM_GETTHUMB

Gets the position of the scroll box (thumb) in the vertical scroll bar of a multiline edit control. You can send this message to either an edit control or a rich edit control.

EM_GETWORDBREAKPROC

Gets the address of the current Wordwrap function. You can send this message to either an edit control or a rich edit control.

EM_HIDEBALLOONTIP

Hides any balloon tip associated with an edit control.

EM_LIMITTEXT

Sets the text limit of an edit control. The text limit is the maximum amount of text, in TCHARs, that the user can type into the edit control. You can send this message to either an edit control or a rich edit control.

For edit controls and Microsoft Rich Edit 1.0, bytes are used. For Microsoft Rich Edit 2.0 and later, characters are used.

EM_LINEFROMCHAR

Gets the index of the line that contains the specified character index in a multiline edit control. A character index is the zero-based index of the character from the beginning of the edit control. You can send this message to either an edit control or a rich edit control.

EM_LINEINDEX

Gets the character index of the first character of a specified line in a multiline edit control. A character index is the zero-based index of the character from the beginning of the edit control. You can send this message to either an edit control or a rich edit control.

EM_LINELENGTH

Retrieves the length, in characters, of a line in an edit control. You can send this message to either an edit control or a rich edit control.

EM_LINESCROLL

Scrolls the text in a multiline edit control.

EM_NOSETFOCUS

Intended for internal use; not recommended for use in applications.

Prevents a single-line edit control from receiving keyboard focus. You can send this message explicitly or by using the Edit_NoSetFocus macro.

EM_POSFROMCHAR

Retrieves the client area coordinates of a specified character in an edit control. You can send this message to either an edit control or a rich edit control.

EM_REPLACESEL

Replaces the selected text in an edit control or a rich edit control with the specified text.

EM_SCROLL

Scrolls the text vertically in a multiline edit control. This message is equivalent to sending a WM_VSCROLL message to the edit control. You can send this message to either an edit control or a rich edit control.

EM_SCROLLCARET

Scrolls the caret into view in an edit control. You can send this message to either an edit control or a rich edit control.

EM_SETCUEBANNER

Sets the textual cue, or tip, that is displayed by the edit control to prompt the user for information.

EM_SETHANDLE

Sets the handle of the memory that will be used by a multiline edit control.

EM_SETHILITE

Not implemented.

EM_SETIMESTATUS

Sets the status flags that determine how an edit control interacts with the IME.

EM_SETLIMITTEXT

Sets the text limit of an edit control. The text limit is the maximum amount of text, in TCHARs, that the user can type into the edit control. You can send this message to either an edit control or a rich edit control.

For edit controls and Microsoft Rich Edit 1.0, bytes are used. For Microsoft Rich Edit 2.0 and later, characters are used.

The EM_SETLIMITTEXT message is identical to the EM_LIMITTEXT message.

EM_SETMARGINS

Sets the widths of the left and right margins for an edit control. The message redraws the control to reflect the new margins. You can send this message to either an edit control or a rich edit control.

EM_SETMODIFY

Sets or clears the modification flag for an edit control. The modification flag indicates whether the text within the edit control has been modified. You can send this message to either an edit control or a rich edit control.

EM_SETPASSWORDCHAR

Sets or removes the password character for an edit control. When a password character is set, that character is displayed in place of the characters typed by the user. You can send this message to either an edit control or a rich edit control.

EM_SETREADONLY

Sets or removes the read-only style (ES_READONLY) of an edit control. You can send this message to either an edit control or a rich edit control.

EM_SETRECT

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.

This message is processed only by multiline edit controls. You can send this message to either an edit control or a rich edit control.

EM_SETRECTNP

Sets the formatting rectangle of a multiline edit control. The EM_SETRECTNP message is identical to the EM_SETRECT message, except that EM_SETRECTNP does not redraw the edit control window.

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.

This message is processed only by multiline edit controls. You can send this message to either an edit control or a rich edit control.

EM_SETSEL

Selects a range of characters in an edit control. You can send this message to either an edit control or a rich edit control.

EM_SETTABSTOPS

The EM_SETTABSTOPS message 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.

This message is processed only by multiline edit controls. You can send this message to either an edit control or a rich edit control.

EM_SETWORDBREAKPROC

Replaces an edit control's default Wordwrap function with an application-defined Wordwrap function. You can send this message to either an edit control or a rich edit control.

EM_SHOWBALLOONTIP

The EM_SHOWBALLOONTIP message displays a balloon tip associated with an edit control.

EM_TAKEFOCUS

Intended for internal use; not recommended for use in applications.

Forces a single-line edit control to receive keyboard focus. You can send this message explicitly or by using the Edit_TakeFocus macro.

EM_UNDO

This message undoes the last edit control operation in the control's undo queue. You can send this message to either an edit control or a rich edit control.

WM_UNDO

An application sends a WM_UNDO message to an edit control to undo the last operation. When this message is sent to an edit control, the previously deleted text is restored or the previously added text is deleted.

 

Notifications

TopicContents
EN_ALIGN_LTR_EC

Sent when the user has changed the edit control direction to left-to-right. The parent window of the edit control receives this notification code through a WM_COMMAND message.

EN_ALIGN_RTL_EC

Sent when the user has changed the edit control direction to right-to-left. The parent window of the edit control receives this notification code through a WM_COMMAND message.

EN_CHANGE

Sent when the user has taken an action that may have altered text in an edit control. Unlike the EN_UPDATE notification code, this notification code is sent after the system updates the screen. The parent window of the edit control receives this notification code through a WM_COMMAND message.

EN_ERRSPACE

Sent when an edit control cannot allocate enough memory to meet a specific request. The parent window of the edit control receives this notification code through a WM_COMMAND message.

EN_HSCROLL

Sent when the user clicks an edit control's horizontal scroll bar. The parent window of the edit control receives this notification code through a WM_COMMAND message. The parent window is notified before the screen is updated.

EN_KILLFOCUS

The EN_KILLFOCUS notification code is sent when an edit control loses the keyboard focus. The parent window of the edit control receives this notification code through a WM_COMMAND message.

EN_MAXTEXT

Sent when the current text insertion has exceeded the specified number of characters for the edit control. The text insertion has been truncated.

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.

The parent window of the edit control receives this notification code through a WM_COMMAND message.

EN_SETFOCUS

Sent when an edit control receives the keyboard focus. The parent window of the edit control receives this notification code through a WM_COMMAND message.

EN_UPDATE

Sent when an edit control is about to redraw itself. This notification code is sent after the control has formatted the text, but before it displays the text. This makes it possible to resize the edit control window, if necessary. The parent window of the edit control receives this notification code through a WM_COMMAND message.

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. The parent window of the edit control receives this notification code through a WM_COMMAND message. The parent window is notified before the screen is updated.

WM_CTLCOLOREDIT

An edit control that is not read-only or disabled sends the WM_CTLCOLOREDIT message to its parent window when the control is about to be drawn. By responding to this message, the parent window can use the specified device context handle to set the text and background colors of the edit control.

 

Structures

TopicContents
EDITBALLOONTIP

Contains information about a balloon tip associated with a button control.

 

Constants

TopicContents
Edit Control Styles

To create an edit control using the CreateWindow or CreateWindowEx function, specify the EDIT class, appropriate window style constants, and a combination of the following edit control styles. After the control has been created, these styles cannot be modified, except as noted.

 

 

 

Community Additions

ADD
Show:
© 2014 Microsoft