ReactOS  0.4.15-dev-3187-ge372f2b
CAutoComplete Class Reference

#include <CAutoComplete.h>

Inheritance diagram for CAutoComplete:
Collaboration diagram for CAutoComplete:

Public Member Functions

 CAutoComplete ()
 
HWND CreateDropDown ()
 
virtual ~CAutoComplete ()
 
BOOL CanAutoSuggest () const
 
BOOL CanAutoAppend () const
 
BOOL UseTab () const
 
BOOL IsComboBoxDropped () const
 
BOOL FilterPrefixes () const
 
INT GetItemCount () const
 
CStringW GetItemText (INT iItem) const
 
CStringW GetEditText () const
 
VOID SetEditText (LPCWSTR pszText)
 
CStringW GetStemText (const CStringW &strText) const
 
VOID SetEditSel (INT ich0, INT ich1)
 
VOID ShowDropDown ()
 
VOID HideDropDown ()
 
VOID SelectItem (INT iItem)
 
VOID DoAutoAppend (PAC_THREAD pThread)
 
VOID DoThreadWork (PAC_THREAD pThread)
 
VOID DoBackWord ()
 
VOID UpdateScrollBar ()
 
VOID StartCompletion (BOOL bAppendOK)
 
VOID AutoCompThreadProc ()
 
VOID FinishCompletion (PAC_THREAD pThread)
 
LRESULT EditWndProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
 
LRESULT OnEditChar (WPARAM wParam, LPARAM lParam)
 
BOOL OnEditKeyDown (WPARAM wParam, LPARAM lParam)
 
VOID OnListSelChange ()
 
BOOL OnListUpDown (UINT vk)
 
STDMETHODIMP Enable (BOOL fEnable) override
 
STDMETHODIMP Init (HWND hwndEdit, IUnknown *punkACL, LPCOLESTR pwszRegKeyPath, LPCOLESTR pwszQuickComplete) override
 
STDMETHODIMP GetOptions (DWORD *pdwFlag) override
 
STDMETHODIMP SetOptions (DWORD dwFlag) override
 
STDMETHODIMP GetDropDownStatus (DWORD *pdwFlags, LPWSTR *ppwszString) override
 
STDMETHODIMP ResetEnumerator () override
 
STDMETHODIMP Next (ULONG celt, LPOLESTR *rgelt, ULONG *pceltFetched) override
 
STDMETHODIMP Skip (ULONG celt) override
 
STDMETHODIMP Reset () override
 
STDMETHODIMP Clone (IEnumString **ppOut) override
 
- Public Member Functions inherited from ATL::CComObjectRootEx< CComMultiThreadModelNoCS >
 ~CComObjectRootEx ()
 
ULONG InternalAddRef ()
 
ULONG InternalRelease ()
 
void Lock ()
 
void Unlock ()
 
HRESULT _AtlInitialConstruct ()
 
- Public Member Functions inherited from ATL::CComObjectRootBase
 CComObjectRootBase ()
 
 ~CComObjectRootBase ()
 
void SetVoid (void *)
 
HRESULT _AtlFinalConstruct ()
 
HRESULT FinalConstruct ()
 
void InternalFinalConstructAddRef ()
 
void InternalFinalConstructRelease ()
 
void FinalRelease ()
 
- Public Member Functions inherited from IUnknown
HRESULT QueryInterface ([in] REFIID riid, [out, iid_is(riid)] void **ppvObject)
 
ULONG AddRef ()
 
ULONG Release ()
 
- Public Member Functions inherited from IEnumString
HRESULT RemoteNext ([in] ULONG celt, [out, size_is(celt), length_is(*pceltFetched)] LPOLESTR *rgelt, [out] ULONG *pceltFetched)
 

Static Public Member Functions

static LPCWSTR GetWndClassName ()
 
- Static Public Member Functions inherited from ATL::CComObjectRootBase
static void WINAPI ObjectMain (bool)
 
static const struct _ATL_CATMAP_ENTRYGetCategoryMap ()
 
static HRESULT WINAPI InternalQueryInterface (void *pThis, const _ATL_INTMAP_ENTRY *pEntries, REFIID iid, void **ppvObject)
 

Public Attributes

BOOL m_bInSetText
 
BOOL m_bInSelectItem
 
- Public Attributes inherited from ATL::CComObjectRootBase
LONG m_dwRef
 

Protected Member Functions

VOID UpdateDropDownState ()
 
VOID CalcRects (BOOL bDowner, RECT &rcListView, RECT &rcScrollBar, RECT &rcSizeBox) const
 
VOID LoadQuickComplete (LPCWSTR pwszRegKeyPath, LPCWSTR pwszQuickComplete)
 
CStringW GetQuickEdit (LPCWSTR pszText) const
 
VOID RepositionDropDown ()
 
VOID ReLoadInnerList (PAC_THREAD pThread)
 
VOID ExtractInnerList (CSimpleArray< CStringW > &outerList, const CSimpleArray< CStringW > &innerList, const CString &strText)
 
