windows_programming_notes.nbk: Home | Index | Next Page: Using List Box Controls | Previous Page: Using Edit Controls


 Using Edit Controls in a Window

An edit control can be created in any window like this:

    times_edit = CreateWindow(
        "EDIT",
        "1",
        WS_VISIBLE | WS_CHILD,
        0, 0, 0, 0,
        hwnd,
        (HMENU)times_edit_id,
        hinstance,
        NULL);

The eighth argument to the CreateWindow function is the edit control's ID.

The edit control sends notifications to it's parent window through a WM_COMMAND meesage. The wParam argument contains the control's id in the low word and the contification message in the high word. The lParam argument is the button's handle.

See Edit controls for the notification messages.

See Using Buttons in a Window for how to catch and interpret the notifications.

The text in the edit control can be set thusly:

    SetWindowText(times_edit, run_count);

The text can be retrieved thusly:

    GetWindowText(times_edit, run_count, sizeof(run_count) - 1);

This works also, giving us a hint about the internals of dialog boxes:

    GetDlgItemText(hwnd, times_edit_id, run_count, sizeof(run_count) - 1);

windows_programming_notes.nbk: Home | Index | Next Page: Using List Box Controls | Previous Page: Using Edit Controls


Notebook exported on Monday, 7 July 2008, 18:56:50 PM Eastern Daylight Time