• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 207
  • 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

Featured Post

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

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