AutoCompl.h
上传用户:sunh8215
上传日期:2010-02-13
资源大小:1616k
文件大小:2k
源码类别:

酒店行业

开发平台:

Visual C++

  1. ////////////////////////////////////////////////////////////////
  2. // VCKBASE -- August 2000
  3. // Compiles with Visual C++ 6.0, runs on Windows 98 and probably NT too.
  4. //
  5. #pragma once
  6. #include "subclass.h"
  7. //////////////////
  8. // Generic auto-completion object you can use to do auto-completion
  9. // for edit and combobox controls
  10. //
  11. // To use:
  12. // - instantiate one of these for each edit/combobox you want to hook
  13. // - add some strings to the string array
  14. // - call Init
  15. //
  16. class CAutoComplete : public CSubclassWnd {
  17. protected:
  18. CStringArray m_arStrings;  // list (array) of strings
  19. CString  m_sPrevious;  // previous content
  20. int m_bIgnoreChangeMsg;  // ignore EN_CHANGE message?
  21. UINT m_idMyControl;  // ID of control I am subclassing
  22. int m_iType;  // type of control (edit/combo)
  23. int m_iCurString;  // index to current string
  24. enum { Edit=1,ComboBox };
  25. // hook fn
  26. virtual LRESULT WindowProc(UINT msg, WPARAM wp, LPARAM lp);
  27. // helper fns you can override but shouldn't need to
  28. virtual UINT GetMatches(LPCTSTR pszText, CStringArray& arMatches,
  29. BOOL bFirstOnly=FALSE);
  30. virtual void OnFirstString();
  31. virtual BOOL OnNextString(CString& sNext);
  32. virtual BOOL OnMatchString(const CString& s, const CString& sMatch);
  33. virtual BOOL IgnoreCompletion(CString s);
  34. virtual void OnComplete(CWnd* pWnd, CString s);
  35. virtual void DoCompletion(CWnd* pWnd, CString s,
  36. const CStringArray& arMatches);
  37. public:
  38. CAutoComplete();
  39. ~CAutoComplete();
  40. void Init(CWnd* pWnd);
  41. CStringArray& GetStringList() { return m_arStrings; }
  42. };