Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

combobox focus event

Posted on 2004-04-23
1
Medium Priority
?
382 Views
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)
            {
                  AfxMessageBox("IDC_COMBO_FIND-mhWnd");
                  return TRUE;
            }
            else if(GetFocus()==GetDlgItem(IDC_COMBO_FIND) )
            {
                  AfxMessageBox("IDC_COMBO_FIND-getfocus");
            }
            else if(pMsg->hwnd == GetDlgItem(IDC_COMBO_FIND)->GetSafeHwnd())
            {
                  AfxMessageBox("IDC_COMBO_FIND-GetSafeHwnd");
            }
            else
            {
                  //AfxMessageBox("not hit");
            }
      }
      return CDialog::PreTranslateMessage(pMsg);
}
0
Comment
Question by:csdnchen
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 48

Accepted Solution

by:
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.
0

Featured Post

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Question has a verified solution.

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

Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
Have you tried to learn about Unicode, UTF-8, and multibyte text encoding and all the articles are just too "academic" or too technical? This article aims to make the whole topic easy for just about anyone to understand.
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 response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
Suggested Courses

618 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