Solved

Message Processing

Posted on 1998-09-03
4
331 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 200 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
mixString challenge 36 111
unable to delete all specified values regedit 38 278
haveThree challenge 22 114
wordappend challenge 8 149
Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
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.
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

920 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

Need Help in Real-Time?

Connect with top rated Experts

16 Experts available now in Live!

Get 1:1 Help Now