Solved

CComboEditBox - update on enter key

Posted on 2004-04-06
5
197 Views
Last Modified: 2013-11-20
How can I capture the user hitting the enter key while on a comboEditBox in MFC? (im using MFC in the .NET environment, but its still MFC).
0
Comment
Question by:CairoBoyce1024
  • 2
5 Comments
 
LVL 15

Accepted Solution

by:
lakshman_ce earned 150 total points
ID: 10770607
Override the PreTranslateMessage method in your combo box

BOOL CMyComboBox::PreTranslateMessage(MSG* pMsg)
{
      if (pMsg->message == WM_KEYDOWN)
      {
            
                   int nVirtKey = (int) pMsg->wParam;
            
                              if (nVirtKey==13)//VK_ENTER
            {
                  CString text;
                  GetWindowText(text);
                  return TRUE;
            }      
      
      }

      return CComboBox::PreTranslateMessage(pMsg);
}

-Lakshman
0
 
LVL 48

Assisted Solution

by:AlexFM
AlexFM earned 100 total points
ID: 10771884
0
 

Author Comment

by:CairoBoyce1024
ID: 11865585
Tried it at the time and it didnt work - will look again tomorrow (22nd).  I have more idea what I am doing now...
0
 

Author Comment

by:CairoBoyce1024
ID: 11886995
couldnt have done it without AlexFM's comment - thought it would be simpler but thanks dudes
0

Featured Post

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
bigDiff challenge 17 75
canBalance challenge 34 65
Change to event 1 73
how to split multiple lines delimiter : 8 54
In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
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. …
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.
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

757 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

21 Experts available now in Live!

Get 1:1 Help Now