combobox focus event

Posted on 2004-04-23
Medium Priority
Last Modified: 2013-11-20
I want to capture the shift+tab event when my combo got  focus, it is ok when I set the combobox DROPDOWNLIST, but when the combobox set to DROPDOWN, I can not capture the event if the focus is hold by the combobox, code like this:

BOOL CMyDlg::PreTranslateMessage(MSG* pMsg)
      if( pMsg->message == WM_KEYDOWN )
            if( (pMsg->hwnd == GetDlgItem(IDC_COMBO_FIND)->m_hWnd)
                  return TRUE;
            else if(GetFocus()==GetDlgItem(IDC_COMBO_FIND) )
            else if(pMsg->hwnd == GetDlgItem(IDC_COMBO_FIND)->GetSafeHwnd())
                  //AfxMessageBox("not hit");
      return CDialog::PreTranslateMessage(pMsg);
Question by:csdnchen
1 Comment
LVL 48

Accepted Solution

AlexFM earned 200 total points
ID: 10906380
Combobox with Dropdown style has child edit box, this is a reason your code doesn't work. You can see this in Spy++.
Find this child edit box using GetWindow or EnumChildWindows, and test for it's HWND in PreTranslateMessage.
You can use also IsChild function to test whether pMsg->hwnd is child of combobox.

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

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

Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
Introduction: The undo support, implementing a stack. Continuing from the eigth article about sudoku.   We need a mechanism to keep track of the digits entered so as to implement an undo mechanism.  This should be a ‘Last In First Out’ collec…
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 this video I will demonstrate how to set up Nine, which I now consider the best alternative email app to Touchdown.
Suggested Courses

627 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