Solved

Trap CEdit  keystrokes

Posted on 1998-09-27
4
564 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 50 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

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
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.
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…

615 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