• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 212
  • Last Modified:

CComboEditBox - update on enter key

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
CairoBoyce1024
Asked:
CairoBoyce1024
  • 2
2 Solutions
 
lakshman_ceCommented:
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
 
AlexFMCommented:
0
 
CairoBoyce1024Author Commented:
Tried it at the time and it didnt work - will look again tomorrow (22nd).  I have more idea what I am doing now...
0
 
CairoBoyce1024Author Commented:
couldnt have done it without AlexFM's comment - thought it would be simpler but thanks dudes
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Certified Penetration Testing

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now