?
Solved

Message Processing

Posted on 1998-09-03
4
Medium Priority
?
341 Views
Last Modified: 2013-11-20
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!
0
Comment
Question by:solomon021499
  • 2
4 Comments
 
LVL 2

Accepted Solution

by:
prasanth earned 800 total points
ID: 1321691
I would try overriding PreTranslateMessage and processing WM_KEYDOWNs where the virtual key is VK_ENTER.
0
 
LVL 6

Expert Comment

by:snoegler
ID: 1321692
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()) );
}
0
 

Author Comment

by:solomon021499
ID: 1321693
prasanth's proposed answer is the way to go.

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

Thanks
0
 
LVL 6

Expert Comment

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

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
Introduction: Dialogs (2) modeless dialog and a worker thread.  Handling data shared between threads.  Recursive functions. Continuing from the tenth article about sudoku.   Last article we worked with a modal dialog to help maintain informat…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
With just a little bit of  SQL and VBA, many doors open to cool things like synchronize a list box to display data relevant to other information on a form.  If you have never written code or looked at an SQL statement before, no problem! ...  give i…
Suggested Courses
Course of the Month17 days, 10 hours left to enroll

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question