Solved

CComboEditBox - update on enter key

Posted on 2004-04-06
5
199 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Complete beginner needs help making a cron job 9 110
Prevent this page from creating additional dialogs. 3 410
Window placement 17 77
Path of Workbook 3 61
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…
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.
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

862 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

22 Experts available now in Live!

Get 1:1 Help Now