Solved

Trap CEdit  keystrokes

Posted on 1998-09-27
4
559 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
  • 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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
if loop error 4 77
Replacement selected text 2 48
notReplace  challenge 53 102
either24  challenge 19 84
Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
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…
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.
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.

743 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

12 Experts available now in Live!

Get 1:1 Help Now