Share via


Creating an Edit Control (Windows Embedded CE 6.0)

1/6/2010

An edit control, also known as 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 that contains 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.

To create an edit control by using the CreateWindow function

  1. Specify the EDIT window class in the lpClassName parameter of the CreateWindow or the CreateWindowEx function.

  2. Specify one or more styles for the edit control in the dwStyle parameter of the CreateWindow or the CreateWindowEx function.

    The style values for the edit control that 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 that 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. If the WS_EX_LAYOUTRTL window style is set, the edit control has to be mirrored. The reading order can be also be controlled by WS_EX_RTLREADING window style.

The following code example shows how to use CreateWindow to create an edit control.

#define EDITID 1000

// Specify the window style for the edit control.
DWORD dwStyle = WS_CHILD | WS_VISIBLE | WS_HSCROLL | WS_VSCROLL | 
                WS_BORDER | ES_LEFT | ES_MULTILINE | ES_NOHIDESEL | 
                ES_AUTOHSCROLL | ES_AUTOVSCROLL;  

// Create the window for 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 window for the edit
                                // control
                CW_USEDEFAULT,  // Height of the window for the edit
                                // control
                hwnd,           // Window handle to the parent window
                (HMENU) EDITID, // Control identifier
                g_hInst,        // Instance handle
                NULL);          // Specify NULL for this parameter when 
                                // you create a control

To create an edit control in a dialog box

  • Add the following EDITTEXT resource-definition statement to your DIALOG resource.

    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. Both style and extended-style determine the appearance of the edit box. The following screen shot shows an edit control.

    Ee502235.ffc0a1d6-05f6-4c99-86e9-ec1f3d647a67(en-US,WinEmbedded.60).gif

For a complete listing of supported styles, see Window and Control Styles.

See Also

Concepts

Working with Window Controls

Other Resources

GWES Application Development