Click to See Complete Forum and Search --> : EN_UPDATE


Erich Ruth
May 15th, 1999, 11:41 AM
How can I use EN_UPDATE or some similiar command to
preview the letter that I typed before it is displayed in the edit
box and how can I not let certain letters be displayed in an edit
box, like the letter h, or the letter z? That is, if the user's cursor
was in edit_box1 and typed the letter h, nothing is displayed
in the editbox.

Any response any one can give me will be greatly appreciated.

Bob Clarke
May 16th, 1999, 03:51 AM
Here's one way:

1. Create member variable m_bHasFocus.
2. Map EN_KILLFOCUS and EN_SETFOCUS for the edit control. In the SetFocus() handler, set m_bhasFocus to true. In the KillFocus() handler, set it to false.
3. Map PreTranslateMessage, and in that handler, check the character and do what you want. For example, here's how to eat the "k" and "K" characters to prevent them from reaching the edit control:

BOOL CSomeClass::PreTranslateMessage(MSG* pMsg)
{
if(pMsg->message == WM_CHAR && m_bHasFocus)
{
if(pMsg->wParam == 'k' || pMsg->wParam == 'K'
return TRUE;
else
return CParentClass::PreTranslateMessage(pMsg);
}
return CSomeParentClass::PreTranslateMessage(pMsg);
}