Solved

Message Processing

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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Expand macro to include alternate header placement and naming 5 71
Process filename extension 3 184
Complete beginner needs help making a cron job 9 116
Line meaning 9 85
Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
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.
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …

776 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