How To create edit box using vc++ ?


An edit box is a control used to either display text, to request text, or to do both. It it provided as a rectangular control with a sunken white background and 3-D borders.

To add an edit box  and click the desired area on a form or a dialog box. To add a new edit box programmatically, declare a variable or a pointer to CEdit using its constructor. To initialize it, call its Create() method. Here is an example:



BOOL CLabelDlg::OnInitDialog()
{
CDialog::OnInitDialog();

// TODO: Add extra initialization here
CEdit *Musician = new CEdit;

Musician->Create(WS_CHILD | WS_VISIBLE,
            CRect(10, 50, 150, 70), this, 0x1552);
return TRUE;  // return TRUE unless you set the focus to a control
             // EXCEPTION: OCX Property Pages should return FALSE


To change the text of the control, a user can click it and start typing. This is possible if allowed it, which is the default behavior. If you don't want the user to be able to change the text of an edit box, at design time, check its Read Only check box or set it to True. To dynamically set an edit box to read-only, add the ES_READONLY style to it.

The text of an edit box displays its characters at they are set in the alphabet. If you want to hide the characters of an edit box, check its Password check box at design time. In this case, the characters would appear as x. If you prefer a different character, call the SendMessage() function with the EM_SETPASSWORDCHAR as the message. Here is an example:

BOOL CLabelDlg::OnInitDialog()
{
CDialog::OnInitDialog();

// TODO: Add extra initialization here
m_AccountPassword.SendMessage(EM_SETPASSWORDCHAR, '&', 0);

return TRUE;  // return TRUE unless you set the focus to a control
             // EXCEPTION: OCX Property Pages should return FALSE
}

Read More:http://www.functionx.com/visualc/controls/editbox.htm

Comments