Link to home
Start Free TrialLog in
Avatar of solomon021499
solomon021499

asked on

Message Processing

This should be easy.

I have an MDI MFC application.  The view is a CFormView
with Buttons, EntryFields, and ComboBoxes.  The default
behavior is to go to the next control in the tab order
when the Tab key is hit.  I want the same behavior when
Enter (or Return) key is hit.

This is not a CDialog it is a CFormView.

I have tried registering all sorts of message
handlers that should work, but none of them
get executed (OnChar, OnKeyDown, OnSysKeyDown,
OnNotify...).

Help!
ASKER CERTIFIED SOLUTION
Avatar of prasanth
prasanth

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of snoegler
snoegler

The easiest way i think is to add a default 'IDOK' button to your form view.
It may be invisible - so it won't affect your layout. Then add a handler:

void CMyFormView::OnOK()
{
  int curID=GetDlgCtrlID(GetFocus());
 
  if( // check if curID is one of your edit fields //)
    SetFocus( GetNextDlgTabItem(GetFocus()) );
}
Avatar of solomon021499

ASKER

prasanth's proposed answer is the way to go.

Unfortunately, snoegler's comment will work for CDialogs, but not CViews.

Thanks
Please don't think that this is against you - but it does work.
We've been using this in a project, and it worked :)