The CEdit class provides the functionality of a Windows edit control. 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. 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:
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.
For more information on CEdit, see Control Topics in Visual C++ Programmer's Guide.
#include <afxwin.h>
Class Members | Base Class | Hierarchy Chart
Samples MFC Sample CALCDRIV | MFC Sample CMNCTRL2 | MFC Sample VCTERM
See Also CWnd, CButton, CComboBox, CListBox, CScrollBar, CStatic, CDialog