Solved

Trap CEdit  keystrokes

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Decoding 32 bit binary streams 6 54
Tab names are off by one 5 54
NotAlone Challenge 20 88
how to use laptop or pad camera in vb.net windows application 2 107
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…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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 a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

749 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