Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Trap CEdit  keystrokes

Posted on 1998-09-27
4
Medium Priority
?
565 Views
Last Modified: 2013-11-20
Hi Everyone!

I would like to trap the Enter keypress in a CEdit control and prosses it as a Tab key, in other words I would like to be able to move from CEdit to CEdit control using the Enter key.
Please help as I am unable to solve this one myself.

Regards Vardis
0
Comment
Question by:vardis
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 23

Expert Comment

by:chensu
ID: 1322643
1. Derive a class from CEdit and override CEdit::OnChar().
2. When an Enter key is detected, post a user-defined message (e.g. WM_APP + 1) to the parent window of the edit control.
3. When the dialog box receives the user-defined message, call CDialog::NextDlgCtrl() to simulate a tab key.
0
 

Expert Comment

by:umarama
ID: 1322644
I have a simpler solution to your problem.

In your derived CEdit class, say CMyEdit, add an handler for PreTranslateMessage ...

BOOL CMyEdit::PreTranslateMessage(MSG* pMsg)
{
  if ((pMsg->message == WM_KEYDOWN) && 
      (pMsg->wParam == VK_RETURN))
      pMsg->wParam = VK_TAB;
      // Return gets translated to TAB - simulation
  }
  return CEdit::PreTranslateMessage(pMsg);
}

This works.
0
 

Accepted Solution

by:
umarama earned 200 total points
ID: 1322645
Try out my solution. Please refer to my previous comment
0
 

Author Comment

by:vardis
ID: 1322646
Thank you umarama for the solution.
You're right it is a simpler solution and it did work.

Thank you!

Vardis
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

Introduction: Ownerdraw of the grid button.  A singleton class implentation and usage. Continuing from the fifth article about sudoku.   Open the project in visual studio. Go to the class view – CGridButton should be visible as a class.  R…
If you use Adobe Reader X it is possible you can't open OLE PDF documents in the standard. The reason is the 'save box mode' in adobe reader X. Many people think the protected Mode of adobe reader x is only to stop the write access. But this fe…
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.
Want to learn how to record your desktop screen without having to use an outside camera. Click on this video and learn how to use the cool google extension called "Screencastify"! Step 1: Open a new google tab Step 2: Go to the left hand upper corn…
Suggested Courses

715 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