GetFocus() don't behave properly?!
I have a dialog with a combobox on it. And in PreTranslateMessage() I want to check if the focus is on the combobox. So I do the following:
void CMyDialog::PreTranslateMessage(MSG* pMsg)
{
int ret = CDialog::PreTranslateMessage();
if(pMsg->message==WM_KEYUP)
if(GetDlgItem(IDC_COMBO) == GetFocus())
{
// do something
}
return ret;
}
the second if always return FALSE. Where do I fail?
Re: GetFocus() don't behave properly?!
The focus is received by inside edit of combbox, not combo.
Sincerely, Mihai
Re: GetFocus() don't behave properly?!
So how should I write it then?
Re: GetFocus() don't behave properly?!
Try this:
void CMyDialog::PreTranslateMessage(MSG* pMsg)
{
const int ret = CDialog::PreTranslateMessage();
if (pMsg->message==WM_KEYUP)
{
if (GetDlgItem(IDC_COMBO)->GetWindow(GW_CHILD) == CWnd::GetFocus())
{
// do something
}
}
return ret;
}