LRESULT OnCreate (UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
 
LRESULT OnNCDestroy (UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
 
LRESULT OnDrawItem (UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
 
LRESULT OnExitSizeMove (UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
 
LRESULT OnGetMinMaxInfo (UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
 
LRESULT OnMeasureItem (UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
 
LRESULT OnMouseActivate (UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
 
LRESULT OnNCActivate (UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
 
LRESULT OnNCLButtonDown (UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
 
LRESULT OnNotify (UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
 
LRESULT OnNCHitTest (UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
 
LRESULT OnSize (UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
 
LRESULT OnShowWindow (UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
 
LRESULT OnTimer (UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
 
LRESULT OnVScroll (UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
 
LRESULT OnAutoCompStart (UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
 
LRESULT OnAutoCompFinish (UINT uMsg, WPARAM wParam, LPARAM lParam, BOOL &bHandled)
 

Protected Attributes

BOOL m_bDowner
 
DWORD m_dwOptions
 
DWORD m_bEnabled
 
HWND m_hwndCombo
 
HFONT m_hFont
 
BOOL m_bResized
 
RECT m_rcEdit
 
HWND m_hwndEdit
 
WNDPROC m_fnOldEditProc
 
EDITWORDBREAKPROCW m_fnOldWordBreakProc
 
HANDLE m_hThread
 
PAC_THREAD m_pThread
 
CStringW m_strText
 
CStringW m_strStemText
 
CStringW m_strQuickComplete
 
CACListView m_hwndList
 
CACScrollBar m_hwndScrollBar
 
CACSizeBox m_hwndSizeBox
 
CComPtr< IEnumStringm_pEnum
 
CComPtr< IACList > m_pACList
 
CSimpleArray< CStringW > m_innerList
 
CSimpleArray< CStringW > m_outerList
 

Additional Inherited Members

- Public Types inherited from IAutoComplete2
enum  _tagAUTOCOMPLETEOPTIONS {
  ACO_NONE = 0x00, ACO_AUTOSUGGEST = 0x01, ACO_AUTOAPPEND = 0x02, ACO_SEARCH = 0x04,
  ACO_FILTERPREFIXES = 0x08, ACO_USETAB = 0x10, ACO_UPDOWNKEYDROPSLIST = 0x20, ACO_RTLREADING = 0x40
}
 
typedef IAutoComplete2LPAUTOCOMPLETE2
 
typedef enum IAutoComplete2::_tagAUTOCOMPLETEOPTIONS AUTOCOMPLETEOPTIONS
 
- Public Types inherited from IAutoComplete
typedef IAutoCompleteLPAUTOCOMPLETE
 
- Public Types inherited from IUnknown
typedef IUnknownLPUNKNOWN
 
- Public Types inherited from IEnumString
typedef IEnumStringLPENUMSTRING
 

Detailed Description

Definition at line 143 of file CAutoComplete.h.

Constructor & Destructor Documentation

◆ CAutoComplete()

CAutoComplete::CAutoComplete ( )

Definition at line 653 of file CAutoComplete.cpp.

659 {
660 }
#define TRUE
Definition: types.h:120
PAC_THREAD m_pThread
WNDPROC m_fnOldEditProc
#define FALSE
Definition: types.h:117
EDITWORDBREAKPROCW m_fnOldWordBreakProc
#define NULL
Definition: types.h:112

◆ ~CAutoComplete()

CAutoComplete::~CAutoComplete ( )
virtual

Definition at line 673 of file CAutoComplete.cpp.

674 {
675  TRACE("CAutoComplete::~CAutoComplete(%p)\n", this);
676  if (m_hThread)
677  {
679  m_hThread = NULL;
680  }
681  if (m_hFont)
682  {
684  m_hFont = NULL;
685  }
686  // quit holding them
687  m_pEnum.Release();
688  m_pACList.Release();
689 }
#define CloseHandle
Definition: compat.h:598
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
CComPtr< IACList > m_pACList
#define TRACE(s)
Definition: solgame.cpp:4
#define NULL
Definition: types.h:112
CComPtr< IEnumString > m_pEnum

Member Function Documentation

◆ AutoCompThreadProc()

VOID CAutoComplete::AutoCompThreadProc ( )

Definition at line 1997 of file CAutoComplete.cpp.

1998 {
1999  for (;;)
2000  {
2002  if (!pThread)
2003  break;
2004  DoThreadWork(pThread);
2005  }
2006 }
VOID DoThreadWork(PAC_THREAD pThread)
PAC_THREAD m_pThread
static PAC_THREAD InterlockedExchangeThreadData(volatile PAC_THREAD *Target, PAC_THREAD Value)
#define NULL
Definition: types.h:112

Referenced by AutoCompThreadProc(), and OnAutoCompStart().

◆ CalcRects()

VOID CAutoComplete::CalcRects ( BOOL  bDowner,
RECT rcListView,
RECT rcScrollBar,
RECT rcSizeBox 
) const
protected

Definition at line 1308 of file CAutoComplete.cpp.

1309 {
1310  // get the client rectangle
1311  RECT rcClient;
1312  GetClientRect(&rcClient);
1313 
1314  // the list
1315  rcList = rcClient;
1316  rcList.right = rcList.left + CX_LIST;
1317 
1318  // the scroll bar
1319  rcScrollBar = rcClient;
1320  rcScrollBar.left = rcClient.right - GetSystemMetrics(SM_CXVSCROLL);
1321  if (bDowner)
1322  {
1323  rcScrollBar.top = 0;
1324  rcScrollBar.bottom = rcClient.bottom - GetSystemMetrics(SM_CYHSCROLL);
1325  }
1326  else
1327  {
1328  rcScrollBar.top = GetSystemMetrics(SM_CYHSCROLL);
1329  }
1330 
1331  // the size box
1332  rcSizeBox = rcClient;
1333  rcSizeBox.left = rcClient.right - GetSystemMetrics(SM_CXVSCROLL);
1334  if (bDowner)
1335  {
1336  rcSizeBox.top = rcClient.bottom - GetSystemMetrics(SM_CYHSCROLL);
1337  }
1338  else
1339  {
1340  rcSizeBox.top = 0;
1341  rcSizeBox.bottom = rcClient.top + GetSystemMetrics(SM_CYHSCROLL);
1342  }
1343 }
#define CX_LIST
#define SM_CYHSCROLL
Definition: winuser.h:952
LONG top
Definition: windef.h:307
LONG left
Definition: windef.h:306
LONG right
Definition: windef.h:308
int WINAPI GetSystemMetrics(_In_ int)
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
#define SM_CXVSCROLL
Definition: winuser.h:951
LONG bottom
Definition: windef.h:309

Referenced by OnSize().

◆ CanAutoAppend()

BOOL CAutoComplete::CanAutoAppend ( ) const
inline

Definition at line 696 of file CAutoComplete.cpp.

697 {
698  return !!(m_dwOptions & ACO_AUTOAPPEND) && m_bEnabled;
699 }

Referenced by DoAutoAppend(), FinishCompletion(), OnEditChar(), and StartCompletion().

◆ CanAutoSuggest()

BOOL CAutoComplete::CanAutoSuggest ( ) const
inline

◆ Clone()

STDMETHODIMP CAutoComplete::Clone ( IEnumString **  ppOut)
override

Implements IEnumString.

Definition at line 1280 of file CAutoComplete.cpp.

1281 {
1282  TRACE("(%p, %p)\n", this, ppOut);
1283  if (ppOut)
1284  *ppOut = NULL;
1285  return E_NOTIMPL;
1286 }
#define TRACE(s)
Definition: solgame.cpp:4
#define E_NOTIMPL
Definition: ddrawi.h:99
#define NULL
Definition: types.h:112

◆ CreateDropDown()

HWND CAutoComplete::CreateDropDown ( )

Definition at line 662 of file CAutoComplete.cpp.

663 {
664  ATLASSERT(m_hWnd == NULL);
665  DWORD dwStyle = WS_POPUP | /*WS_VISIBLE |*/ WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_BORDER;
667  Create(NULL, NULL, NULL, dwStyle, dwExStyle);
668  TRACE("CAutoComplete::CreateDropDown(%p): m_hWnd=%p, m_hwndEdit=%p\n",
669  this, m_hWnd, m_hwndEdit);
670  return m_hWnd;
671 }
#define WS_CLIPSIBLINGS
Definition: pedump.c:618
#define ATLASSERT(x)
Definition: CComVariant.cpp:10
_In_ BOOLEAN Create
Definition: pstypes.h:527
#define WS_CLIPCHILDREN
Definition: pedump.c:619
#define WS_EX_TOOLWINDOW
Definition: winuser.h:404
#define TRACE(s)
Definition: solgame.cpp:4
unsigned long DWORD
Definition: ntddk_ex.h:95
#define WS_EX_TOPMOST
Definition: pedump.c:647
#define WS_BORDER
Definition: pedump.c:625
#define WS_EX_NOPARENTNOTIFY
Definition: pedump.c:646
#define WS_POPUP
Definition: pedump.c:616
#define NULL
Definition: types.h:112

Referenced by UpdateDropDownState().

◆ DoAutoAppend()

VOID CAutoComplete::DoAutoAppend ( PAC_THREAD  pThread)

Definition at line 786 of file CAutoComplete.cpp.

787 {
788  if (!CanAutoAppend()) // can we auto-append?
789  return; // don't append
790 
791  CStringW strText = GetEditText(); // get the text
792  if (strText.IsEmpty())
793  return; // don't append
794 
795  INT cItems = m_outerList.GetSize(); // get the number of items
796  if (cItems == 0)
797  return; // don't append
798 
799  // get the common string
800  CStringW strCommon;
801  BOOL bFound = FALSE;
802  for (INT iItem = 0; iItem < cItems; ++iItem)
803  {
804  const CStringW& strItem = m_outerList[iItem]; // get the text of the item
805 
806  CStringW strBody;
807  if (DropPrefix(strItem, strBody) &&
808  ::StrCmpNIW(strBody, strText, strText.GetLength()) == 0)
809  {
810  if (!bFound)
811  {
812  bFound = TRUE;
813  strCommon = strBody;
814  continue;
815  }
816  for (INT ich = 0; ich < strBody.GetLength(); ++ich)
817  {
818  if (strCommon.GetLength() <= ich)
819  break;
820  if (ChrCmpIW(strCommon[ich], strBody[ich]) != 0)
821  {
822  strCommon = strCommon.Left(ich);
823  break;
824  }
825  }
826  continue;
827  }
828 
829  if (::StrCmpNIW(strItem, strText, strText.GetLength()) == 0)
830  {
831  if (!bFound)
832  {
833  bFound = TRUE;
834  strCommon = strItem;
835  continue;
836  }
837 
838  for (INT ich = 0; ich < strItem.GetLength(); ++ich)
839  {
840  if (strCommon.GetLength() <= ich)
841  break;
842  if (ChrCmpIW(strCommon[ich], strItem[ich]) != 0)
843  {
844  strCommon = strCommon.Left(ich);
845  break;
846  }
847  }
848  }
849  }
850 
851  if (strCommon.IsEmpty() || strCommon.GetLength() <= strText.GetLength())
852  return; // no suggestion
853 
854  // append suggestion
855  SetEditText(strCommon);
856 
857  // select the appended suggestion
858  SetEditSel(strText.GetLength(), strCommon.GetLength());
859 }
int GetLength() const
Definition: atlsimpstr.h:356
#define TRUE
Definition: types.h:120
int GetSize() const
Definition: atlsimpcoll.h:104
int32_t INT
Definition: typedefs.h:58
BOOL CanAutoAppend() const
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
VOID SetEditText(LPCWSTR pszText)
VOID SetEditSel(INT ich0, INT ich1)
bool IsEmpty() const
Definition: atlsimpstr.h:379
static BOOL DropPrefix(const CStringW &str, CStringW &strBody)
CStringW GetEditText() const
CSimpleArray< CStringW > m_outerList
CStringT Left(int nCount) const
Definition: cstringt.h:728
BOOL WINAPI ChrCmpIW(WCHAR ch1, WCHAR ch2)
Definition: string.c:217
INT WINAPI StrCmpNIW(LPCWSTR lpszStr, LPCWSTR lpszComp, INT iLen)
Definition: string.c:311

Referenced by FinishCompletion().

◆ DoBackWord()

VOID CAutoComplete::DoBackWord ( )

Definition at line 862 of file CAutoComplete.cpp.

863 {
864  // get current selection
865  INT ich0, ich1;
867  reinterpret_cast<WPARAM>(&ich0), reinterpret_cast<LPARAM>(&ich1));
868  if (ich0 <= 0 || ich0 != ich1) // there is selection or left-side end
869  return; // don't do anything
870  // get text
872  // extend the range
873  while (ich0 > 0 && IsWordBreak(str[ich0 - 1]))
874  --ich0;
875  while (ich0 > 0 && !IsWordBreak(str[ich0 - 1]))
876  --ich0;
877  // select range
878  SetEditSel(ich0, ich1);
879  // replace selection with empty text (this is actually deletion)
881 }
#define TRUE
Definition: types.h:120
int32_t INT
Definition: typedefs.h:58
#define EM_GETSEL
Definition: winuser.h:1980
WNDPROC m_fnOldEditProc
const WCHAR * str
LONG_PTR LPARAM
Definition: windef.h:208
VOID SetEditSel(INT ich0, INT ich1)
static const WCHAR L[]
Definition: oid.c:1250
LRESULT WINAPI CallWindowProcW(_In_ WNDPROC, _In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
static BOOL IsWordBreak(WCHAR ch)
CStringW GetEditText() const
#define EM_REPLACESEL
Definition: winuser.h:1989

Referenced by OnEditKeyDown().

◆ DoThreadWork()

VOID CAutoComplete::DoThreadWork ( PAC_THREAD  pThread)

Definition at line 2008 of file CAutoComplete.cpp.

2009 {
2010  if (pThread->m_bExpand || m_innerList.GetSize() == 0)
2011  {
2012  ReLoadInnerList(pThread);
2013  }
2014  else
2015  {
2016  pThread->m_innerList = m_innerList;
2017  }
2018 
2019  if (m_pThread || !m_hThread)
2020  {
2021  delete pThread;
2022  return;
2023  }
2024 
2025  ExtractInnerList(pThread->m_outerList, pThread->m_innerList, pThread->m_strText);
2026 
2027  if (m_pThread || !m_hThread)
2028  {
2029  delete pThread;
2030  return;
2031  }
2032 
2033  DoSort(pThread->m_outerList);
2034  DoUniqueAndTrim(pThread->m_outerList);
2035 
2036  if (m_pThread || !m_hThread ||
2037  !::PostMessageW(m_hWnd, AUTOCOMP_FINISH, 0, (LPARAM)pThread))
2038  {
2039  delete pThread;
2040  }
2041 }
BOOL m_bExpand
CSimpleArray< CStringW > m_innerList
int GetSize() const
Definition: atlsimpcoll.h:104
PAC_THREAD m_pThread
CSimpleArray< CStringW > m_innerList
static void DoUniqueAndTrim(list_t &list)
LONG_PTR LPARAM
Definition: windef.h:208
VOID ReLoadInnerList(PAC_THREAD pThread)
CStringW m_strText
static void DoSort(list_t &list)
VOID ExtractInnerList(CSimpleArray< CStringW > &outerList, const CSimpleArray< CStringW > &innerList, const CString &strText)
#define AUTOCOMP_FINISH
BOOL WINAPI PostMessageW(_In_opt_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
CSimpleArray< CStringW > m_outerList

Referenced by AutoCompThreadProc().

◆ EditWndProc()

LRESULT CAutoComplete::EditWndProc ( HWND  hwnd,
UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam 
)

Definition at line 299 of file CAutoComplete.cpp.

300 {
301  LRESULT ret;
302  HWND hwndGotFocus;
303  switch (uMsg)
304  {
305  case WM_CHAR:
306  return OnEditChar(wParam, lParam);
307  case WM_CUT: case WM_PASTE: case WM_CLEAR:
308  ret = ::DefSubclassProc(hwnd, uMsg, wParam, lParam); // do default
310  return ret;
311  case WM_GETDLGCODE:
312  ret = ::DefSubclassProc(hwnd, uMsg, wParam, lParam); // do default
313  // some special keys need default processing. we handle them here
314  switch (wParam)
315  {
316  case VK_RETURN:
317  if (IsWindowVisible() || ::GetKeyState(VK_CONTROL) < 0)
319  break;
320  case VK_TAB:
321  if (IsWindowVisible() && UseTab())
322  ret |= DLGC_WANTALLKEYS; // we want all keys to manipulate the list
323  break;
324  case VK_ESCAPE:
325  if (IsWindowVisible())
326  ret |= DLGC_WANTALLKEYS; // we want all keys to manipulate the list
327  break;
328  default:
329  {
330  ret |= DLGC_WANTALLKEYS; // we want all keys to manipulate the list
331  break;
332  }
333  }
334  return ret;
335  case WM_KEYDOWN:
337  return TRUE; // eat
338  break;
339  case WM_SETFOCUS:
340  break;
341  case WM_KILLFOCUS:
342  // hide the list if lost focus
343  hwndGotFocus = (HWND)wParam;
344  if (hwndGotFocus != m_hwndEdit && hwndGotFocus != m_hWnd)
345  HideDropDown();
346  break;
347  case WM_SETTEXT:
348  if (!m_bInSetText)
349  HideDropDown(); // it's mechanical WM_SETTEXT
350  break;
351  case WM_DESTROY:
352  {
354  {
355  ::SendMessageW(hwnd, EM_SETWORDBREAKPROC, 0, reinterpret_cast<LPARAM>(m_fnOldWordBreakProc));
357  }
359  if (::IsWindow(m_hWnd))
360  PostMessageW(WM_CLOSE, 0, 0);
361  // remove reference to m_hwndEdit
362  Release();
363  break;
364  }
365  }
366 
367  return ::DefSubclassProc(hwnd, uMsg, wParam, lParam); // do default
368 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
#define WM_GETDLGCODE
Definition: winuser.h:1672
BOOL UseTab() const
#define WM_CHAR
Definition: winuser.h:1700
#define WM_CUT
Definition: winuser.h:1844
BOOL WINAPI IsWindow(_In_opt_ HWND)
#define TRUE
Definition: types.h:120
BOOL OnEditKeyDown(WPARAM wParam, LPARAM lParam)
#define EM_SETWORDBREAKPROC
Definition: winuser.h:2003
HANDLE HWND
Definition: compat.h:19
#define WM_PASTE
Definition: winuser.h:1846
#define VK_TAB
Definition: winuser.h:2175
#define VK_ESCAPE
Definition: winuser.h:2190
#define WM_CLEAR
Definition: winuser.h:1847
VOID StartCompletion(BOOL bAppendOK)
#define VK_RETURN
Definition: winuser.h:2177
WPARAM wParam
Definition: combotst.c:138
ULONG Release()
#define WM_KEYDOWN
Definition: winuser.h:1698
LRESULT WINAPI DefSubclassProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: commctrl.c:1496
#define WM_SETTEXT
Definition: winuser.h:1600
#define WM_DESTROY
Definition: winuser.h:1592
SHORT WINAPI GetKeyState(_In_ int)
#define WM_KILLFOCUS
Definition: winuser.h:1597
EDITWORDBREAKPROCW m_fnOldWordBreakProc
#define WM_CLOSE
Definition: winuser.h:1604
int ret
LRESULT OnEditChar(WPARAM wParam, LPARAM lParam)
#define DLGC_WANTALLKEYS
Definition: winuser.h:2588
BOOL WINAPI RemoveWindowSubclass(HWND hWnd, SUBCLASSPROC pfnSubclass, UINT_PTR uID)
Definition: commctrl.c:1390
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define NULL
Definition: types.h:112
static LRESULT CALLBACK EditSubclassProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam, UINT_PTR uSubclassID, DWORD_PTR dwData)
#define VK_CONTROL
Definition: winuser.h:2179
BOOL WINAPI PostMessageW(_In_opt_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
BOOL WINAPI IsWindowVisible(_In_ HWND)
#define WM_SETFOCUS
Definition: winuser.h:1596
LONG_PTR LRESULT
Definition: windef.h:209
LPARAM lParam
Definition: combotst.c:139

Referenced by EditSubclassProc().

◆ Enable()

STDMETHODIMP CAutoComplete::Enable ( BOOL  fEnable)
override

Implements IAutoComplete.

Definition at line 1094 of file CAutoComplete.cpp.

1095 {
1096  TRACE("(%p)->Enable(%d)\n", this, fEnable);
1097  m_bEnabled = fEnable;
1098  return S_OK;
1099 }
#define TRACE(s)
Definition: solgame.cpp:4
#define S_OK
Definition: intsafe.h:52

◆ ExtractInnerList()

VOID CAutoComplete::ExtractInnerList ( CSimpleArray< CStringW > &  outerList,
const CSimpleArray< CStringW > &  innerList,
const CString strText 
)
protected

Definition at line 1469 of file CAutoComplete.cpp.

1472 {
1473  for (INT iItem = 0; iItem < innerList.GetSize(); ++iItem)
1474  {
1475  if (m_pThread || !m_hThread)
1476  break;
1477 
1478  const CStringW& strTarget = innerList[iItem];
1479  if (DoesMatch(strTarget, strText))
1480  {
1481  outerList.Add(strTarget);
1482 
1483  if (outerList.GetSize() >= MAX_ITEM_COUNT)
1484  break;
1485  }
1486  }
1487 }
BOOL Add(const T &t)
Definition: atlsimpcoll.h:58
#define MAX_ITEM_COUNT
int GetSize() const
Definition: atlsimpcoll.h:104
int32_t INT
Definition: typedefs.h:58
PAC_THREAD m_pThread
static BOOL DoesMatch(const CStringW &strTarget, const CStringW &strText)

Referenced by DoThreadWork().

◆ FilterPrefixes()

BOOL CAutoComplete::FilterPrefixes ( ) const
inline

Definition at line 713 of file CAutoComplete.cpp.

◆ FinishCompletion()

VOID CAutoComplete::FinishCompletion ( PAC_THREAD  pThread)

Definition at line 2129 of file CAutoComplete.cpp.

2130 {
2131  if (m_pThread || !m_hThread)
2132  return;
2133 
2134  if (!CanAutoSuggest() && !CanAutoAppend())
2135  return;
2136 
2137  // set inner list
2138  m_innerList = pThread->m_innerList;
2139 
2140  // set the items of the virtual listview
2141  m_outerList = pThread->m_outerList; // FIXME: We need more speed!
2142  m_hwndList.SendMessageW(LVM_SETITEMCOUNT, m_outerList.GetSize(), 0);
2143 
2144  // save text
2145  m_strText = pThread->m_strText;
2147 
2148  if (CanAutoSuggest()) // can we auto-suggest?
2149  {
2150  m_bInSelectItem = TRUE; // don't respond
2151  SelectItem(-1); // select none
2153 
2154  if (m_outerList.GetSize() > 0)
2156  else
2157  HideDropDown();
2158  }
2159 
2160  if (CanAutoAppend() && pThread->m_bAppendOK) // can we auto-append?
2161  {
2162  DoAutoAppend(pThread);
2163  }
2164 }
CStringW m_strStemText
CSimpleArray< CStringW > m_innerList
#define TRUE
Definition: types.h:120
int GetSize() const
Definition: atlsimpcoll.h:104
PAC_THREAD m_pThread
BOOL CanAutoSuggest() const
BOOL CanAutoAppend() const
CSimpleArray< CStringW > m_innerList
#define FALSE
Definition: types.h:117
VOID DoAutoAppend(PAC_THREAD pThread)
#define LVM_SETITEMCOUNT
Definition: commctrl.h:2696
CACListView m_hwndList
VOID RepositionDropDown()
CStringW m_strText
VOID SelectItem(INT iItem)
CStringW GetStemText(const CStringW &strText) const
BOOL m_bAppendOK
CSimpleArray< CStringW > m_outerList
CStringW m_strText
CSimpleArray< CStringW > m_outerList

Referenced by OnAutoCompFinish().

◆ GetDropDownStatus()

STDMETHODIMP CAutoComplete::GetDropDownStatus ( DWORD pdwFlags,
LPWSTR ppwszString 
)
override

Implements IAutoCompleteDropDown.

Definition at line 1199 of file CAutoComplete.cpp.

1200 {
1201  BOOL dropped = m_hwndList.IsWindowVisible();
1202 
1203  if (pdwFlags)
1204  *pdwFlags = (dropped ? ACDD_VISIBLE : 0);
1205 
1206  if (ppwszString)
1207  {
1208  *ppwszString = NULL;
1209 
1210  if (dropped)
1211  {
1212  // get selected item
1213  INT iItem = m_hwndList.GetCurSel();
1214  if (iItem >= 0)
1215  {
1216  // get the text of item
1217  CStringW strText = m_hwndList.GetItemText(iItem);
1218 
1219  // store to *ppwszString
1220  SHStrDupW(strText, ppwszString);
1221  if (*ppwszString == NULL)
1222  return E_OUTOFMEMORY;
1223  }
1224  }
1225  }
1226 
1227  return S_OK;
1228 }
r dropped
Definition: btrfs.c:2948
HRESULT WINAPI SHStrDupW(LPCWSTR src, LPWSTR *dest)
Definition: string.c:2004
int32_t INT
Definition: typedefs.h:58
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
unsigned int BOOL
Definition: ntddk_ex.h:94
CACListView m_hwndList
#define S_OK
Definition: intsafe.h:52
#define NULL
Definition: types.h:112
CStringW GetItemText(INT iItem)

◆ GetEditText()

CStringW CAutoComplete::GetEditText ( ) const
inline

Definition at line 730 of file CAutoComplete.cpp.

731 {
734  return szText;
735  return L"";
736 }
static const WCHAR szText[]
Definition: dialog.c:139
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define _countof(array)
Definition: sndvol32.h:68
static const WCHAR L[]
Definition: oid.c:1250
#define L_MAX_URL_LENGTH
Definition: commctrl.h:4735
int WINAPI GetWindowTextW(HWND hWnd, LPWSTR lpString, int nMaxCount)
Definition: window.c:1412

Referenced by DoAutoAppend(), DoBackWord(), OnAutoCompStart(), and OnEditKeyDown().

◆ GetItemCount()

INT CAutoComplete::GetItemCount ( ) const
inline

Definition at line 718 of file CAutoComplete.cpp.

719 {
720  return m_outerList.GetSize();
721 }
int GetSize() const
Definition: atlsimpcoll.h:104
CSimpleArray< CStringW > m_outerList

Referenced by RepositionDropDown(), and ShowDropDown().

◆ GetItemText()

CStringW CAutoComplete::GetItemText ( INT  iItem) const

Definition at line 723 of file CAutoComplete.cpp.

724 {
725  if (iItem < 0 || m_outerList.GetSize() <= iItem)
726  return L"";
727  return m_outerList[iItem];
728 }
int GetSize() const
Definition: atlsimpcoll.h:104
static const WCHAR L[]
Definition: oid.c:1250
CSimpleArray< CStringW > m_outerList

Referenced by CACListView::GetItemText(), OnEditKeyDown(), OnListSelChange(), and OnNotify().

◆ GetOptions()

STDMETHODIMP CAutoComplete::GetOptions ( DWORD pdwFlag)
override

Implements IAutoComplete2.

Definition at line 1167 of file CAutoComplete.cpp.

1168 {
1169  TRACE("(%p) -> (%p)\n", this, pdwFlag);
1170  if (pdwFlag)
1171  {
1172  *pdwFlag = m_dwOptions;
1173  return S_OK;
1174  }
1175  return E_INVALIDARG;
1176 }
#define E_INVALIDARG
Definition: ddrawi.h:101
#define TRACE(s)
Definition: solgame.cpp:4
#define S_OK
Definition: intsafe.h:52

◆ GetQuickEdit()

CStringW CAutoComplete::GetQuickEdit ( LPCWSTR  pszText) const
protected

Definition at line 1378 of file CAutoComplete.cpp.

1379 {
1380  if (pszText[0] == 0 || m_strQuickComplete.IsEmpty())
1381  return pszText;
1382 
1383  // m_strQuickComplete will be "www.%s.com" etc.
1384  CStringW ret;
1385  ret.Format(m_strQuickComplete, pszText);
1386  return ret;
1387 }
int ret
bool IsEmpty() const
Definition: atlsimpstr.h:379
CStringW m_strQuickComplete

Referenced by OnEditKeyDown().

◆ GetStemText()

CStringW CAutoComplete::GetStemText ( const CStringW strText) const
inline

Definition at line 745 of file CAutoComplete.cpp.

746 {
747  INT ich = strText.ReverseFind(L'\\');
748  if (ich == -1)
749  return L""; // no stem
750  return strText.Left(ich + 1);
751 }
int32_t INT
Definition: typedefs.h:58
static const WCHAR L[]
Definition: oid.c:1250
int ReverseFind(_In_ XCHAR ch) const
Definition: cstringt.h:682
CStringT Left(int nCount) const
Definition: cstringt.h:728

Referenced by FinishCompletion(), and OnAutoCompStart().

◆ GetWndClassName()

static LPCWSTR CAutoComplete::GetWndClassName ( )
inlinestatic

Definition at line 153 of file CAutoComplete.h.

153 { return WC_DROPDOWNW; }
#define WC_DROPDOWNW

◆ HideDropDown()

VOID CAutoComplete::HideDropDown ( )

Definition at line 774 of file CAutoComplete.cpp.

775 {
777 }
#define SW_HIDE
Definition: winuser.h:762
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)

Referenced by EditWndProc(), FinishCompletion(), OnEditKeyDown(), CACListView::OnLButtonDown(), OnNCDestroy(), OnNotify(), OnTimer(), and ShowDropDown().

◆ Init()

STDMETHODIMP CAutoComplete::Init ( HWND  hwndEdit,
IUnknown punkACL,
LPCOLESTR  pwszRegKeyPath,
LPCOLESTR  pwszQuickComplete 
)
override

Implements IAutoComplete.

Definition at line 1102 of file CAutoComplete.cpp.

1104 {
1105  TRACE("(%p)->Init(0x%08lx, %p, %s, %s)\n",
1106  this, hwndEdit, punkACL, debugstr_w(pwszRegKeyPath), debugstr_w(pwszQuickComplete));
1107  // sanity check
1108  if (m_hwndEdit || !punkACL)
1109  return E_FAIL;
1110  if (!hwndEdit)
1111  return E_INVALIDARG;
1112  // do subclass textbox to watch messages
1113  m_fnOldEditProc = reinterpret_cast<WNDPROC>(::GetWindowLongPtrW(hwndEdit, GWLP_WNDPROC));
1114  if (!m_fnOldEditProc)
1115  return E_FAIL;
1116  if (!::SetWindowSubclass(hwndEdit, EditSubclassProc, 0, reinterpret_cast<DWORD_PTR>(this)))
1117  return E_FAIL;
1118  m_hwndEdit = hwndEdit;
1119  // add reference to m_hwndEdit
1120  AddRef();
1121  // set word break procedure
1122  m_fnOldWordBreakProc = reinterpret_cast<EDITWORDBREAKPROCW>(
1124  reinterpret_cast<LPARAM>(EditWordBreakProcW)));
1125  // save position
1127 
1128  // get an IEnumString
1129  ATLASSERT(!m_pEnum);
1130  punkACL->QueryInterface(IID_IEnumString, (VOID **)&m_pEnum);
1131  TRACE("m_pEnum: %p\n", static_cast<void *>(m_pEnum));
1132  if (m_pEnum)
1133  m_pEnum->AddRef(); // hold not to be freed
1134 
1135  // get an IACList
1136  ATLASSERT(!m_pACList);
1137  punkACL->QueryInterface(IID_IACList, (VOID **)&m_pACList);
1138  TRACE("m_pACList: %p\n", static_cast<void *>(m_pACList));
1139  if (m_pACList)
1140  m_pACList->AddRef(); // hold not to be freed
1141 
1142  UpdateDropDownState(); // create/hide the drop-down window if necessary
1143 
1144  // load quick completion info
1145  LoadQuickComplete(pwszRegKeyPath, pwszQuickComplete);
1146 
1147  // any combobox for m_hwndEdit?
1148  m_hwndCombo = NULL;
1150  WCHAR szClass[16];
1151  if (::GetClassNameW(hwndParent, szClass, _countof(szClass)))
1152  {
1153  if (::StrCmpIW(szClass, WC_COMBOBOXW) == 0 ||
1154  ::StrCmpIW(szClass, WC_COMBOBOXEXW) == 0)
1155  {
1156  m_hwndCombo = hwndParent; // get combobox
1157  }
1158  }
1159 
1160  return S_OK;
1161 }
const GUID IID_IEnumString
#define ATLASSERT(x)
Definition: CComVariant.cpp:10
#define EM_SETWORDBREAKPROC
Definition: winuser.h:2003
#define GetWindowLongPtrW
Definition: winuser.h:4805
#define E_FAIL
Definition: ddrawi.h:102
int WINAPI GetClassNameW(_In_ HWND hWnd, _Out_writes_to_(nMaxCount, return) LPWSTR lpClassName, _In_ int nMaxCount)
WNDPROC m_fnOldEditProc
CComPtr< IACList > m_pACList
#define debugstr_w
Definition: kernel32.h:32
#define E_INVALIDARG
Definition: ddrawi.h:101
static HWND hwndParent
Definition: cryptui.c:300
VOID LoadQuickComplete(LPCWSTR pwszRegKeyPath, LPCWSTR pwszQuickComplete)
BOOL WINAPI SetWindowSubclass(HWND hWnd, SUBCLASSPROC pfnSubclass, UINT_PTR uIDSubclass, DWORD_PTR dwRef)
Definition: commctrl.c:1261
#define TRACE(s)
Definition: solgame.cpp:4
EDITWORDBREAKPROCW m_fnOldWordBreakProc
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define _countof(array)
Definition: sndvol32.h:68
ULONG AddRef()
#define GWLP_WNDPROC
Definition: treelist.c:66
HWND hwndEdit
Definition: combotst.c:65
HWND WINAPI GetParent(_In_ HWND)
#define S_OK
Definition: intsafe.h:52
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define WC_COMBOBOXEXW
Definition: commctrl.h:3781
#define NULL
Definition: types.h:112
static LRESULT CALLBACK EditSubclassProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam, UINT_PTR uSubclassID, DWORD_PTR dwData)
VOID UpdateDropDownState()
HRESULT QueryInterface([in] REFIID riid, [out, iid_is(riid)] void **ppvObject)
static INT CALLBACK EditWordBreakProcW(LPWSTR lpch, INT index, INT count, INT code)
CComPtr< IEnumString > m_pEnum
BOOL WINAPI GetWindowRect(_In_ HWND, _Out_ LPRECT)
int WINAPI StrCmpIW(LPCWSTR lpszStr, LPCWSTR lpszComp)
Definition: string.c:353
#define WC_COMBOBOXW
Definition: commctrl.h:4717

◆ IsComboBoxDropped()

BOOL CAutoComplete::IsComboBoxDropped ( ) const
inline

Definition at line 706 of file CAutoComplete.cpp.

707 {
708  if (!::IsWindow(m_hwndCombo))
709  return FALSE;
711 }
#define CB_GETDROPPEDSTATE
Definition: winuser.h:1928
BOOL WINAPI IsWindow(_In_opt_ HWND)
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)

Referenced by ShowDropDown().

◆ LoadQuickComplete()

VOID CAutoComplete::LoadQuickComplete ( LPCWSTR  pwszRegKeyPath,
LPCWSTR  pwszQuickComplete 
)
protected

Definition at line 1345 of file CAutoComplete.cpp.

1346 {
1348 
1349  if (pwszRegKeyPath)
1350  {
1351  CStringW strPath = pwszRegKeyPath;
1352  INT ichSep = strPath.ReverseFind(L'\\'); // find separator
1353  if (ichSep != -1) // found the last separator
1354  {
1355  // split by the separator
1356  CStringW strKey = strPath.Left(ichSep);
1357  CStringW strName = strPath.Mid(ichSep + 1);
1358 
1359  // load from registry
1360  WCHAR szValue[MAX_PATH] = L"";
1361  DWORD cbValue = sizeof(szValue), dwType = REG_NONE;
1362  SHRegGetUSValueW(pwszRegKeyPath, strName, &dwType,
1363  szValue, &cbValue, FALSE, NULL, 0);
1364  if (szValue[0] != 0 && cbValue != 0 &&
1365  (dwType == REG_SZ || dwType == REG_EXPAND_SZ))
1366  {
1367  m_strQuickComplete = szValue;
1368  }
1369  }
1370  }
1371 
1372  if (pwszQuickComplete && m_strQuickComplete.IsEmpty())
1373  {
1374  m_strQuickComplete = pwszQuickComplete;
1375  }
1376 }
CStringT Mid(int iFirst, int nCount) const
Definition: cstringt.h:700
int32_t INT
Definition: typedefs.h:58
#define FALSE
Definition: types.h:117
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define MAX_PATH
Definition: compat.h:34
unsigned long DWORD
Definition: ntddk_ex.h:95
static const WCHAR L[]
Definition: oid.c:1250
bool IsEmpty() const
Definition: atlsimpstr.h:379
#define REG_EXPAND_SZ
Definition: nt_native.h:1494
#define NULL
Definition: types.h:112
int ReverseFind(_In_ XCHAR ch) const
Definition: cstringt.h:682
#define REG_NONE
Definition: nt_native.h:1492
LONG WINAPI SHRegGetUSValueW(LPCWSTR pSubKey, LPCWSTR pValue, LPDWORD pwType, LPVOID pvData, LPDWORD pcbData, BOOL flagIgnoreHKCU, LPVOID pDefaultData, DWORD wDefaultDataSize)
Definition: reg.c:594
CStringT Left(int nCount) const
Definition: cstringt.h:728
CStringW m_strQuickComplete
#define REG_SZ
Definition: layer.c:22

Referenced by Init().

◆ Next()

STDMETHODIMP CAutoComplete::Next ( ULONG  celt,
LPOLESTR rgelt,
ULONG pceltFetched 
)
override

Implements IEnumString.

Definition at line 1244 of file CAutoComplete.cpp.

1245 {
1246  TRACE("(%p, %d, %p, %p)\n", this, celt, rgelt, pceltFetched);
1247  if (rgelt)
1248  *rgelt = NULL;
1249  if (*pceltFetched)
1250  *pceltFetched = 0;
1251  if (celt != 1 || !rgelt || !pceltFetched || !m_pEnum)
1252  return E_INVALIDARG;
1253 
1254  LPWSTR pszText = NULL;
1255  HRESULT hr = m_pEnum->Next(1, &pszText, pceltFetched);
1256  if (hr == S_OK)
1257  *rgelt = pszText;
1258  else
1259  ::CoTaskMemFree(pszText);
1260  return hr;
1261 }
VOID WINAPI CoTaskMemFree(LPVOID ptr)
Definition: ifs.c:442
HRESULT hr
Definition: shlfolder.c:183
#define E_INVALIDARG
Definition: ddrawi.h:101
#define TRACE(s)
Definition: solgame.cpp:4
LONG HRESULT
Definition: typedefs.h:79
#define S_OK
Definition: intsafe.h:52
#define NULL
Definition: types.h:112
CComPtr< IEnumString > m_pEnum
WCHAR * LPWSTR
Definition: xmlstorage.h:184

◆ OnAutoCompFinish()

LRESULT CAutoComplete::OnAutoCompFinish ( UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam,
BOOL bHandled 
)
protected

Definition at line 2116 of file CAutoComplete.cpp.

2117 {
2118  PAC_THREAD pThread = reinterpret_cast<PAC_THREAD>(lParam);
2119  if (m_pThread == NULL)
2120  {
2121  FinishCompletion(pThread);
2122  }
2124  m_hThread = NULL;
2125  delete pThread;
2126  return 0;
2127 }
#define CloseHandle
Definition: compat.h:598
PAC_THREAD m_pThread
#define NULL
Definition: types.h:112
VOID FinishCompletion(PAC_THREAD pThread)
LPARAM lParam
Definition: combotst.c:139

◆ OnAutoCompStart()

LRESULT CAutoComplete::OnAutoCompStart ( UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam,
BOOL bHandled 
)
protected

Definition at line 2044 of file CAutoComplete.cpp.

2045 {
2046  BOOL bAppendOK = (BOOL)wParam;
2047 
2048  CStringW strText = GetEditText();
2049  if (m_strText.CompareNoCase(strText) == 0)
2050  {
2051  // no change
2052  return 0;
2053  }
2054 
2055  PAC_THREAD pThread = new AC_THREAD { this, bAppendOK, strText };
2056 
2057  // if previous text was empty
2058  if (m_strText.IsEmpty())
2059  {
2060  pThread->m_bReset = TRUE;
2061  }
2062  m_strText = strText;
2063 
2064  // do expand the items if the stem is changed
2065  CStringW strStemText = GetStemText(pThread->m_strText);
2066  if (m_strStemText.CompareNoCase(strStemText) != 0)
2067  {
2068  pThread->m_bReset = TRUE;
2069  pThread->m_bExpand = !strStemText.IsEmpty();
2070  m_strStemText = strStemText;
2071  }
2072 
2073  // reset if necessary
2074  if (pThread->m_bReset && m_pEnum)
2075  {
2076  HRESULT hr = m_pEnum->Reset(); // IEnumString::Reset
2077  TRACE("m_pEnum->Reset(%p): 0x%08lx\n",
2078  static_cast<IUnknown *>(m_pEnum), hr);
2079  }
2080 
2081  // update ac list if necessary
2082  if (pThread->m_bExpand && m_pACList)
2083  {
2084  HRESULT hr = m_pACList->Expand(strStemText); // IACList::Expand
2085  TRACE("m_pACList->Expand(%p, %S): 0x%08lx\n",
2086  static_cast<IUnknown *>(m_pACList),
2087  static_cast<LPCWSTR>(strStemText), hr);
2088  }
2089 
2091  if (pOld)
2092  delete pOld;
2093 
2094  BOOL bDoStart = FALSE;
2095  if (m_hThread)
2096  {
2098  {
2100  m_hThread = NULL;
2101  bDoStart = TRUE;
2102  }
2103  }
2104  else
2105  {
2106  bDoStart = TRUE;
2107  }
2108 
2109  if (bDoStart)
2111 
2112  return 0;
2113 }
BOOL m_bExpand
#define CloseHandle
Definition: compat.h:598
HRESULT hr
Definition: shlfolder.c:183
CStringW m_strStemText
#define TRUE
Definition: types.h:120
int CompareNoCase(_In_z_ PCXSTR psz) const
Definition: cstringt.h:695
_CRTIMP uintptr_t __cdecl _beginthreadex(_In_opt_ void *_Security, _In_ unsigned _StackSize, _In_ unsigned(__stdcall *_StartAddress)(void *), _In_opt_ void *_ArgList, _In_ unsigned _InitFlag, _Out_opt_ unsigned *_ThrdAddr)
#define BOOL
Definition: nt_native.h:43
WPARAM wParam
Definition: combotst.c:138
PAC_THREAD m_pThread
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
CComPtr< IACList > m_pACList
#define TRACE(s)
Definition: solgame.cpp:4
LONG HRESULT
Definition: typedefs.h:79
PVOID HANDLE
Definition: typedefs.h:73
VOID AutoCompThreadProc()
static PAC_THREAD InterlockedExchangeThreadData(volatile PAC_THREAD *Target, PAC_THREAD Value)
#define WAIT_TIMEOUT
Definition: dderror.h:14
bool IsEmpty() const
Definition: atlsimpstr.h:379
CStringW m_strText
#define NULL
Definition: types.h:112
CComPtr< IEnumString > m_pEnum
CStringW GetStemText(const CStringW &strText) const
CStringW GetEditText() const
CStringW m_strText

◆ OnCreate()

LRESULT CAutoComplete::OnCreate ( UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam,
BOOL bHandled 
)
protected

Definition at line 1529 of file CAutoComplete.cpp.

1530 {
1531  TRACE("CAutoComplete::OnCreate(%p)\n", this);
1532 
1533  // set the pointer of CAutoComplete
1534  m_hwndList.m_pDropDown = this;
1536  m_hwndSizeBox.m_pDropDown = this;
1537 
1538  // create the children
1539  m_hwndList.Create(m_hWnd);
1540  if (!m_hwndList)
1541  return -1; // failure
1542  m_hwndSizeBox.Create(m_hWnd);
1543  if (!m_hwndSizeBox)
1544  return -1; // failure
1545  m_hwndScrollBar.Create(m_hWnd);
1546  if (!m_hwndScrollBar)
1547  return -1; // failure
1548 
1549  // show the controls
1550  m_hwndList.ShowWindow(SW_SHOWNOACTIVATE);
1551  m_hwndSizeBox.ShowWindow(SW_SHOWNOACTIVATE);
1552  m_hwndScrollBar.ShowWindow(SW_SHOWNOACTIVATE);
1553 
1554  // set the list font
1555  m_hFont = reinterpret_cast<HFONT>(::GetStockObject(DEFAULT_GUI_FONT));
1557 
1558  // add reference to CAutoComplete::m_hWnd
1559  AddRef();
1560  return 0; // success
1561 }
HGDIOBJ WINAPI GetStockObject(_In_ int)
CACScrollBar m_hwndScrollBar
#define SW_SHOWNOACTIVATE
Definition: winuser.h:768
HWND Create(HWND hwndParent)
CACSizeBox m_hwndSizeBox
CAutoComplete * m_pDropDown
Definition: CAutoComplete.h:80
VOID SetFont(HFONT hFont)
#define TRACE(s)
Definition: solgame.cpp:4
ULONG AddRef()
#define DEFAULT_GUI_FONT
Definition: wingdi.h:908
CACListView m_hwndList
HWND Create(HWND hwndParent)
HWND Create(HWND hwndParent)
CAutoComplete * m_pDropDown
Definition: CAutoComplete.h:97
CAutoComplete * m_pDropDown
Definition: CAutoComplete.h:38

◆ OnDrawItem()

LRESULT CAutoComplete::OnDrawItem ( UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam,
BOOL bHandled 
)
protected

Definition at line 1607 of file CAutoComplete.cpp.

1608 {
1609  LPDRAWITEMSTRUCT pDraw = reinterpret_cast<LPDRAWITEMSTRUCT>(lParam);
1610  ATLASSERT(pDraw != NULL);
1611  ATLASSERT(m_hwndList.GetStyle() & LVS_OWNERDRAWFIXED);
1612 
1613  // sanity check
1614  if (pDraw->CtlType != ODT_LISTVIEW || pDraw->hwndItem != m_hwndList)
1615  return FALSE;
1616 
1617  // item rectangle
1618  RECT rcItem = pDraw->rcItem;
1619 
1620  // get info
1621  UINT iItem = pDraw->itemID; // the index of item
1622  CStringW strItem = m_hwndList.GetItemText(iItem); // get text of item
1623 
1624  // draw background and set text color
1625  HDC hDC = pDraw->hDC;
1626  BOOL bSelected = (pDraw->itemState & ODS_SELECTED);
1627  if (bSelected)
1628  {
1631  }
1632  else
1633  {
1636  }
1637 
1638  // draw text
1639  rcItem.left += ::GetSystemMetrics(SM_CXBORDER);
1640  HGDIOBJ hFontOld = ::SelectObject(hDC, m_hFont);
1641  const UINT uDT_ = DT_LEFT | DT_NOPREFIX | DT_SINGLELINE | DT_VCENTER;
1643  ::DrawTextW(hDC, strItem, -1, &rcItem, uDT_);
1644  ::SelectObject(hDC, hFontOld);
1645 
1646  return TRUE;
1647 }
#define COLOR_HIGHLIGHT
Definition: winuser.h:916
#define ATLASSERT(x)
Definition: CComVariant.cpp:10
#define TRUE
Definition: types.h:120
static HDC
Definition: imagelist.c:92
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1499
LONG left
Definition: windef.h:306
#define DT_NOPREFIX
Definition: winuser.h:537
#define COLOR_WINDOW
Definition: winuser.h:908
DWORD WINAPI GetSysColor(_In_ int)
#define ODT_LISTVIEW
Definition: commctrl.h:80
int WINAPI SetBkMode(_In_ HDC, _In_ int)
Definition: dc.c:1034
#define FALSE
Definition: types.h:117
#define DT_LEFT
Definition: winuser.h:534
unsigned int BOOL
Definition: ntddk_ex.h:94
#define TRANSPARENT
Definition: wingdi.h:949
#define DT_VCENTER
Definition: winuser.h:543
#define COLOR_HIGHLIGHTTEXT
Definition: winuser.h:917
#define COLOR_WINDOWTEXT
Definition: winuser.h:911
int WINAPI GetSystemMetrics(_In_ int)
CACListView m_hwndList
#define SM_CXBORDER
Definition: winuser.h:954
COLORREF WINAPI SetTextColor(_In_ HDC, _In_ COLORREF)
Definition: text.c:898
static HDC hDC
Definition: 3dtext.c:33
#define DT_SINGLELINE
Definition: winuser.h:540
unsigned int UINT
Definition: ndis.h:50
#define NULL
Definition: types.h:112
#define ODS_SELECTED
Definition: winuser.h:2521
int WINAPI FillRect(HDC, LPCRECT, HBRUSH)
HBRUSH WINAPI GetSysColorBrush(_In_ int)
LPARAM lParam
Definition: combotst.c:139
#define LVS_OWNERDRAWFIXED
Definition: commctrl.h:2283
INT WINAPI DrawTextW(HDC hdc, LPCWSTR str, INT count, LPRECT rect, UINT flags)
Definition: defwnd.c:17
CStringW GetItemText(INT iItem)

◆ OnEditChar()

LRESULT CAutoComplete::OnEditChar ( WPARAM  wParam,
LPARAM  lParam 
)

Definition at line 989 of file CAutoComplete.cpp.

990 {
991  TRACE("CACEditCtrl::OnEditChar(%p, %p)\n", this, wParam);
992  if (wParam == L'\n' || wParam == L'\t')
993  return 0; // eat
995  if (CanAutoSuggest() || CanAutoAppend())
997  return ret;
998 }
#define WM_CHAR
Definition: winuser.h:1700
VOID StartCompletion(BOOL bAppendOK)
WPARAM wParam
Definition: combotst.c:138
BOOL CanAutoSuggest() const
BOOL CanAutoAppend() const
LRESULT WINAPI DefSubclassProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: commctrl.c:1496
#define TRACE(s)
Definition: solgame.cpp:4
int ret
static const WCHAR L[]
Definition: oid.c:1250
#define VK_BACK
Definition: winuser.h:2174
LONG_PTR LRESULT
Definition: windef.h:209
LPARAM lParam
Definition: combotst.c:139

Referenced by EditWndProc().

◆ OnEditKeyDown()

BOOL CAutoComplete::OnEditKeyDown ( WPARAM  wParam,
LPARAM  lParam 
)

Definition at line 899 of file CAutoComplete.cpp.

900 {
901  TRACE("CAutoComplete::OnEditKeyDown(%p, %p)\n", this, wParam);
902 
903  UINT vk = (UINT)wParam; // virtual key
904  switch (vk)
905  {
906  case VK_UP: case VK_DOWN:
907  case VK_PRIOR: case VK_NEXT:
908  // is suggestion available?
909  if (!CanAutoSuggest())
910  return FALSE; // do default
911  if (IsWindowVisible())
912  return OnListUpDown(vk);
913  break;
914  case VK_ESCAPE:
915  {
916  // is suggestion available?
917  if (!CanAutoSuggest())
918  return FALSE; // do default
919  if (IsWindowVisible())
920  {
921  SetEditText(m_strText); // revert the edit text
922  // select the end
924  SetEditSel(cch, cch);
925  HideDropDown(); // hide
926  return TRUE; // eat
927  }
928  break;
929  }
930  case VK_RETURN:
931  {
932  if (::GetKeyState(VK_CONTROL) < 0)
933  {
934  // quick edit
935  CStringW strText = GetEditText();
936  SetEditText(GetQuickEdit(strText));
937  }
938  else
939  {
940  // if item is selected, then update the edit text
941  INT iItem = m_hwndList.GetCurSel();
942  if (iItem != -1)
943  {
944  CStringW strText = GetItemText(iItem);
945  SetEditText(strText);
946  }
947  }
948  // select all
950  SetEditSel(0, cch);
951  // hide
952  HideDropDown();
953  break;
954  }
955  case VK_TAB:
956  {
957  // ACO_USETAB
958  if (IsWindowVisible() && UseTab())
959  {
960  if (GetKeyState(VK_SHIFT) < 0)
961  return OnListUpDown(VK_UP);
962  else
963  return OnListUpDown(VK_DOWN);
964  }
965  break;
966  }
967  case VK_DELETE:
968  {
969  // is suggestion available?
970  if (!CanAutoSuggest())
971  return FALSE; // do default
972  ::DefSubclassProc(m_hwndEdit, WM_KEYDOWN, VK_DELETE, 0); // do default
974  return TRUE; // eat
975  }
976  case VK_BACK:
977  {
978  if (::GetKeyState(VK_CONTROL) < 0)
979  {
980  DoBackWord();
981  return TRUE; // eat
982  }
983  break;
984  }
985  }
986  return FALSE; // default
987 }
int GetLength() const
Definition: atlsimpstr.h:356
#define WM_GETTEXTLENGTH
Definition: winuser.h:1602
BOOL UseTab() const
#define TRUE
Definition: types.h:120
WORD vk
Definition: input.c:77
#define VK_TAB
Definition: winuser.h:2175
#define VK_DOWN
Definition: winuser.h:2203
#define VK_PRIOR
Definition: winuser.h:2196
#define VK_ESCAPE
Definition: winuser.h:2190
VOID StartCompletion(BOOL bAppendOK)
int32_t INT
Definition: typedefs.h:58
#define VK_RETURN
Definition: winuser.h:2177
WPARAM wParam
Definition: combotst.c:138
BOOL CanAutoSuggest() const
#define VK_NEXT
Definition: winuser.h:2197
WNDPROC m_fnOldEditProc
#define VK_UP
Definition: winuser.h:2201
#define FALSE
Definition: types.h:117
VOID SetEditText(LPCWSTR pszText)
#define VK_SHIFT
Definition: winuser.h:2178
#define WM_KEYDOWN
Definition: winuser.h:1698
BOOL OnListUpDown(UINT vk)
LRESULT WINAPI DefSubclassProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: commctrl.c:1496
#define VK_DELETE
Definition: winuser.h:2209
SHORT WINAPI GetKeyState(_In_ int)
#define TRACE(s)
Definition: solgame.cpp:4
VOID SetEditSel(INT ich0, INT ich1)
CStringW GetItemText(INT iItem) const
CACListView m_hwndList
#define VK_BACK
Definition: winuser.h:2174
CStringW GetQuickEdit(LPCWSTR pszText) const
unsigned int UINT
Definition: ndis.h:50
#define VK_CONTROL
Definition: winuser.h:2179
LRESULT WINAPI CallWindowProcW(_In_ WNDPROC, _In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
BOOL WINAPI IsWindowVisible(_In_ HWND)
CStringW GetEditText() const
IN PCTCH IN DWORD cch
Definition: pager.h:36
CStringW m_strText

Referenced by EditWndProc().

◆ OnExitSizeMove()

LRESULT CAutoComplete::OnExitSizeMove ( UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam,
BOOL bHandled 
)
protected

Definition at line 1591 of file CAutoComplete.cpp.

1592 {
1593  TRACE("CAutoComplete::OnExitSizeMove(%p)\n", this);
1594  m_bResized = TRUE; // remember resized
1595 
1596  ModifyStyle(WS_THICKFRAME, 0); // remove thick frame to resize
1597  // frame changed
1599  SetWindowPos(NULL, 0, 0, 0, 0, uSWP_);
1600 
1601  ::SetFocus(m_hwndEdit); // restore focus
1602  return 0;
1603 }
#define WS_THICKFRAME
Definition: pedump.c:630
#define TRUE
Definition: types.h:120
HWND WINAPI SetFocus(_In_opt_ HWND)
#define SWP_NOZORDER
Definition: winuser.h:1233
#define TRACE(s)
Definition: solgame.cpp:4
#define SWP_NOACTIVATE
Definition: winuser.h:1228
#define SWP_FRAMECHANGED
Definition: winuser.h:1226
#define SWP_NOSIZE
Definition: winuser.h:1231
unsigned int UINT
Definition: ndis.h:50
#define NULL
Definition: types.h:112
#define SWP_NOMOVE
Definition: winuser.h:1230
BOOL WINAPI SetWindowPos(_In_ HWND, _In_opt_ HWND, _In_ int, _In_ int, _In_ int, _In_ int, _In_ UINT)

◆ OnGetMinMaxInfo()

LRESULT CAutoComplete::OnGetMinMaxInfo ( UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam,
BOOL bHandled 
)
protected

Definition at line 1651 of file CAutoComplete.cpp.

1652 {
1653  // restrict minimum size
1654  LPMINMAXINFO pInfo = reinterpret_cast<LPMINMAXINFO>(lParam);
1657  return 0;
1658 }
POINT ptMinTrackSize
Definition: winuser.h:3606
#define SM_CYHSCROLL
Definition: winuser.h:952
long y
Definition: polytest.cpp:48
long x
Definition: polytest.cpp:48
int WINAPI GetSystemMetrics(_In_ int)
#define SM_CXVSCROLL
Definition: winuser.h:951
LPARAM lParam
Definition: combotst.c:139

◆ OnListSelChange()

VOID CAutoComplete::OnListSelChange ( )

Definition at line 1000 of file CAutoComplete.cpp.

1001 {
1002  // update EDIT text
1003  INT iItem = m_hwndList.GetCurSel();
1004  CStringW text = ((iItem != -1) ? GetItemText(iItem) : m_strText);
1005  SetEditText(text);
1006  // ensure the item visible
1007  m_hwndList.EnsureVisible(iItem, FALSE);
1008  // select the end
1009  INT cch = text.GetLength();
1010  SetEditSel(cch, cch);
1011 }
const WCHAR * text
Definition: package.c:1827
int32_t INT
Definition: typedefs.h:58
#define FALSE
Definition: types.h:117
VOID SetEditText(LPCWSTR pszText)
VOID SetEditSel(INT ich0, INT ich1)
CStringW GetItemText(INT iItem) const
CACListView m_hwndList
IN PCTCH IN DWORD cch
Definition: pager.h:36
CStringW m_strText

Referenced by OnNotify().

◆ OnListUpDown()

BOOL CAutoComplete::OnListUpDown ( UINT  vk)

Definition at line 1013 of file CAutoComplete.cpp.

1014 {
1015  if (!CanAutoSuggest())
1016  return FALSE; // default
1017 
1019  {
1020  ShowDropDown();
1021  return TRUE; // eat
1022  }
1023 
1024  INT iItem = m_hwndList.GetCurSel(); // current selection
1025  INT cItems = m_hwndList.GetItemCount(); // the number of items
1026  switch (vk)
1027  {
1028  case VK_UP:
1029  if (iItem == -1)
1030  iItem = cItems - 1;
1031  else if (iItem == 0)
1032  iItem = -1;
1033  else
1034  --iItem;
1035  m_hwndList.SetCurSel(iItem);
1036  break;
1037  case VK_DOWN:
1038  if (iItem == -1)
1039  iItem = 0;
1040  else if (iItem == cItems - 1)
1041  iItem = -1;
1042  else
1043  ++iItem;
1044  m_hwndList.SetCurSel(iItem);
1045  break;
1046  case VK_PRIOR:
1047  if (iItem == -1)
1048  {
1049  iItem = cItems - 1;
1050  }
1051  else if (iItem == 0)
1052  {
1053  iItem = -1;
1054  }
1055  else
1056  {
1057  iItem -= m_hwndList.GetVisibleCount() - 1;
1058  if (iItem < 0)
1059  iItem = 0;
1060  }
1061  m_hwndList.SetCurSel(iItem);
1062  break;
1063  case VK_NEXT:
1064  if (iItem == -1)
1065  {
1066  iItem = 0;
1067  }
1068  else if (iItem == cItems - 1)
1069  {
1070  iItem = -1;
1071  }
1072  else
1073  {
1074  iItem += m_hwndList.GetVisibleCount() - 1;
1075  if (iItem > cItems)
1076  iItem = cItems - 1;
1077  }
1078  m_hwndList.SetCurSel(iItem);
1079  break;
1080  default:
1081  {
1082  ATLASSERT(FALSE);
1083  break;
1084  }
1085  }
1086 
1087  return TRUE; // eat
1088 }
#define ATLASSERT(x)
Definition: CComVariant.cpp:10
#define TRUE
Definition: types.h:120
WORD vk
Definition: input.c:77
INT GetVisibleCount()
#define VK_DOWN
Definition: winuser.h:2203
#define VK_PRIOR
Definition: winuser.h:2196
int32_t INT
Definition: typedefs.h:58
BOOL CanAutoSuggest() const
#define VK_NEXT
Definition: winuser.h:2197
#define VK_UP
Definition: winuser.h:2201
#define FALSE
Definition: types.h:117
VOID SetCurSel(INT iItem)
CACListView m_hwndList
BOOL WINAPI IsWindowVisible(_In_ HWND)

Referenced by OnEditKeyDown().

◆ OnMeasureItem()

LRESULT CAutoComplete::OnMeasureItem ( UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam,
BOOL bHandled 
)
protected

Definition at line 1662 of file CAutoComplete.cpp.

1663 {
1664  LPMEASUREITEMSTRUCT pMeasure = reinterpret_cast<LPMEASUREITEMSTRUCT>(lParam);
1665  ATLASSERT(pMeasure != NULL);
1666  if (pMeasure->CtlType != ODT_LISTVIEW)
1667  return FALSE;
1668  if (!m_hwndList)
1669  return FALSE;
1670  ATLASSERT(m_hwndList.GetStyle() & LVS_OWNERDRAWFIXED);
1671  pMeasure->itemHeight = m_hwndList.m_cyItem; // height of item
1672  return TRUE;
1673 }
#define ATLASSERT(x)
Definition: CComVariant.cpp:10
#define TRUE
Definition: types.h:120
#define ODT_LISTVIEW
Definition: commctrl.h:80
#define FALSE
Definition: types.h:117
CACListView m_hwndList
#define NULL
Definition: types.h:112
LPARAM lParam
Definition: combotst.c:139
#define LVS_OWNERDRAWFIXED
Definition: commctrl.h:2283

◆ OnMouseActivate()

LRESULT CAutoComplete::OnMouseActivate ( UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam,
BOOL bHandled 
)
protected

Definition at line 1677 of file CAutoComplete.cpp.

1678 {
1679  return MA_NOACTIVATE; // don't activate by mouse
1680 }
#define MA_NOACTIVATE
Definition: winuser.h:2479

◆ OnNCActivate()

LRESULT CAutoComplete::OnNCActivate ( UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam,
BOOL bHandled 
)
protected

Definition at line 1684 of file CAutoComplete.cpp.

1685 {
1686  bHandled = FALSE; // do default
1687  return 0;
1688 }
#define FALSE
Definition: types.h:117

◆ OnNCDestroy()

LRESULT CAutoComplete::OnNCDestroy ( UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam,
BOOL bHandled 
)
protected

Definition at line 1564 of file CAutoComplete.cpp.

1565 {
1566  TRACE("CAutoComplete::OnNCDestroy(%p)\n", this);
1567 
1568  // hide
1569  if (IsWindowVisible())
1570  HideDropDown();
1571 
1572  // clear CAutoComplete pointers
1576 
1577  // destroy controls
1578  m_hwndList.DestroyWindow();
1579  m_hwndScrollBar.DestroyWindow();
1580  m_hwndSizeBox.DestroyWindow();
1581 
1582  // clean up
1583  m_hwndCombo = NULL;
1584  // remove reference to CAutoComplete::m_hWnd
1585  Release();
1586  return 0;
1587 }
CACScrollBar m_hwndScrollBar
CACSizeBox m_hwndSizeBox
CAutoComplete * m_pDropDown
Definition: CAutoComplete.h:80
ULONG Release()
#define TRACE(s)
Definition: solgame.cpp:4
CACListView m_hwndList
#define NULL
Definition: types.h:112
BOOL WINAPI IsWindowVisible(_In_ HWND)
CAutoComplete * m_pDropDown
Definition: CAutoComplete.h:97
CAutoComplete * m_pDropDown
Definition: CAutoComplete.h:38

◆ OnNCHitTest()

LRESULT CAutoComplete::OnNCHitTest ( UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam,
BOOL bHandled 
)
protected

Definition at line 1817 of file CAutoComplete.cpp.

1818 {
1819  TRACE("CAutoComplete::OnNCHitTest(%p)\n", this);
1820  POINT pt = { GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam) }; // in screen coordinates
1821  ScreenToClient(&pt); // into client coordinates
1822  if (ChildWindowFromPoint(pt) == m_hwndSizeBox) // hit?
1823  {
1824  // allow resizing (with cursor shape)
1825  return m_bDowner ? HTBOTTOMRIGHT : HTTOPRIGHT;
1826  }
1827  bHandled = FALSE; // do default
1828  return 0;
1829 }
#define pt(x, y)
Definition: drawing.c:79
CACSizeBox m_hwndSizeBox
#define GET_X_LPARAM(lp)
Definition: windowsx.h:274
#define FALSE
Definition: types.h:117
#define TRACE(s)
Definition: solgame.cpp:4
#define HTTOPRIGHT
Definition: winuser.h:2468
#define HTBOTTOMRIGHT
Definition: winuser.h:2471
#define GET_Y_LPARAM(lp)
Definition: windowsx.h:275
HWND WINAPI ChildWindowFromPoint(_In_ HWND, _In_ POINT)
BOOL WINAPI ScreenToClient(_In_ HWND, _Inout_ LPPOINT)
LPARAM lParam
Definition: combotst.c:139

◆ OnNCLButtonDown()

LRESULT CAutoComplete::OnNCLButtonDown ( UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam,
BOOL bHandled 
)
protected

Definition at line 1691 of file CAutoComplete.cpp.

1692 {
1693  switch (wParam)
1694  {
1695  case HTBOTTOMRIGHT: case HTTOPRIGHT:
1696  {
1697  // add thick frame to resize.
1698  ModifyStyle(0, WS_THICKFRAME);
1699  // frame changed
1701  SetWindowPos(NULL, 0, 0, 0, 0, uSWP_);
1702  break;
1703  }
1704  }
1705  bHandled = FALSE; // do default
1706  return 0;
1707 }
#define WS_THICKFRAME
Definition: pedump.c:630
#define SWP_NOZORDER
Definition: winuser.h:1233
WPARAM wParam
Definition: combotst.c:138
#define FALSE
Definition: types.h:117
#define HTTOPRIGHT
Definition: winuser.h:2468
#define SWP_NOACTIVATE
Definition: winuser.h:1228
#define SWP_FRAMECHANGED
Definition: winuser.h:1226
#define HTBOTTOMRIGHT
Definition: winuser.h:2471
#define SWP_NOSIZE
Definition: winuser.h:1231
unsigned int UINT
Definition: ndis.h:50
#define NULL
Definition: types.h:112
#define SWP_NOMOVE
Definition: winuser.h:1230
BOOL WINAPI SetWindowPos(_In_ HWND, _In_opt_ HWND, _In_ int, _In_ int, _In_ int, _In_ int, _In_ UINT)

◆ OnNotify()

LRESULT CAutoComplete::OnNotify ( UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam,
BOOL bHandled 
)
protected

Definition at line 1711 of file CAutoComplete.cpp.

1712 {
1713  LPNMHDR pnmh = reinterpret_cast<LPNMHDR>(lParam);
1714  ATLASSERT(pnmh != NULL);
1715 
1716  switch (pnmh->code)
1717  {
1718  case NM_DBLCLK: // double-clicked
1719  {
1720  TRACE("NM_DBLCLK\n");
1721  HideDropDown();
1722  break;
1723  }
1724  case NM_HOVER: // mouse is hovering
1725  {
1726  POINT pt;
1727  ::GetCursorPos(&pt); // get cursor position in screen coordinates
1728  m_hwndList.ScreenToClient(&pt); // into client coordinates
1729  INT iItem = m_hwndList.ItemFromPoint(pt.x, pt.y);
1730  if (iItem != -1)
1731  {
1732  m_bInSelectItem = TRUE; // don't respond
1733  m_hwndList.SetCurSel(iItem); // select
1735  }
1736  return TRUE; // eat
1737  }
1738  case LVN_GETDISPINFOA: // for user's information only
1739  {
1740  TRACE("LVN_GETDISPINFOA\n");
1741  if (pnmh->hwndFrom != m_hwndList)
1742  break;
1743 
1744  LV_DISPINFOA *pDispInfo = reinterpret_cast<LV_DISPINFOA *>(pnmh);
1745  LV_ITEMA *pItem = &pDispInfo->item;
1746  INT iItem = pItem->iItem;
1747  if (iItem == -1)
1748  break;
1749 
1750  CStringW strText = GetItemText(iItem);
1751  if (pItem->mask & LVIF_TEXT)
1752  SHUnicodeToAnsi(strText, pItem->pszText, pItem->cchTextMax);
1753  break;
1754  }
1755  case LVN_GETDISPINFOW: // for user's information only
1756  {
1757  TRACE("LVN_GETDISPINFOW\n");
1758  if (pnmh->hwndFrom != m_hwndList)
1759  break;
1760 
1761  LV_DISPINFOW *pDispInfo = reinterpret_cast<LV_DISPINFOW *>(pnmh);
1762  LV_ITEMW *pItem = &pDispInfo->item;
1763  INT iItem = pItem->iItem;
1764  if (iItem == -1)
1765  break;
1766 
1767  CStringW strText = GetItemText(iItem);
1768  if (pItem->mask & LVIF_TEXT)
1769  StringCbCopyW(pItem->pszText, pItem->cchTextMax, strText);
1770  break;
1771  }
1772  case LVN_HOTTRACK: // enabled by LVS_EX_TRACKSELECT
1773  {
1774  TRACE("LVN_HOTTRACK\n");
1775  LPNMLISTVIEW pListView = reinterpret_cast<LPNMLISTVIEW>(pnmh);
1776  INT iItem = pListView->iItem;
1777  TRACE("LVN_HOTTRACK: iItem:%d\n", iItem);
1778  m_hwndList.SetCurSel(iItem);
1779  m_hwndList.EnsureVisible(iItem, FALSE);
1780  return TRUE;
1781  }
1782  case LVN_ITEMACTIVATE: // enabled by LVS_EX_ONECLICKACTIVATE
1783  {
1784  TRACE("LVN_ITEMACTIVATE\n");
1785  LPNMITEMACTIVATE pItemActivate = reinterpret_cast<LPNMITEMACTIVATE>(pnmh);
1786  INT iItem = pItemActivate->iItem;
1787  TRACE("LVN_ITEMACTIVATE: iItem:%d\n", iItem);
1788  if (iItem != -1) // the item is clicked
1789  {
1790  SelectItem(iItem);
1791  HideDropDown();
1792  }
1793  break;
1794  }
1795  case LVN_ITEMCHANGED: // item info is changed
1796  {
1797  TRACE("LVN_ITEMCHANGED\n");
1798  LPNMLISTVIEW pListView = reinterpret_cast<LPNMLISTVIEW>(pnmh);
1799  if (pListView->uChanged & LVIF_STATE) // selection changed
1800  {
1801  // listview selection changed
1802  if (!m_bInSelectItem)
1803  {
1804  OnListSelChange();
1805  }
1806  UpdateScrollBar();
1807  }
1808  break;
1809  }
1810  }
1811 
1812  return 0;
1813 }
#define ATLASSERT(x)
Definition: CComVariant.cpp:10
#define LVN_HOTTRACK
Definition: commctrl.h:3152
#define TRUE
Definition: types.h:120
#define pt(x, y)
Definition: drawing.c:79
#define NM_HOVER
Definition: commctrl.h:138
#define LVN_GETDISPINFOA
Definition: commctrl.h:3153
#define LVN_ITEMCHANGED
Definition: commctrl.h:3131
#define LVN_GETDISPINFOW
Definition: commctrl.h:3154
BOOL WINAPI GetCursorPos(_Out_ LPPOINT)
Definition: cursoricon.c:2635
int32_t INT
Definition: typedefs.h:58
#define LVIF_TEXT
Definition: commctrl.h:2309
UINT code
Definition: winuser.h:3135
#define FALSE
Definition: types.h:117
#define LVN_ITEMACTIVATE
Definition: commctrl.h:3147
#define LV_ITEMW
Definition: commctrl.h:2332
#define LV_DISPINFOW
Definition: commctrl.h:3169
#define TRACE(s)
Definition: solgame.cpp:4
CStringW GetItemText(INT iItem) const
VOID SetCurSel(INT iItem)
CACListView m_hwndList
INT WINAPI SHUnicodeToAnsi(LPCWSTR lpSrcStr, LPSTR lpDstStr, INT iLen)
Definition: string.c:2783
HWND hwndFrom
Definition: winuser.h:3133
VOID UpdateScrollBar()
#define NM_DBLCLK
Definition: commctrl.h:131
VOID SelectItem(INT iItem)
#define LV_ITEMA
Definition: commctrl.h:2331
#define LV_DISPINFOA
Definition: commctrl.h:3168
#define NULL
Definition: types.h:112
INT ItemFromPoint(INT x, INT y)
#define LVIF_STATE
Definition: commctrl.h:2312
STRSAFEAPI StringCbCopyW(STRSAFE_LPWSTR pszDest, size_t cbDest, STRSAFE_LPCWSTR pszSrc)
Definition: strsafe.h:166
LPARAM lParam
Definition: combotst.c:139

◆ OnShowWindow()

LRESULT CAutoComplete::OnShowWindow ( UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam,
BOOL bHandled 
)
protected

Definition at line 1858 of file CAutoComplete.cpp.

1859 {
1860  // hook mouse events
1861  BOOL bShow = (BOOL)wParam;
1862  if (bShow)
1863  {
1864  if (s_hWatchWnd != m_hWnd && ::IsWindowVisible(s_hWatchWnd))
1866  s_hWatchWnd = m_hWnd; // watch this
1867 
1868  // unhook mouse if any
1869  if (s_hMouseHook)
1870  {
1871  HHOOK hHookOld = s_hMouseHook;
1872  s_hMouseHook = NULL;
1873  ::UnhookWindowsHookEx(hHookOld);
1874  }
1875 
1876  // hook mouse
1879 
1880  // set timer
1882 
1883  bHandled = FALSE; // do default
1884  return 0;
1885  }
1886  else
1887  {
1888  // kill timer
1890 
1891  s_hWatchWnd = NULL; // unwatch
1892 
1893  // unhook mouse if any
1894  if (s_hMouseHook)
1895  {
1896  HHOOK hHookOld = s_hMouseHook;
1897  s_hMouseHook = NULL;
1898  ::UnhookWindowsHookEx(hHookOld);
1899  }
1900 
1901  LRESULT ret = DefWindowProcW(uMsg, wParam, lParam); // do default
1902 
1903  if (m_hwndCombo)
1904  ::InvalidateRect(m_hwndCombo, NULL, TRUE); // redraw
1905 
1906  m_outerList.RemoveAll(); // no use
1907  return ret;
1908  }
1909 }
#define WH_MOUSE
Definition: winuser.h:37
#define ATLASSERT(x)
Definition: CComVariant.cpp:10
#define TRUE
Definition: types.h:120
#define SW_HIDE
Definition: winuser.h:762
static LRESULT CALLBACK MouseProc(INT nCode, WPARAM wParam, LPARAM lParam)
static HWND s_hWatchWnd
#define BOOL
Definition: nt_native.h:43
WPARAM wParam
Definition: combotst.c:138
LRESULT WINAPI DefWindowProcW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define WATCH_INTERVAL
BOOL WINAPI ShowWindowAsync(_In_ HWND, _In_ int)
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
DWORD WINAPI GetCurrentThreadId(VOID)
Definition: thread.c:458
UINT_PTR WINAPI SetTimer(_In_opt_ HWND, _In_ UINT_PTR, _In_ UINT, _In_opt_ TIMERPROC)
#define SetWindowsHookEx
Definition: winuser.h:5832
BOOL WINAPI InvalidateRect(_In_opt_ HWND, _In_opt_ LPCRECT, _In_ BOOL)
BOOL WINAPI KillTimer(_In_opt_ HWND, _In_ UINT_PTR)
int ret
BOOL WINAPI UnhookWindowsHookEx(_In_ HHOOK)
static HHOOK s_hMouseHook
#define NULL
Definition: types.h:112
BOOL WINAPI IsWindowVisible(_In_ HWND)
LONG_PTR LRESULT
Definition: windef.h:209
CSimpleArray< CStringW > m_outerList
LPARAM lParam
Definition: combotst.c:139
#define WATCH_TIMER_ID

◆ OnSize()

LRESULT CAutoComplete::OnSize ( UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam,
BOOL bHandled 
)
protected

Definition at line 1833 of file CAutoComplete.cpp.

1834 {
1835  // calculate the positions of the controls
1836  CRect rcList, rcScrollBar, rcSizeBox;
1837  CalcRects(m_bDowner, rcList, rcScrollBar, rcSizeBox);
1838 
1839  // reposition the controls in smartest way
1841  HDWP hDWP = ::BeginDeferWindowPos(3);
1843  rcScrollBar.left, rcScrollBar.top,
1844  rcScrollBar.Width(), rcScrollBar.Height(), uSWP_);
1846  rcSizeBox.left, rcSizeBox.top,
1847  rcSizeBox.Width(), rcSizeBox.Height(), uSWP_);
1849  rcList.left, rcList.top,
1850  rcList.Width(), rcList.Height(), uSWP_);
1851  ::EndDeferWindowPos(hDWP);
1852 
1853  UpdateScrollBar();
1854  return 0;
1855 }
CACScrollBar m_hwndScrollBar
HDWP WINAPI BeginDeferWindowPos(_In_ int)
VOID CalcRects(BOOL bDowner, RECT &rcListView, RECT &rcScrollBar, RECT &rcSizeBox) const
int Width() const
Definition: atltypes.h:407
CACSizeBox m_hwndSizeBox
LONG top
Definition: windef.h:307
#define HWND_TOP
Definition: winuser.h:1193
LONG left
Definition: windef.h:306
#define SWP_NOCOPYBITS
Definition: winuser.h:1229
BOOL WINAPI EndDeferWindowPos(_In_ HDWP)
int Height() const
Definition: atltypes.h:318
HDWP WINAPI DeferWindowPos(_In_ HDWP, _In_ HWND, _In_opt_ HWND, _In_ int, _In_ int, _In_ int, _In_ int, _In_ UINT)
#define SWP_NOACTIVATE
Definition: winuser.h:1228
CACListView m_hwndList
VOID UpdateScrollBar()
unsigned int UINT
Definition: ndis.h:50

◆ OnTimer()

LRESULT CAutoComplete::OnTimer ( UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam,
BOOL bHandled 
)
protected

Definition at line 1912 of file CAutoComplete.cpp.

1913 {
1914  if (wParam != WATCH_TIMER_ID) // sanity check
1915  return 0;
1916 
1917  // if the textbox is dead, then kill the timer
1918  if (!::IsWindow(m_hwndEdit))
1919  {
1921  return 0;
1922  }
1923 
1924  // m_hwndEdit is moved?
1925  RECT rcEdit;
1926  ::GetWindowRect(m_hwndEdit, &rcEdit);
1927  if (!::EqualRect(&rcEdit, &m_rcEdit))
1928  {
1929  // if so, hide
1930  HideDropDown();
1931 
1932  m_rcEdit = rcEdit; // update rectangle
1933  m_bResized = FALSE; // clear flag
1934  }
1935 
1936  return 0;
1937 }
BOOL WINAPI IsWindow(_In_opt_ HWND)
WPARAM wParam
Definition: combotst.c:138
#define FALSE
Definition: types.h:117
BOOL WINAPI KillTimer(_In_opt_ HWND, _In_ UINT_PTR)
BOOL WINAPI EqualRect(_In_ LPCRECT, _In_ LPCRECT)
BOOL WINAPI GetWindowRect(_In_ HWND, _Out_ LPRECT)
#define WATCH_TIMER_ID

◆ OnVScroll()

LRESULT CAutoComplete::OnVScroll ( UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam,
BOOL bHandled 
)
protected

Definition at line 1941 of file CAutoComplete.cpp.

1942 {
1943  TRACE("CAutoComplete::OnVScroll(%p)\n", this);
1944  WORD code = LOWORD(wParam);
1945  switch (code)
1946  {
1947  case SB_THUMBPOSITION: case SB_THUMBTRACK:
1948  {
1949  // get the scrolling info
1950  INT nPos = HIWORD(wParam);
1951  SCROLLINFO si = { sizeof(si), SIF_ALL };
1952  m_hwndList.GetScrollInfo(SB_VERT, &si);
1953 
1954  // scroll the list-view by CListView::EnsureVisible
1955  INT cItems = m_hwndList.GetItemCount();
1956  // iItem : cItems == (nPos - si.nMin) : (si.nMax - si.nMin).
1957  INT iItem = cItems * (nPos - si.nMin) / (si.nMax - si.nMin);
1958  if (nPos > si.nPos)
1959  {
1960  iItem += m_hwndList.GetVisibleCount();
1961  if (iItem >= cItems)
1962  iItem = cItems - 1;
1963  }
1964  m_hwndList.EnsureVisible(iItem, FALSE);
1965 
1966  // update scrolling position of m_hwndScrollBar
1967  si.fMask = SIF_POS;
1968  m_hwndList.GetScrollInfo(SB_VERT, &si);
1969  m_hwndScrollBar.SetScrollInfo(SB_VERT, &si, FALSE);
1970  break;
1971  }
1972  default:
1973  {
1974  // pass it to m_hwndList
1975  m_hwndList.SendMessageW(WM_VSCROLL, wParam, lParam);
1976  UpdateScrollBar();
1977  break;
1978  }
1979  }
1980  return 0;
1981 }
CACScrollBar m_hwndScrollBar
#define SB_VERT
Definition: winuser.h:553
INT GetVisibleCount()
int32_t INT
Definition: typedefs.h:58
WPARAM wParam
Definition: combotst.c:138
#define FALSE
Definition: types.h:117
#define SB_THUMBPOSITION
Definition: winuser.h:572
#define TRACE(s)
Definition: solgame.cpp:4
#define SB_THUMBTRACK
Definition: winuser.h:573
unsigned short WORD
Definition: ntddk_ex.h:93
CACListView m_hwndList
Definition: inflate.c:139
#define SIF_POS
Definition: winuser.h:1220
VOID UpdateScrollBar()
#define HIWORD(l)
Definition: typedefs.h:247
LPARAM lParam
Definition: combotst.c:139
#define LOWORD(l)
Definition: pedump.c:82
#define WM_VSCROLL
Definition: winuser.h:1727
#define SIF_ALL
Definition: winuser.h:1218

◆ ReLoadInnerList()

VOID CAutoComplete::ReLoadInnerList ( PAC_THREAD  pThread)
protected

Definition at line 1489 of file CAutoComplete.cpp.

1490 {
1491  pThread->m_innerList.RemoveAll(); // clear contents
1492 
1493  if (!m_pEnum || pThread->m_strText.IsEmpty())
1494  return;
1495 
1496  // reload the items
1497  LPWSTR pszItem;
1498  ULONG cGot;
1499  HRESULT hr;
1500  CSimpleArray<CStringW>& innerList = pThread->m_innerList;
1501  while (!m_pThread && m_hThread)
1502  {
1503  // get next item
1504  hr = m_pEnum->Next(1, &pszItem, &cGot);
1505  if (hr != S_OK)
1506  break;
1507 
1508  innerList.Add(pszItem); // append item to innerList
1509  ::CoTaskMemFree(pszItem); // free
1510  }
1511 }
BOOL Add(const T &t)
Definition: atlsimpcoll.h:58
VOID WINAPI CoTaskMemFree(LPVOID ptr)
Definition: ifs.c:442
HRESULT hr
Definition: shlfolder.c:183
PAC_THREAD m_pThread
CSimpleArray< CStringW > m_innerList
LONG HRESULT
Definition: typedefs.h:79
bool IsEmpty() const
Definition: atlsimpstr.h:379
#define S_OK
Definition: intsafe.h:52
CStringW m_strText
CComPtr< IEnumString > m_pEnum
unsigned int ULONG
Definition: retypes.h:1
WCHAR * LPWSTR
Definition: xmlstorage.h:184

Referenced by DoThreadWork().

◆ RepositionDropDown()

VOID CAutoComplete::RepositionDropDown ( )
protected

Definition at line 1389 of file CAutoComplete.cpp.

1390 {
1391  // get nearest monitor from m_hwndEdit
1392  HMONITOR hMon = ::MonitorFromWindow(m_hwndEdit, MONITOR_DEFAULTTONEAREST);
1393  ATLASSERT(hMon != NULL);
1394  if (hMon == NULL)
1395  return;
1396 
1397  // get nearest monitor info
1398  MONITORINFO mi = { sizeof(mi) };
1399  if (!::GetMonitorInfo(hMon, &mi))
1400  {
1401  ATLASSERT(FALSE);
1402  return;
1403  }
1404 
1405  // get count and item height
1406  INT cItems = GetItemCount();
1407  INT cyItem = m_hwndList.m_cyItem;
1408  ATLASSERT(cyItem > 0);
1409 
1410  // get m_hwndEdit position
1411  RECT rcEdit;
1412  ::GetWindowRect(m_hwndEdit, &rcEdit);
1413  INT x = rcEdit.left, y = rcEdit.bottom;
1414 
1415  // get list extent
1416  RECT rcMon = mi.rcMonitor;
1417  INT cx = rcEdit.right - rcEdit.left, cy = cItems * cyItem;
1418  BOOL bLongList = FALSE;
1419  if (cy > CY_LIST)
1420  {
1421  cy = INT(CY_LIST / cyItem) * cyItem;
1422  bLongList = TRUE;
1423  }
1424 
1425  // convert rectangle for frame
1426  RECT rc = { 0, 0, cx, cy };
1427  AdjustWindowRectEx(&rc, GetStyle(), FALSE, GetExStyle());
1428  cy = rc.bottom - rc.top;
1429 
1430  if (!m_bResized)
1431  {
1432  // is the drop-down window a 'downer' or 'upper'?
1433  // NOTE: 'downer' is below the EDIT control. 'upper' is above the EDIT control.
1434  m_bDowner = (rcEdit.bottom + cy < rcMon.bottom);
1435  }
1436 
1437  // adjust y and cy
1438  if (m_bDowner)
1439  {
1440  if (rcMon.bottom < y + cy)
1441  {
1442  cy = ((rcMon.bottom - y) / cyItem) * cyItem;
1443  bLongList = TRUE;
1444  }
1445  }
1446  else
1447  {
1448  if (rcEdit.top < rcMon.top + cy)
1449  {
1450  cy = ((rcEdit.top - rcMon.top) / cyItem) * cyItem;
1451  bLongList = TRUE;
1452  }
1453  y = rcEdit.top - cy;
1454  }
1455 
1456  // set status
1457  m_hwndSizeBox.SetStatus(m_bDowner, bLongList);
1458 
1459  if (m_bResized) // already resized?
1460  PostMessageW(WM_SIZE, 0, 0); // re-layout
1461  else
1462  MoveWindow(x, y, cx, cy); // move
1463 
1464  // show without activation
1466 }
#define SW_SHOWNOACTIVATE
Definition: winuser.h:768
#define ATLASSERT(x)
Definition: CComVariant.cpp:10
#define TRUE
Definition: types.h:120
#define INT
Definition: polytest.cpp:20
CACSizeBox m_hwndSizeBox
LONG top
Definition: windef.h:307
BOOL WINAPI AdjustWindowRectEx(_Inout_ LPRECT, _In_ DWORD, _In_ BOOL, _In_ DWORD)
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
static MONITORINFO mi
Definition: win.c:7339
LONG left
Definition: windef.h:306
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
LONG right
Definition: windef.h:308
RECT rcMonitor
Definition: winuser.h:3761
int32_t INT
Definition: typedefs.h:58
VOID SetStatus(BOOL bDowner, BOOL bLongList)
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
_Out_opt_ int _Out_opt_ int * cy
Definition: commctrl.h:585
#define CY_LIST
#define GetMonitorInfo
Definition: winuser.h:5767
#define WM_SIZE
Definition: winuser.h:1594
CACListView m_hwndList
BOOL WINAPI MoveWindow(_In_ HWND, _In_ int, _In_ int, _In_ int, _In_ int, _In_ BOOL)
INT GetItemCount() const
HMONITOR WINAPI MonitorFromWindow(HWND, DWORD)
#define NULL
Definition: types.h:112
GLint GLint GLint GLint GLint GLint y
Definition: gl.h:1548
_Out_opt_ int * cx
Definition: commctrl.h:585
BOOL WINAPI PostMessageW(_In_opt_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
LONG bottom
Definition: windef.h:309
BOOL WINAPI GetWindowRect(_In_ HWND, _Out_ LPRECT)

Referenced by FinishCompletion(), and ShowDropDown().

◆ Reset()

STDMETHODIMP CAutoComplete::Reset ( void  )
override

Implements IEnumString.

Definition at line 1271 of file CAutoComplete.cpp.

1272 {
1273  TRACE("(%p)\n", this);
1274  if (m_pEnum)
1275  return m_pEnum->Reset();
1276  return E_FAIL;
1277 }
#define E_FAIL
Definition: ddrawi.h:102
#define TRACE(s)
Definition: solgame.cpp:4
CComPtr< IEnumString > m_pEnum

Referenced by ResetEnumerator().

◆ ResetEnumerator()

STDMETHODIMP CAutoComplete::ResetEnumerator ( )
override

Implements IAutoCompleteDropDown.

Definition at line 1230 of file CAutoComplete.cpp.

1231 {
1232  FIXME("(%p): stub\n", this);
1233 
1234  Reset();
1235  m_hwndList.SendMessageW(LVM_SETITEMCOUNT, 0, 0);
1237  return S_OK;
1238 }
STDMETHODIMP Reset() override
#define FIXME(fmt,...)
Definition: debug.h:111
#define LVM_SETITEMCOUNT
Definition: commctrl.h:2696
CACListView m_hwndList
#define S_OK
Definition: intsafe.h:52
CSimpleArray< CStringW > m_outerList

◆ SelectItem()

VOID CAutoComplete::SelectItem ( INT  iItem)

Definition at line 779 of file CAutoComplete.cpp.

780 {
781  m_hwndList.SetCurSel(iItem);
782  if (iItem != -1)
783  m_hwndList.EnsureVisible(iItem, FALSE);
784 }
#define FALSE
Definition: types.h:117
VOID SetCurSel(INT iItem)
CACListView m_hwndList

Referenced by FinishCompletion(), CACListView::OnLButtonDown(), and OnNotify().

◆ SetEditSel()

VOID CAutoComplete::SetEditSel ( INT  ich0,
INT  ich1 
)

Definition at line 753 of file CAutoComplete.cpp.

754 {
756 }
WNDPROC m_fnOldEditProc
#define EM_SETSEL
Definition: winuser.h:2001
LRESULT WINAPI CallWindowProcW(_In_ WNDPROC, _In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)

Referenced by DoAutoAppend(), DoBackWord(), OnEditKeyDown(), CACListView::OnLButtonDown(), and OnListSelChange().

◆ SetEditText()

VOID CAutoComplete::SetEditText ( LPCWSTR  pszText)

Definition at line 738 of file CAutoComplete.cpp.

739 {
740  m_bInSetText = TRUE; // don't hide drop-down
741  ::CallWindowProcW(m_fnOldEditProc, m_hwndEdit, WM_SETTEXT, 0, reinterpret_cast<LPARAM>(pszText));
743 }
#define TRUE
Definition: types.h:120
WNDPROC m_fnOldEditProc
#define FALSE
Definition: types.h:117
#define WM_SETTEXT
Definition: winuser.h:1600
LRESULT WINAPI CallWindowProcW(_In_ WNDPROC, _In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)

Referenced by DoAutoAppend(), OnEditKeyDown(), CACListView::OnLButtonDown(), and OnListSelChange().

◆ SetOptions()

STDMETHODIMP CAutoComplete::SetOptions ( DWORD  dwFlag)
override

Implements IAutoComplete2.

Definition at line 1179 of file CAutoComplete.cpp.

1180 {
1181  TRACE("(%p) -> (0x%x)\n", this, dwFlag);
1182  m_dwOptions = dwFlag;
1183 
1184  if (m_dwOptions & ACO_SEARCH)
1185  FIXME(" ACO_SEARCH not supported\n");
1187  FIXME(" ACO_FILTERPREFIXES not supported\n");
1189  FIXME(" ACO_RTLREADING not supported\n");
1190 
1191  UpdateDropDownState(); // create/hide the drop-down window if necessary
1192  return S_OK;
1193 }
#define FIXME(fmt,...)
Definition: debug.h:111
#define TRACE(s)
Definition: solgame.cpp:4
#define S_OK
Definition: intsafe.h:52
VOID UpdateDropDownState()

◆ ShowDropDown()

VOID CAutoComplete::ShowDropDown ( )

Definition at line 758 of file CAutoComplete.cpp.

759 {
760  if (!m_hWnd || !CanAutoSuggest())
761  return;
762 
763  INT cItems = GetItemCount();
764  if (cItems == 0 || ::GetFocus() != m_hwndEdit || IsComboBoxDropped())
765  {
766  // hide the drop-down if necessary
767  HideDropDown();
768  return;
769  }
770 
772 }
BOOL IsComboBoxDropped() const
int32_t INT
Definition: typedefs.h:58
BOOL CanAutoSuggest() const
VOID RepositionDropDown()
INT GetItemCount() const
HWND WINAPI GetFocus(void)
Definition: window.c:1909

Referenced by OnListUpDown().

◆ Skip()

STDMETHODIMP CAutoComplete::Skip ( ULONG  celt)
override

Implements IEnumString.

Definition at line 1264 of file CAutoComplete.cpp.

1265 {
1266  TRACE("(%p, %d)\n", this, celt);
1267  return E_NOTIMPL;
1268 }
#define TRACE(s)
Definition: solgame.cpp:4
#define E_NOTIMPL
Definition: ddrawi.h:99

◆ StartCompletion()

VOID CAutoComplete::StartCompletion ( BOOL  bAppendOK)

Definition at line 1513 of file CAutoComplete.cpp.

1514 {
1515  TRACE("CAutoComplete::StartCompletion(%p, %d)\n", this, bAppendOK);
1516 
1517  if (!m_pEnum || (!CanAutoSuggest() && !CanAutoAppend()))
1518  return;
1519 
1520  ::SendMessageW(m_hWnd, AUTOCOMP_START, bAppendOK, 0);
1521 }
#define AUTOCOMP_START
BOOL CanAutoSuggest() const
BOOL CanAutoAppend() const
#define TRACE(s)
Definition: solgame.cpp:4
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
CComPtr< IEnumString > m_pEnum

Referenced by EditWndProc(), OnEditChar(), and OnEditKeyDown().

◆ UpdateDropDownState()

VOID CAutoComplete::UpdateDropDownState ( )
protected

Definition at line 1291 of file CAutoComplete.cpp.

1292 {
1293  if (CanAutoSuggest())
1294  {
1295  // create the drop-down window if not existed
1296  if (!m_hWnd)
1297  CreateDropDown();
1298  }
1299  else
1300  {
1301  // hide if existed
1302  if (m_hWnd)
1304  }
1305 }
#define SW_HIDE
Definition: winuser.h:762
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
BOOL CanAutoSuggest() const

Referenced by Init(), and SetOptions().

◆ UpdateScrollBar()

VOID CAutoComplete::UpdateScrollBar ( )

Definition at line 883 of file CAutoComplete.cpp.

884 {
885  // copy scroll info from m_hwndList to m_hwndScrollBar
886  SCROLLINFO si = { sizeof(si), SIF_ALL };
887  m_hwndList.GetScrollInfo(SB_VERT, &si);
888  m_hwndScrollBar.SetScrollInfo(SB_CTL, &si, FALSE);
889 
890  // show/hide scroll bar
891  INT cVisibles = m_hwndList.GetVisibleCount();
892  INT cItems = m_hwndList.GetItemCount();
893  BOOL bShowScroll = (cItems > cVisibles);
894  m_hwndScrollBar.ShowWindow(bShowScroll ? SW_SHOWNOACTIVATE : SW_HIDE);
895  if (bShowScroll)
896  m_hwndScrollBar.InvalidateRect(NULL, FALSE); // redraw
897 }
CACScrollBar m_hwndScrollBar
#define SW_SHOWNOACTIVATE
Definition: winuser.h:768
#define SB_CTL
Definition: winuser.h:554
#define SB_VERT
Definition: winuser.h:553
#define SW_HIDE
Definition: winuser.h:762
INT GetVisibleCount()
int32_t INT
Definition: typedefs.h:58
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
CACListView m_hwndList
#define NULL
Definition: types.h:112
#define SIF_ALL
Definition: winuser.h:1218

Referenced by CACListView::OnMouseWheel(), OnNotify(), OnSize(), and OnVScroll().

◆ UseTab()

BOOL CAutoComplete::UseTab ( ) const
inline

Definition at line 701 of file CAutoComplete.cpp.

702 {
703  return !!(m_dwOptions & ACO_USETAB) && m_bEnabled;
704 }

Referenced by EditWndProc(), and OnEditKeyDown().

Member Data Documentation

◆ m_bDowner

BOOL CAutoComplete::m_bDowner
protected

Definition at line 211 of file CAutoComplete.h.

Referenced by OnNCHitTest(), OnSize(), and RepositionDropDown().

◆ m_bEnabled

DWORD CAutoComplete::m_bEnabled
protected

Definition at line 213 of file CAutoComplete.h.

Referenced by CanAutoAppend(), CanAutoSuggest(), Enable(), FilterPrefixes(), and UseTab().

◆ m_bInSelectItem

BOOL CAutoComplete::m_bInSelectItem

Definition at line 155 of file CAutoComplete.h.

Referenced by FinishCompletion(), and OnNotify().

◆ m_bInSetText

BOOL CAutoComplete::m_bInSetText

Definition at line 154 of file CAutoComplete.h.

Referenced by EditWndProc(), and SetEditText().

◆ m_bResized

BOOL CAutoComplete::m_bResized
protected

Definition at line 216 of file CAutoComplete.h.

Referenced by OnExitSizeMove(), OnTimer(), and RepositionDropDown().

◆ m_dwOptions

DWORD CAutoComplete::m_dwOptions
protected

◆ m_fnOldEditProc

WNDPROC CAutoComplete::m_fnOldEditProc
protected

Definition at line 219 of file CAutoComplete.h.

Referenced by DoBackWord(), Init(), OnEditKeyDown(), SetEditSel(), and SetEditText().

◆ m_fnOldWordBreakProc

EDITWORDBREAKPROCW CAutoComplete::m_fnOldWordBreakProc
protected

Definition at line 220 of file CAutoComplete.h.

Referenced by EditWndProc(), and Init().

◆ m_hFont

HFONT CAutoComplete::m_hFont
protected

Definition at line 215 of file CAutoComplete.h.

Referenced by OnCreate(), OnDrawItem(), and ~CAutoComplete().

◆ m_hThread

HANDLE CAutoComplete::m_hThread
protected

◆ m_hwndCombo

HWND CAutoComplete::m_hwndCombo
protected

Definition at line 214 of file CAutoComplete.h.

Referenced by Init(), IsComboBoxDropped(), OnNCDestroy(), and OnShowWindow().

◆ m_hwndEdit

◆ m_hwndList

◆ m_hwndScrollBar

CACScrollBar CAutoComplete::m_hwndScrollBar
protected

Definition at line 229 of file CAutoComplete.h.

Referenced by OnCreate(), OnNCDestroy(), OnSize(), OnVScroll(), and UpdateScrollBar().

◆ m_hwndSizeBox

CACSizeBox CAutoComplete::m_hwndSizeBox
protected

Definition at line 230 of file CAutoComplete.h.

Referenced by OnCreate(), OnNCDestroy(), OnNCHitTest(), OnSize(), and RepositionDropDown().

◆ m_innerList

CSimpleArray<CStringW> CAutoComplete::m_innerList
protected

Definition at line 233 of file CAutoComplete.h.

Referenced by DoThreadWork(), and FinishCompletion().

◆ m_outerList

CSimpleArray<CStringW> CAutoComplete::m_outerList
protected

◆ m_pACList

CComPtr<IACList> CAutoComplete::m_pACList
protected

Definition at line 232 of file CAutoComplete.h.

Referenced by Init(), OnAutoCompStart(), and ~CAutoComplete().

◆ m_pEnum

CComPtr<IEnumString> CAutoComplete::m_pEnum
protected

◆ m_pThread

◆ m_rcEdit

RECT CAutoComplete::m_rcEdit
protected

Definition at line 217 of file CAutoComplete.h.

Referenced by Init(), and OnTimer().

◆ m_strQuickComplete

CStringW CAutoComplete::m_strQuickComplete
protected

Definition at line 227 of file CAutoComplete.h.

Referenced by GetQuickEdit(), and LoadQuickComplete().

◆ m_strStemText

CStringW CAutoComplete::m_strStemText
protected

Definition at line 226 of file CAutoComplete.h.

Referenced by FinishCompletion(), and OnAutoCompStart().

◆ m_strText

CStringW CAutoComplete::m_strText
protected

Definition at line 225 of file CAutoComplete.h.

Referenced by FinishCompletion(), OnAutoCompStart(), OnEditKeyDown(), and OnListSelChange().


The documentation for this class was generated from the following files: