nicolet
asked on
Detect Return keypress in a edit text widget
How can I get noticed when user press the "Enter" key in a edit text widget after user enter their value.
Widget means what ?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank You!
ASKER
This Edit box is in a child window dialog, It does not response to "OnOK". Would you please be more detailed about using derived class from CEdit and process WM_KEYDOWN, WM_KEYUP. to catch a "Return" key press.
Thank You!
Thank You!
Try this out ...
In your derived CEdit class, say CMyEdit, add an handler for PreTranslateMessage ...
BOOL CMyEdit::PreTranslateMessa ge(MSG* pMsg)
{
if ((pMsg->message == WM_KEYDOWN) &&
(pMsg->wParam == VK_RETURN))
.... CALL YOUR FUNCTION (Enter has been detected)
return TRUE;// Saying that you have handled the msg
}
return CEdit::PreTranslateMessage (pMsg);
}
You can also translate your key strokes to some other key stroke.
For Ex: If Enter needs to be treated as Tabs, you can do the following ..
BOOL CMyEdit::PreTranslateMessa ge(MSG* pMsg)
{
if ((pMsg->message == WM_KEYDOWN) &&
(pMsg->wParam == VK_RETURN))
pMsg->wParam = VK_TAB;// Cheating !!
}
return CEdit::PreTranslateMessage (pMsg);
}
Hope this helps
In your derived CEdit class, say CMyEdit, add an handler for PreTranslateMessage ...
BOOL CMyEdit::PreTranslateMessa
{
if ((pMsg->message == WM_KEYDOWN) &&
(pMsg->wParam == VK_RETURN))
.... CALL YOUR FUNCTION (Enter has been detected)
return TRUE;// Saying that you have handled the msg
}
return CEdit::PreTranslateMessage
}
You can also translate your key strokes to some other key stroke.
For Ex: If Enter needs to be treated as Tabs, you can do the following ..
BOOL CMyEdit::PreTranslateMessa
{
if ((pMsg->message == WM_KEYDOWN) &&
(pMsg->wParam == VK_RETURN))
pMsg->wParam = VK_TAB;// Cheating !!
}
return CEdit::PreTranslateMessage
}
Hope this helps
ASKER
Thank You!
ASKER