Click to See Complete Forum and Search --> : GetFocus() don't behave properly?!


ric
May 21st, 1999, 04:26 AM
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?

mihai
May 21st, 1999, 05:06 AM
The focus is received by inside edit of combbox, not combo.
Sincerely, Mihai

ric
May 21st, 1999, 05:22 AM
So how should I write it then?

sally
May 21st, 1999, 07:42 AM
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;
}

Sally
May 21st, 1999, 07:42 AM
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;
}