Solved

combobox focus event

Posted on 2004-04-23
1
370 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
1 Comment
 
LVL 48

Accepted Solution

by:
AlexFM earned 50 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

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
ODBC Connection Logging, ADO.NET 6 56
Shell script to login to remote m/c and execute commands 10 78
sumHeights2  challenge 7 92
How to convert MFC::CString to UTF8 wchar_t* 10 150
In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
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.
Learn how to create flexible layouts using relative units in CSS.  New relative units added in CSS3 include vw(viewports width), vh(viewports height), vmin(minimum of viewports height and width), and vmax (maximum of viewports height and width).

863 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

27 Experts available now in Live!

Get 1:1 Help Now