I want an Editbox to display a string. And as soon as I change the string, I want the editbox to update it. The second part with the update isn't necessary.
Can anyone help me with this please?
Printable View
I want an Editbox to display a string. And as soon as I change the string, I want the editbox to update it. The second part with the update isn't necessary.
Can anyone help me with this please?
Since you don't mention your programming environment, I'll assume it is VC5 or VC6.
CWnd::SetWindowText() can be used to set the contents of the edit box.
For the updating, use the Class Wizard's Message Map to map the EN_CHANGE notification message. Whenever the contents of the edit box changes, this method will be called. Inside this method, put code to update your string variable.
Example:
// in your initialization code
CString cSample("This is edit box text");
m_editBox.SetWindowText( cSample );
CSample::OnChangeEdit1()
{
cSample = m_editBox.GetWindowText();
}
Actully I use VC 4, but I hope it won't make much of a difference.