Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

edit control problem

doughydoughy Member Posts: 13
I want to get information from an edit box and have an afx message box popup with what what was typed into the edit box when the user presses enter. I don't want there to be a button such as this example.
[code]
void CTestDlg::OnTest()
{
// TODO: Add your control notification handler code here
CString szEdit;
CString szResult;
int nLength = m_editTest.LineLength();
m_editTest.GetWindowText(szEdit);
szResult.Format("%s has %d chars", szEdit, nLength);
AfxMessageBox(szResult);
}
[/code]
In this example there's a button control. This function is called when a button is pressed. I tried most of hte message maps but there's none for a simple enter button.

Comments

  • TribalTechTribalTech Member Posts: 74
    : I want to get information from an edit box and have an afx message
    : box popup with what what was typed into the edit box when the user
    : presses enter. I don't want there to be a button such as this
    : example.
    : [code]:
    : void CTestDlg::OnTest()
    : {
    : // TODO: Add your control notification handler code here
    : CString szEdit;
    : CString szResult;
    : int nLength = m_editTest.LineLength();
    : m_editTest.GetWindowText(szEdit);
    : szResult.Format("%s has %d chars", szEdit, nLength);
    : AfxMessageBox(szResult);
    : }
    : [/code]:
    : In this example there's a button control. This function is called
    : when a button is pressed. I tried most of hte message maps but
    : there's none for a simple enter button.
    :
    Try doing a message handler for OnOk(), test for the enter key being pressed, if so display a messagebox with the string from the edit box but don't let the dialog close.
    TT
Sign In or Register to comment.