class CEdit : public CWnd1、CEdit::Create
virtual BOOL Create( DWORD dwStyle,
const RECT& rect,
CWnd* pParentWnd,
UINT nID
);
(1)DWORD dwStyle : Specifies the edit control's style. Apply any combination of edit styles to the control.
Edit Style
- ES_AUTOHSCROLL Automatically scrolls text to the right by 10 characters when the user types a character at the end of the line. When the user presses the ENTER key, the control scrolls all text back to position 0.//同一行可以无限往后输入
- ES_AUTOVSCROLL Automatically scrolls text up one page when the user presses ENTER on the last line.//可以换行无限往下输入
- ES_CENTER Centers text in a single-line or multiline edit control.
- ES_LEFT Left-aligns text in a single-line or multiline edit control.
- ES_LOWERCASE Converts all characters to lowercase as they are typed into the edit control.
- ES_MULTILINE Designates a multiple-line edit control. (The default is single line.) If the ES_AUTOVSCROLL style is specified, the edit control shows as many lines as possible and scrolls vertically when the user presses the ENTER key. If ES_AUTOVSCROLL is not given, the edit control shows as many lines as possible and beeps if ENTER is pressed when no more lines can be displayed. If the ES_AUTOHSCROLL style is specified, the multiple-line edit control automatically scrolls horizontally when the caret goes past the right edge of the control. To start a new line, the user must press ENTER. If ES_AUTOHSCROLL is not given, the control automatically wraps words to the beginning of the next line when necessary; a new line is also started if ENTER is pressed. The position of the wordwrap is determined by the window size. If the window size changes, the wordwrap position changes and the text is redisplayed. Multiple-line edit controls can have scroll bars. An edit control with scroll bars processes its own scroll-bar messages. Edit controls without scroll bars scroll as described above and process any scroll messages sent by the parent window. //多行
- ES_NOHIDESEL Normally, an edit control hides the selection when the control loses the input focus and inverts the selection when the control receives the input focus. Specifying ES_NOHIDESEL deletes this default action.
- ES_NUMBER Allows only digits to be entered into the edit control.
- ES_OEMCONVERT Text entered in the edit control is converted from the ANSI character set to the OEM character set and then back to ANSI. This ensures proper character conversion when the application calls the AnsiToOem Windows function to convert an ANSI string in the edit control to OEM characters. This style is most useful for edit controls that contain filenames.
- ES_PASSWORD Displays all characters as an asterisk ( *) as they are typed into the edit control. An application can use the SetPasswordChar member function to change the character that is displayed.
- ES_READONLY Prevents the user from entering or editing text in the edit control.
- ES_RIGHT Right-aligns text in a single-line or multiline 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 while entering text into a multiple-line edit control in a dialog box. Without this style, pressing the ENTER key has the same effect as pressing the dialog boxs default pushbutton. This style has no effect on a single-line edit control.
Windows Style
- WS_BORDER Creates a window that has a border.//有边框
- WS_CAPTION Creates a window that has a title bar (implies the WS_BORDER style). Cannot be used with the WS_DLGFRAME style.
- WS_CHILD Creates a child window. Cannot be used with the WS_POPUP style.//创建为子窗口,与父窗口的焦点不能同时操作
- WS_CHILDWINDOW Same as the WS_CHILD style.
- WS_CLIPCHILDREN Excludes the area occupied by child windows when you draw within the parent window. Used when you create the parent window.
- WS_CLIPSIBLINGS Clips child windows relative to each other; that is, when a particular child window receives a paint message, the WS_CLIPSIBLINGS style clips all other overlapped child windows out of the region of the child window to be updated. (If WS_CLIPSIBLINGS is not given and child windows overlap, when you draw within the client area of a child window, it is possible to draw within the client area of a neighboring child window.) For use with the WS_CHILD style only.
- WS_DISABLED Creates a window that is initially disabled.
- WS_DLGFRAME Creates a window with a double border but no title.
- WS_GROUP Specifies the first control of a group of controls in which the user can move from one control to the next with the arrow keys. All controls defined with the WS_GROUP style FALSE after the first control belong to the same group. The next control with the WS_GROUP style starts the next group (that is, one group ends where the next begins).
- WS_HSCROLL Creates a window that has a horizontal scroll bar.
- WS_ICONIC Creates a window that is initially minimized. Same as the WS_MINIMIZE style.
- WS_MAXIMIZE Creates a window of maximum size.
- WS_MAXIMIZEBOX Creates a window that has a Maximize button.
- WS_MINIMIZE Creates a window that is initially minimized. For use with the WS_OVERLAPPED style only.
- WS_MINIMIZEBOX Creates a window that has a Minimize button.
- WS_OVERLAPPED Creates an overlapped window. An overlapped window usually has a caption and a border.
- WS_OVERLAPPEDWINDOW Creates an overlapped window with the WS_OVERLAPPED, WS_CAPTION, WS_SYSMENU, WS_THICKFRAME, WS_MINIMIZEBOX, and WS_MAXIMIZEBOX styles.
- WS_POPUP Creates a pop-up window. Cannot be used with the WS_CHILD style.
- WS_POPUPWINDOW Creates a pop-up window with the WS_BORDER, WS_POPUP, and WS_SYSMENU styles. The WS_CAPTION style must be combined with the WS_POPUPWINDOW style to make the Control menu visible.
- WS_SIZEBOX Creates a window that has a sizing border. Same as the WS_THICKFRAME style.
- WS_SYSMENU Creates a window that has a Control-menu box in its title bar. Used only for windows with title bars.
- WS_TABSTOP Specifies one of any number of controls through which the user can move by using the TAB key. The TAB key moves the user to the next control specified by the WS_TABSTOP style.//可以用TAB键切换到该控件
- WS_THICKFRAME Creates a window with a thick frame that can be used to size the window.
- WS_TILED Creates an overlapped window. An overlapped window has a title bar and a border. Same as the WS_OVERLAPPEDstyle.
- WS_TILEDWINDOW Creates an overlapped window with the WS_OVERLAPPED, WS_CAPTION, WS_SYSMENU, WS_THICKFRAME, WS_MINIMIZEBOX, and WS_MAXIMIZEBOX styles. Same as the WS_OVERLAPPEDWINDOW style.
- WS_VISIBLE Creates a window that is initially visible. //可见的
- WS_VSCROLL Creates a window that has a vertical scroll bar
(2)
rect Specifies the edit control's size and position. Can be a CRect object or RECT structure.
(3)
pParentWnd
Specifies the edit control's parent window (usually a
CDialog
). It must not be
NULL
(4)
nID
Specifies the edit control's ID.
Name | Description |
---|---|
CEdit::CanUndo | Determines whether an edit-control operation can be undone. |
CEdit::CharFromPos | Retrieves the line and character indexes for the character closest to a specified position. |
CEdit::Clear | Deletes (clears) the current selection (if any) in the edit control. |
CEdit::Copy | Copies the current selection (if any) in the edit control to the Clipboard in CF_TEXT format. |
CEdit::Create | Creates the Windows edit control and attaches it to the CEdit object. |
CEdit::Cut | Deletes (cuts) the current selection (if any) in the edit control and copies the deleted text to the Clipboard in CF_TEXT format. |
CEdit::EmptyUndoBuffer | Resets (clears) the undo flag of an edit control. |
CEdit::FmtLines | Sets the inclusion of soft line-break characters on or off within a multiple-line edit control. |
CEdit::GetCueBanner | 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. |
CEdit::GetFirstVisibleLine | Determines the topmost visible line in an edit control. |
CEdit::GetHandle | Retrieves a handle to the memory that is currently allocated for a multiple-line edit control. |
CEdit::GetHighlight | Gets the indexes of the starting and ending characters in a range of text that is highlighted in the current edit control. |
CEdit::GetLimitText | Gets the maximum amount of text this CEdit can contain. |
CEdit::GetLine | Retrieves a line of text from an edit control. |
CEdit::GetLineCount | Retrieves the number of lines in a multiple-line edit control. |
CEdit::GetMargins | Gets the left and right margins for this CEdit. |
CEdit::GetModify | Determines whether the contents of an edit control have been modified. |
CEdit::GetPasswordChar | Retrieves the password character displayed in an edit control when the user enters text. |
CEdit::GetRect | Gets the formatting rectangle of an edit control. |
CEdit::GetSel | Gets the first and last character positions of the current selection in an edit control. |
CEdit::HideBalloonTip | Hides any balloon tip associated with the current edit control. |
CEdit::LimitText | Limits the length of the text that the user can enter into an edit control. |
CEdit::LineFromChar | Retrieves the line number of the line that contains the specified character index. |
CEdit::LineIndex | Retrieves the character index of a line within a multiple-line edit control. |
CEdit::LineLength | Retrieves the length of a line in an edit control. |
CEdit::LineScroll | Scrolls the text of a multiple-line edit control. |
CEdit::Paste | 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. |
CEdit::PosFromChar | Retrieves the coordinates of the upper-left corner of a specified character index. |
CEdit::ReplaceSel | Replaces the current selection in an edit control with the specified text. |
CEdit::SetCueBanner | 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. |
CEdit::SetHandle | Sets the handle to the local memory that will be used by a multiple-line edit control. |
CEdit::SetHighlight | Highlights a range of text that is displayed in the current edit control. |
CEdit::SetLimitText | Sets the maximum amount of text this CEdit can contain. |
CEdit::SetMargins | Sets the left and right margins for this CEdit. |
CEdit::SetModify | Sets or clears the modification flag for an edit control. |
CEdit::SetPasswordChar | Sets or removes a password character displayed in an edit control when the user enters text. |
CEdit::SetReadOnly | Sets the read-only state of an edit control. |
CEdit::SetRect | Sets the formatting rectangle of a multiple-line edit control and updates the control. |
CEdit::SetRectNP | Sets the formatting rectangle of a multiple-line edit control without redrawing the control window. |
CEdit::SetSel | Selects a range of characters in an edit control. |
CEdit::SetTabStops | Sets the tab stops in a multiple-line edit control. |
CEdit::ShowBalloonTip | Displays a balloon tip that is associated with the current edit control. |
CEdit::Undo | Reverses the last edit-control operation. |