CEdit Class
Provides the functionality of a Windows edit control.
class CEdit : public CWnd
Members
Public Constructors
Name |
Description |
---|---|
Constructs a CEdit control object. |
Public Methods
Name |
Description |
---|---|
Determines whether an edit-control operation can be undone. |
|
Retrieves the line and character indexes for the character closest to a specified position. |
|
Deletes (clears) the current selection (if any) in the edit control. |
|
Copies the current selection (if any) in the edit control to the Clipboard in CF_TEXT format. |
|
Creates the Windows edit control and attaches it to the CEdit object. |
|
Deletes (cuts) the current selection (if any) in the edit control and copies the deleted text to the Clipboard in CF_TEXT format. |
|
Resets (clears) the undo flag of an edit control. |
|
Sets the inclusion of soft line-break characters on or off within a multiple-line edit control. |
|
Retrieves the text that is displayed as the text cue, or tip, in an edit control when the control is empty and does not have focus. |
|
Determines the topmost visible line in an edit control. |
|
Retrieves a handle to the memory that is currently allocated for a multiple-line edit control. |
|
Gets the indexes of the starting and ending characters in a range of text that is highlighted in the current edit control. |
|
Gets the maximum amount of text this CEdit can contain. |
|
Retrieves a line of text from an edit control. |
|
Retrieves the number of lines in a multiple-line edit control. |
|
Gets the left and right margins for this CEdit. |
|
Determines whether the contents of an edit control have been modified. |
|
Retrieves the password character displayed in an edit control when the user enters text. |
|
Gets the formatting rectangle of an edit control. |
|
Gets the first and last character positions of the current selection in an edit control. |
|
Hides any balloon tip associated with the current edit control. |
|
Limits the length of the text that the user can enter into an edit control. |
|
Retrieves the line number of the line that contains the specified character index. |
|
Retrieves the character index of a line within a multiple-line edit control. |
|
Retrieves the length of a line in an edit control. |
|
Scrolls the text of a multiple-line edit control. |
|
Inserts the data from the Clipboard into the edit control at the current cursor position. Data is inserted only if the Clipboard contains data in CF_TEXT format. |
|
Retrieves the coordinates of the upper-left corner of a specified character index. |
|
Replaces the current selection in an edit control with the specified text. |
|
Sets the text that is displayed as the text cue, or tip, in an edit control when the control is empty and does not have focus. |
|
Sets the handle to the local memory that will be used by a multiple-line edit control. |
|
Highlights a range of text that is displayed in the current edit control. |
|
Sets the maximum amount of text this CEdit can contain. |
|
Sets the left and right margins for this CEdit. |
|
Sets or clears the modification flag for an edit control. |
|
Sets or removes a password character displayed in an edit control when the user enters text. |
|
Sets the read-only state of an edit control. |
|
Sets the formatting rectangle of a multiple-line edit control and updates the control. |
|
Sets the formatting rectangle of a multiple-line edit control without redrawing the control window. |
|
Selects a range of characters in an edit control. |
|
Sets the tab stops in a multiple-line edit control. |
|
Displays a balloon tip that is associated with the current edit control. |
|
Reverses the last edit-control operation. |
Remarks
An edit control is a rectangular child window in which the user can enter text.
You can create an edit control either from a dialog template or directly in your code. In both cases, first call the constructor CEdit to construct the CEdit object, then call the Create member function to create the Windows edit control and attach it to the CEdit object.
Construction can be a one-step process in a class derived from CEdit. Write a constructor for the derived class and call Create from within the constructor.
CEdit inherits significant functionality from CWnd. To set and retrieve text from a CEdit object, use the CWnd member functions SetWindowText and GetWindowText, which set or get the entire contents of an edit control, even if it is a multiline control. Text lines in a multiline control are separated by '\r\n' character sequences. Also, if an edit control is multiline, get and set part of the control's text by calling the CEdit member functions GetLine, SetSel, GetSel, and ReplaceSel.
If you want to handle Windows notification messages sent by an edit control to its parent (usually a class derived from CDialog), add a message-map entry and message-handler member function to the parent class for each message.
Each message-map entry takes the following form:
ON_Notification( id, memberFxn )
where id specifies the child window ID of the edit control sending the notification, and memberFxn is the name of the parent member function you have written to handle the notification.
The parent's function prototype is as follows:
afx_msg void memberFxn**( );**
Following is a list of potential message-map entries and a description of the cases in which they would be sent to the parent:
ON_EN_CHANGE The user has taken an action that may have altered text in an edit control. Unlike the EN_UPDATE notification message, this notification message is sent after Windows updates the display.
ON_EN_ERRSPACE The edit control cannot allocate enough memory to meet a specific request.
ON_EN_HSCROLL The user clicks an edit control's horizontal scroll bar. The parent window is notified before the screen is updated.
ON_EN_KILLFOCUS The edit control loses the input focus.
ON_EN_MAXTEXT The current insertion has exceeded the specified number of characters for the edit control and has been truncated. 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. 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.
ON_EN_SETFOCUS Sent when an edit control receives the input focus.
ON_EN_UPDATE The edit control is about to display altered text. Sent after the control has formatted the text but before it screens the text so that the window size can be altered, if necessary.
ON_EN_VSCROLL The user clicks an edit control's vertical scroll bar. The parent window is notified before the screen is updated.
If you create a CEdit object within a dialog box, the CEdit object is automatically destroyed when the user closes the dialog box.
If you create a CEdit object from a dialog resource using the dialog editor, the CEdit object is automatically destroyed when the user closes the dialog box.
If you create a CEdit object within a window, you may also need to destroy it. If you create the CEdit object on the stack, it is destroyed automatically. If you create the CEdit object on the heap by using the new function, you must call delete on the object to destroy it when the user terminates the Windows edit control. If you allocate any memory in the CEdit object, override the CEdit destructor to dispose of the allocations.
To modify certain styles in an edit control (such as ES_READONLY) you must send specific messages to the control instead of using ModifyStyle. See Edit Control Styles in the Windows SDK.
For more information on CEdit, see:
Knowledge Base article Q259949 : INFO: SetCaretPos() Is Not Appropriate with CEdit or CRichEditCtrl Controls
Inheritance Hierarchy
CEdit
Requirements
Header: afxwin.h