Those of you who struggle every day to produce user friendly
(and not friendly user) MMI’s, must have encountered the
problem of placing lots of edit boxes together.
Most of the time, the user just looks at the screen and
goes “huh??”, and doesn’t know where to begin to enter
data. And usually while entering data, he loses his focus
very easily, especially if he has to keep track of some
other controls around the screen.
Anyway, giving the currently active input edit box an
indication that it is active at the moment, is a good
idea. You can, for instance, raise the edit box or
simply make its border a 3D one. That’s what we’ll do here.
I created a class named CBorderEdit, which is derived
from CEdit. In this class, I process WM_SETFOCUS and
WM_KILLFOCUS and simply change the extended style of
the edit box, using CWnd::ModifyStyleEx.
void CBorderEdit::OnSetFocus(CWnd* pOldWnd)
ModifyStyleEx(0, WS_EX_DLGMODALFRAME | WS_EX_WINDOWEDGE | WS_EX_RIGHT);
void CBorderEdit::OnKillFocus(CWnd* pNewWnd)
ModifyStyleEx(WS_EX_DLGMODALFRAME | WS_EX_WINDOWEDGE | WS_EX_RIGHT, 0);
Note: For some odd reason, the style of the edit box doesn’t change
unless I throw in the WS_EX_RIGHT or WS_EX_RTLREADING extended styles.
If anyone has any idea, please let me know.
Next, link a member variable of the type CBorderEdit to some edit box
control that you put in the dialog resource (make sure you’re using
Class Wizard so it would use DDX_), and there you go!