Thank you mat. You are right.I just call GetFocus and determine weather the EN_KILLFOCUS comes from the focused control.
BOOL CMyDlg::OnCommand(WPARAM wParam, LPARAM lParam)
{
// TODO: Add your specialized code here and/or call the base class
UINT notificationCode = (UINT)HIWORD(wParam);
if (notificationCode == EN_KILLFOCUS || notificationCode == CBN_KILLFOCUS)
{
HWND hwnd = (HWND)lParam;
if (hwnd == NULL)
{
return false;
}
CWnd* pWnd = CWnd::FromHandle(hwnd);
int nID = pWnd->GetDlgCtrlID();
if (GetFocus() != NULL && GetFocus()->m_hWnd == pWnd->m_hWnd) // Add this
{
return false;
}
GetParent()->PostMessage(UM_KILLFOCUS, nID, 0);
}
return CDialog::OnCommand(wParam, lParam);
}