return TRUE; // eat
break;
case WM_SETFOCUS:
+ m_bEditHasFocus = TRUE;
break;
case WM_KILLFOCUS:
// hide the list if lost focus
hwndGotFocus = (HWND)wParam;
if (hwndGotFocus != m_hwndEdit && hwndGotFocus != m_hWnd)
HideDropDown();
+ m_bEditHasFocus = FALSE;
break;
case WM_IME_NOTIFY:
if (wParam == IMN_OPENCANDIDATE)
// CAutoComplete public methods
CAutoComplete::CAutoComplete()
- : m_bInSetText(FALSE), m_bInSelectItem(FALSE)
+ : m_bInSetText(FALSE), m_bInSelectItem(FALSE), m_bEditHasFocus(FALSE)
, m_bDowner(TRUE), m_dwOptions(ACO_AUTOAPPEND | ACO_AUTOSUGGEST)
, m_bEnabled(TRUE), m_hwndCombo(NULL), m_hFont(NULL), m_bResized(FALSE)
, m_hwndEdit(NULL), m_fnOldEditProc(NULL), m_fnOldWordBreakProc(NULL)
if (!::SetWindowSubclass(hwndEdit, EditSubclassProc, 0, reinterpret_cast<DWORD_PTR>(this)))
return E_FAIL;
m_hwndEdit = hwndEdit;
+ m_bEditHasFocus = (::GetFocus() == hwndEdit);
// add reference to m_hwndEdit
AddRef();
// set word break procedure
VOID CAutoComplete::RepositionDropDown()
{
+ // If Edit has no focus, don't open auto-complete
+ if (!m_bEditHasFocus)
+ {
+ TRACE("!m_bEditHasFocus\n");
+ return;
+ }
+
// get nearest monitor from m_hwndEdit
HMONITOR hMon = ::MonitorFromWindow(m_hwndEdit, MONITOR_DEFAULTTONEAREST);
ATLASSERT(hMon != NULL);