An edit control, also called a text box, is a rectangular window in which a user can enter and edit text. Generally, you provide a label for an edit control by placing a static control with the appropriate text above or next to the edit control. However, if you do not have enough space, enclose the label within angle brackets—for example, <edit control label>—and include the enclosed label as the default text inside the edit control.
The edit control style values you select can establish the appearance of a single-line or multiline edit control, align the text in the control, and determine if and how text appears in the edit control. The number and type of styles the application uses depend on the type and purpose of the edit control. For a complete listing of supported styles, see Window and Control Styles.
The following code example shows how to use CreateWindow to create an edit control.
#define EDITID 1
// Specify the edit control window style.
DWORD dwStyle = WS_CHILD | WS_VISIBLE | WS_HSCROLL | WS_VSCROLL |
WS_BORDER | ES_LEFT | ES_MULTILINE | ES_NOHIDESEL |
ES_AUTOHSCROLL | ES_AUTOVSCROLL;
// Create the edit control window.
g_hwndEdit = CreateWindow (
TEXT("edit"), // Class name
NULL, // Window text
dwStyle, // Window style
0, // x coordinate of the upper-left corner
0, // y coordinate of the upper-left corner
CW_USEDEFAULT, // Width of the edit control window
CW_USEDEFAULT, // Height of the edit control window
hwnd, // Window handle to parent window
(HMENU) EDITID, // Control identifier
g_hInst, // Instance handle
NULL); // Specify NULL for this parameter when
// creating a control
EDITTEXT id, x, y, width, height [[, style [[, extended-style]]]]
Here, id is the value that identifies the edit box. The upper-left corner of the control is positioned at x, y, and its dimension is determined by width and height. Style and extended-style determine the appearance of the edit box. The following screen shot shows an edit control.
For a complete listing of supported styles, see Window and Control Styles.