ReactOS  0.4.15-dev-1070-ge1a01de
CAutoComplete Class Reference

#include <CAutoComplete.h>

Inheritance diagram for CAutoComplete:
Collaboration diagram for CAutoComplete:

Public Member Functions

 CAutoComplete ()
 
 ~CAutoComplete ()
 
void CreateListbox ()
 
virtual HRESULT WINAPI Enable (BOOL fEnable)
 
virtual HRESULT WINAPI Init (HWND hwndEdit, IUnknown *punkACL, LPCOLESTR pwzsRegKeyPath, LPCOLESTR pwszQuickComplete)
 
virtual HRESULT WINAPI GetOptions (DWORD *pdwFlag)
 
virtual HRESULT WINAPI SetOptions (DWORD dwFlag)
 
virtual HRESULT STDMETHODCALLTYPE GetDropDownStatus (DWORD *pdwFlags, LPWSTR *ppwszString)
 
virtual HRESULT STDMETHODCALLTYPE ResetEnumerator ()
 
virtual HRESULT STDMETHODCALLTYPE Next (ULONG celt, LPOLESTR *rgelt, ULONG *pceltFetched)
 
virtual HRESULT STDMETHODCALLTYPE Skip (ULONG celt)
 
virtual HRESULT STDMETHODCALLTYPE Reset ()
 
virtual HRESULT STDMETHODCALLTYPE Clone (IEnumString **ppenum)
 
- 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 LRESULT APIENTRY ACEditSubclassProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
 
static LRESULT APIENTRY ACLBoxSubclassProc (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
 
- 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)
 

Private Attributes

BOOL enabled
 
BOOL initialized
 
HWND hwndEdit
 
HWND hwndListBox
 
WNDPROC wpOrigEditProc
 
WNDPROC wpOrigLBoxProc
 
WCHARtxtbackup
 
WCHARquickComplete
 
CComPtr< IEnumStringenumstr
 
AUTOCOMPLETEOPTIONS options
 

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
 
- Public Attributes inherited from ATL::CComObjectRootBase
LONG m_dwRef
 

Detailed Description

Definition at line 25 of file CAutoComplete.h.

Constructor & Destructor Documentation

◆ CAutoComplete()

CAutoComplete::CAutoComplete ( )

Definition at line 48 of file CAutoComplete.cpp.

49 {
50  enabled = TRUE;
54  hwndListBox = NULL;
55  txtbackup = NULL;
57  hwndEdit = NULL;
59 }
#define TRUE
Definition: types.h:120
WNDPROC wpOrigLBoxProc
Definition: CAutoComplete.h:38
GLenum GLenum GLsizei const GLuint GLboolean enabled
Definition: glext.h:7750
#define FALSE
Definition: types.h:117
smooth NULL
Definition: ftsmooth.c:416
WCHAR * quickComplete
Definition: CAutoComplete.h:40
WNDPROC wpOrigEditProc
Definition: CAutoComplete.h:37
WCHAR * txtbackup
Definition: CAutoComplete.h:39

◆ ~CAutoComplete()

CAutoComplete::~CAutoComplete ( )

Definition at line 64 of file CAutoComplete.cpp.

65 {
66  TRACE(" destroying IAutoComplete(%p)\n", this);
69  if (wpOrigEditProc)
70  {
73  }
74  if (hwndListBox)
76 }
BOOL WINAPI DestroyWindow(_In_ HWND)
HANDLE WINAPI RemovePropW(_In_ HWND, _In_ LPCWSTR)
WCHAR * quickComplete
Definition: CAutoComplete.h:40
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:484
#define GWLP_WNDPROC
Definition: treelist.c:66
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
WNDPROC wpOrigEditProc
Definition: CAutoComplete.h:37
WCHAR * txtbackup
Definition: CAutoComplete.h:39
#define SetWindowLongPtrW
Definition: winuser.h:5321
static const WCHAR autocomplete_propertyW[]
#define HeapFree(x, y, z)
Definition: compat.h:483

Member Function Documentation

◆ ACEditSubclassProc()

LRESULT APIENTRY CAutoComplete::ACEditSubclassProc ( HWND  hwnd,
UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam 
)
static

Definition at line 327 of file CAutoComplete.cpp.

328 {
329  CAutoComplete *pThis = static_cast<CAutoComplete *>(GetPropW(hwnd, autocomplete_propertyW));
330  HRESULT hr;
331  WCHAR hwndText[255];
332  WCHAR *hwndQCText;
333  RECT r;
334  BOOL control, filled, displayall = FALSE;
335  int cpt, height, sel;
336  ULONG fetched;
337 
338  if (!pThis->enabled)
339  {
340  return CallWindowProcW(pThis->wpOrigEditProc, hwnd, uMsg, wParam, lParam);
341  }
342 
343  switch (uMsg)
344  {
345  case CB_SHOWDROPDOWN:
346  {
347  ShowWindow(pThis->hwndListBox, SW_HIDE);
348  }; break;
349 
350  case WM_KILLFOCUS:
351  {
352  if ((pThis->options & ACO_AUTOSUGGEST) && ((HWND)wParam != pThis->hwndListBox))
353  {
354  ShowWindow(pThis->hwndListBox, SW_HIDE);
355  }
356  return CallWindowProcW(pThis->wpOrigEditProc, hwnd, uMsg, wParam, lParam);
357  }; break;
358 
359  case WM_KEYUP:
360  {
361  GetWindowTextW(hwnd, (LPWSTR)hwndText, 255);
362 
363  switch(wParam)
364  {
365  case VK_RETURN:
366  {
367  /* If quickComplete is set and control is pressed, replace the string */
368  control = GetKeyState(VK_CONTROL) & 0x8000;
369  if (control && pThis->quickComplete)
370  {
371  hwndQCText = (WCHAR *)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
372  (wcslen(pThis->quickComplete)+wcslen(hwndText))*sizeof(WCHAR));
373  sel = swprintf(hwndQCText, pThis->quickComplete, hwndText);
374  SendMessageW(hwnd, WM_SETTEXT, 0, (LPARAM)hwndQCText);
375  SendMessageW(hwnd, EM_SETSEL, 0, sel);
376  HeapFree(GetProcessHeap(), 0, hwndQCText);
377  }
378 
379  ShowWindow(pThis->hwndListBox, SW_HIDE);
380  return 0;
381  }; break;
382 
383  case VK_LEFT:
384  case VK_RIGHT:
385  {
386  return 0;
387  }; break;
388 
389  case VK_UP:
390  case VK_DOWN:
391  {
392  /* Two cases here :
393  - if the listbox is not visible, displays it
394  with all the entries if the style ACO_UPDOWNKEYDROPSLIST
395  is present but does not select anything.
396  - if the listbox is visible, change the selection
397  */
399  && (!IsWindowVisible(pThis->hwndListBox) && (! *hwndText)) )
400  {
401  /* We must display all the entries */
402  displayall = TRUE;
403  }
404  else
405  {
406  if (IsWindowVisible(pThis->hwndListBox))
407  {
408  int count;
409 
410  count = SendMessageW(pThis->hwndListBox, LB_GETCOUNT, 0, 0);
411  /* Change the selection */
412  sel = SendMessageW(pThis->hwndListBox, LB_GETCURSEL, 0, 0);
413  if (wParam == VK_UP)
414  sel = ((sel-1) < 0) ? count-1 : sel-1;
415  else
416  sel = ((sel+1) >= count) ? -1 : sel+1;
417 
418  SendMessageW(pThis->hwndListBox, LB_SETCURSEL, sel, 0);
419 
420  if (sel != -1)
421  {
422  WCHAR *msg;
423  int len;
424 
426  msg = (WCHAR *)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, (len + 1) * sizeof(WCHAR));
427 
428  if (msg)
429  {
430  SendMessageW(pThis->hwndListBox, LB_GETTEXT, sel, (LPARAM)msg);
433 
434  HeapFree(GetProcessHeap(), 0, msg);
435  }
436  else
437  {
438  TRACE("HeapAlloc failed to allocate %d bytes\n", (len + 1) * sizeof(WCHAR));
439  }
440  }
441  else
442  {
445  }
446  }
447  return 0;
448  }
449  }; break;
450 
451  case VK_BACK:
452  {
453  if (GetKeyState(VK_CONTROL) < 0) // Ctrl+Backspace
454  {
456  return 0;
457  }
458  }
459  // FALL THROUGH
460  case VK_DELETE:
461  {
462  if ((! *hwndText) && (pThis->options & ACO_AUTOSUGGEST))
463  {
464  ShowWindow(pThis->hwndListBox, SW_HIDE);
465  return CallWindowProcW(pThis->wpOrigEditProc, hwnd, uMsg, wParam, lParam);
466  }
467 
468  if (pThis->options & ACO_AUTOAPPEND)
469  {
470  DWORD b;
472  if (b>1)
473  {
474  hwndText[b-1] = '\0';
475  }
476  else
477  {
478  hwndText[0] = '\0';
479  SetWindowTextW(hwnd, hwndText);
480  }
481  }
482  }; break;
483 
484  default:
485  ;
486  }
487 
489 
490  HeapFree(GetProcessHeap(), 0, pThis->txtbackup);
491 
492  pThis->txtbackup = (WCHAR *)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, (wcslen(hwndText)+1)*sizeof(WCHAR));
493 
494  if (pThis->txtbackup)
495  {
496  wcscpy(pThis->txtbackup, hwndText);
497  }
498  else
499  {
500  TRACE("HeapAlloc failed to allocate %d bytes\n", (wcslen(hwndText)+1)*sizeof(WCHAR));
501  }
502 
503  /* Returns if there is no text to search and we doesn't want to display all the entries */
504  if ((!displayall) && (! *hwndText) )
505  break;
506 
507  pThis->enumstr->Reset();
508  filled = FALSE;
509  size_t curlen = wcslen(hwndText);
510 
511  for(cpt = 0;;)
512  {
514  hr = pThis->enumstr->Next(1, &strs, &fetched);
515  if (hr != S_OK)
516  break;
517 
518  if (!_wcsnicmp(hwndText, strs, curlen))
519  {
520 
521  if (pThis->options & ACO_AUTOAPPEND && *hwndText)
522  {
523  CComBSTR str((PCWSTR)strs);
524  memcpy(str.m_str, hwndText, curlen * sizeof(WCHAR));
526  SendMessageW(hwnd, EM_SETSEL, curlen, str.Length());
527  if (!(pThis->options & ACO_AUTOSUGGEST))
528  break;
529  }
530 
531  if (pThis->options & ACO_AUTOSUGGEST)
532  {
534  filled = TRUE;
535  cpt++;
536  }
537  }
538  }
539 
540  if (pThis->options & ACO_AUTOSUGGEST)
541  {
542  if (filled)
543  {
545  SendMessageW(pThis->hwndListBox, LB_CARETOFF, 0, 0);
546  GetWindowRect(hwnd, &r);
548  /* It seems that Windows XP displays 7 lines at most
549  and otherwise displays a vertical scroll bar */
551  r.left, r.bottom + 1, r.right - r.left, min(height * 7, height * (cpt + 1)),
552  SWP_SHOWWINDOW );
553  }
554  else
555  {
556  ShowWindow(pThis->hwndListBox, SW_HIDE);
557  }
558  }
559 
560  }; break;
561 
562  case WM_DESTROY:
563  {
564  /* Release our reference that we had since ->Init() */
565  pThis->Release();
566  return 0;
567  }
568 
569 
570  default:
571  {
572  return CallWindowProcW(pThis->wpOrigEditProc, hwnd, uMsg, wParam, lParam);
573  }
574 
575  }
576 
577  return 0;
578 }
#define LB_SETCURSEL
Definition: winuser.h:2045
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
const uint16_t * PCWSTR
Definition: typedefs.h:57
HRESULT hr
Definition: shlfolder.c:183
#define LB_ADDSTRING
Definition: winuser.h:2013
#define TRUE
Definition: types.h:120
#define SW_HIDE
Definition: winuser.h:762
HWND WINAPI SetParent(_In_ HWND, _In_opt_ HWND)
GLdouble GLdouble GLdouble r
Definition: gl.h:2055
GLuint GLuint GLsizei count
Definition: gl.h:1545
static void Edit_BackWord(HWND hwndEdit)
_Check_return_ _CRTIMP int __cdecl _wcsnicmp(_In_reads_or_z_(_MaxCount) const wchar_t *_Str1, _In_reads_or_z_(_MaxCount) const wchar_t *_Str2, _In_ size_t _MaxCount)
#define VK_LEFT
Definition: winuser.h:2199
#define HWND_TOP
Definition: winuser.h:1193
BOOL WINAPI SetWindowTextW(_In_ HWND, _In_opt_ LPCWSTR)
UINT_PTR WPARAM
Definition: windef.h:207
#define VK_DOWN
Definition: winuser.h:2202
CComPtr< IEnumString > enumstr
Definition: CAutoComplete.h:41
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
static LPOLESTR
Definition: stg_prop.c:27
#define VK_RETURN
Definition: winuser.h:2176
WPARAM wParam
Definition: combotst.c:138
#define EM_GETSEL
Definition: winuser.h:1979
#define LB_RESETCONTENT
Definition: winuser.h:2037
#define VK_UP
Definition: winuser.h:2200
#define FALSE
Definition: types.h:117
unsigned int BOOL
Definition: ntddk_ex.h:94
#define CB_SHOWDROPDOWN
Definition: winuser.h:1952
ULONG Release()
const WCHAR * str
smooth NULL
Definition: ftsmooth.c:416
LONG_PTR LPARAM
Definition: windef.h:208
#define LB_GETTEXTLEN
Definition: winuser.h:2032
#define LB_GETCOUNT
Definition: winuser.h:2020
#define WM_SETTEXT
Definition: winuser.h:1599
WCHAR * quickComplete
Definition: CAutoComplete.h:40
#define VK_DELETE
Definition: winuser.h:2208
#define b
Definition: ke_i.h:79
#define WM_DESTROY
Definition: winuser.h:1591
SHORT WINAPI GetKeyState(_In_ int)
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
#define TRACE(s)
Definition: solgame.cpp:4
#define WM_KILLFOCUS
Definition: winuser.h:1596
#define GetProcessHeap()
Definition: compat.h:484
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
__wchar_t WCHAR
Definition: xmlstorage.h:180
LONG HRESULT
Definition: typedefs.h:79
#define swprintf(buf, format,...)
Definition: sprintf.c:56
#define EM_SETSEL
Definition: winuser.h:2000
#define WM_KEYUP
Definition: winuser.h:1698
unsigned long DWORD
Definition: ntddk_ex.h:95
#define LB_CARETOFF
Definition: undocuser.h:51
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
#define LB_GETTEXT
Definition: winuser.h:2031
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
GLenum GLsizei len
Definition: glext.h:6722
#define VK_BACK
Definition: winuser.h:2173
#define LB_GETITEMHEIGHT
Definition: winuser.h:2024
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
#define VK_RIGHT
Definition: winuser.h:2201
AUTOCOMPLETEOPTIONS options
Definition: CAutoComplete.h:42
#define S_OK
Definition: intsafe.h:51
int WINAPI GetWindowTextW(HWND hWnd, LPWSTR lpString, int nMaxCount)
Definition: window.c:1412
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define HWND_DESKTOP
Definition: winuser.h:1195
#define min(a, b)
Definition: monoChain.cc:55
#define LB_GETCURSEL
Definition: winuser.h:2021
WNDPROC wpOrigEditProc
Definition: CAutoComplete.h:37
HANDLE WINAPI GetPropW(_In_ HWND, _In_ LPCWSTR)
#define SWP_SHOWWINDOW
Definition: winuser.h:1233
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
#define VK_CONTROL
Definition: winuser.h:2178
#define msg(x)
Definition: auth_time.c:54
WCHAR * txtbackup
Definition: CAutoComplete.h:39
LRESULT WINAPI CallWindowProcW(_In_ WNDPROC, _In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
unsigned int ULONG
Definition: retypes.h:1
BOOL WINAPI IsWindowVisible(_In_ HWND)
BOOL WINAPI GetWindowRect(_In_ HWND, _Out_ LPRECT)
BOOL WINAPI SetWindowPos(_In_ HWND, _In_opt_ HWND, _In_ int, _In_ int, _In_ int, _In_ int, _In_ UINT)
WCHAR * LPWSTR
Definition: xmlstorage.h:184
static const WCHAR autocomplete_propertyW[]
LPARAM lParam
Definition: combotst.c:139
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define HeapFree(x, y, z)
Definition: compat.h:483

Referenced by Init().

◆ ACLBoxSubclassProc()

LRESULT APIENTRY CAutoComplete::ACLBoxSubclassProc ( HWND  hwnd,
UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam 
)
static

Definition at line 580 of file CAutoComplete.cpp.

581 {
582  CAutoComplete *pThis = reinterpret_cast<CAutoComplete *>(GetWindowLongPtrW(hwnd, GWLP_USERDATA));
583  WCHAR *msg;
584  int sel, len;
585 
586  switch (uMsg)
587  {
588  case WM_MOUSEMOVE:
589  {
592  }; break;
593 
594  case WM_LBUTTONDOWN:
595  {
596  sel = SendMessageW(hwnd, LB_GETCURSEL, 0, 0);
597 
598  if (sel < 0)
599  break;
600 
601  len = SendMessageW(pThis->hwndListBox, LB_GETTEXTLEN, sel, 0);
602  msg = (WCHAR *)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, (len + 1) * sizeof(WCHAR));
603 
604  if (msg)
605  {
607  SendMessageW(pThis->hwndEdit, WM_SETTEXT, 0, (LPARAM)msg);
608  SendMessageW(pThis->hwndEdit, EM_SETSEL, 0, wcslen(msg));
610 
611  HeapFree(GetProcessHeap(), 0, msg);
612  }
613  else
614  {
615  TRACE("HeapAlloc failed to allocate %d bytes\n", (len + 1) * sizeof(WCHAR));
616  }
617 
618  }; break;
619 
620  default:
621  return CallWindowProcW(pThis->wpOrigLBoxProc, hwnd, uMsg, wParam, lParam);
622  }
623  return 0;
624 }
#define LB_SETCURSEL
Definition: winuser.h:2045
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
#define WM_LBUTTONDOWN
Definition: winuser.h:1758
#define SW_HIDE
Definition: winuser.h:762
UINT_PTR WPARAM
Definition: windef.h:207
WNDPROC wpOrigLBoxProc
Definition: CAutoComplete.h:38
#define GetWindowLongPtrW
Definition: winuser.h:4804
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
WPARAM wParam
Definition: combotst.c:138
#define GWLP_USERDATA
Definition: treelist.c:63
LONG_PTR LPARAM
Definition: windef.h:208
#define LB_GETTEXTLEN
Definition: winuser.h:2032
#define WM_SETTEXT
Definition: winuser.h:1599
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:484
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define EM_SETSEL
Definition: winuser.h:2000
#define LB_GETTEXT
Definition: winuser.h:2031
GLenum GLsizei len
Definition: glext.h:6722
#define LB_ITEMFROMPOINT
Definition: winuser.h:2036
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define LB_GETCURSEL
Definition: winuser.h:2021
#define WM_MOUSEMOVE
Definition: winuser.h:1757
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
#define msg(x)
Definition: auth_time.c:54
LRESULT WINAPI CallWindowProcW(_In_ WNDPROC, _In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
LPARAM lParam
Definition: combotst.c:139
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define HeapFree(x, y, z)
Definition: compat.h:483

Referenced by CreateListbox().

◆ Clone()

HRESULT STDMETHODCALLTYPE CAutoComplete::Clone ( IEnumString **  ppenum)
virtual

Implements IEnumString.

Definition at line 683 of file CAutoComplete.cpp.

684 {
685  FIXME("(%p, %p): stub\n", this, ppOut);
686  *ppOut = NULL;
687  return E_NOTIMPL;
688 }
#define FIXME(fmt,...)
Definition: debug.h:111
smooth NULL
Definition: ftsmooth.c:416
#define E_NOTIMPL
Definition: ddrawi.h:99

◆ CreateListbox()

void CAutoComplete::CreateListbox ( )

Definition at line 95 of file CAutoComplete.cpp.

96 {
98 
99  /* FIXME : The listbox should be resizable with the mouse. WS_THICKFRAME looks ugly */
103  hwndParent, NULL,
105 
106  if (hwndListBox)
107  {
110  }
111 }
#define LBS_HASSTRINGS
Definition: pedump.c:684
WNDPROC wpOrigLBoxProc
Definition: CAutoComplete.h:38
#define WS_CHILD
Definition: pedump.c:617
#define GetWindowLongPtrW
Definition: winuser.h:4804
static LRESULT APIENTRY ACLBoxSubclassProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
#define LBS_NOINTEGRALHEIGHT
Definition: pedump.c:686
#define CW_USEDEFAULT
Definition: winuser.h:225
#define GWLP_USERDATA
Definition: treelist.c:63
smooth NULL
Definition: ftsmooth.c:416
static HWND hwndParent
Definition: cryptui.c:300
#define WC_LISTBOXW
Definition: commctrl.h:4707
HWND WINAPI CreateWindowExW(_In_ DWORD dwExStyle, _In_opt_ LPCWSTR lpClassName, _In_opt_ LPCWSTR lpWindowName, _In_ DWORD dwStyle, _In_ int X, _In_ int Y, _In_ int nWidth, _In_ int nHeight, _In_opt_ HWND hWndParent, _In_opt_ HMENU hMenu, _In_opt_ HINSTANCE hInstance, _In_opt_ LPVOID lpParam)
#define GWLP_WNDPROC
Definition: treelist.c:66
LRESULT(CALLBACK * WNDPROC)(HWND, UINT, WPARAM, LPARAM)
Definition: winuser.h:2881
HWND WINAPI GetParent(_In_ HWND)
#define WS_BORDER
Definition: pedump.c:625
#define LBS_NOTIFY
Definition: pedump.c:678
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
#define WS_VSCROLL
Definition: pedump.c:627
#define GWLP_HINSTANCE
Definition: winuser.h:850
#define SetWindowLongPtrW
Definition: winuser.h:5321

Referenced by Init(), and SetOptions().

◆ Enable()

HRESULT WINAPI CAutoComplete::Enable ( BOOL  fEnable)
virtual

Implements IAutoComplete.

Definition at line 81 of file CAutoComplete.cpp.

82 {
83  HRESULT hr = S_OK;
84 
85  TRACE("(%p)->(%s)\n", this, (fEnable) ? "true" : "false");
86 
87  enabled = fEnable;
88 
89  return hr;
90 }
HRESULT hr
Definition: shlfolder.c:183
GLenum GLenum GLsizei const GLuint GLboolean enabled
Definition: glext.h:7750
#define TRACE(s)
Definition: solgame.cpp:4
LONG HRESULT
Definition: typedefs.h:79
#define S_OK
Definition: intsafe.h:51

◆ GetDropDownStatus()

HRESULT STDMETHODCALLTYPE CAutoComplete::GetDropDownStatus ( DWORD pdwFlags,
LPWSTR ppwszString 
)
virtual

Implements IAutoCompleteDropDown.

Definition at line 629 of file CAutoComplete.cpp.

630 {
632 
633  if (pdwFlags)
634  *pdwFlags = (dropped ? ACDD_VISIBLE : 0);
635 
636  if (ppwszString)
637  {
638  *ppwszString = NULL;
639 
640  if (dropped)
641  {
642  int sel = SendMessageW(hwndListBox, LB_GETCURSEL, 0, 0);
643  if (sel >= 0)
644  {
646  *ppwszString = (LPWSTR)CoTaskMemAlloc((len+1)*sizeof(WCHAR));
647  SendMessageW(hwndListBox, LB_GETTEXT, sel, (LPARAM)*ppwszString);
648  }
649  }
650  }
651 
652  return S_OK;
653 }
r dropped
Definition: btrfs.c:2948
unsigned int BOOL
Definition: ntddk_ex.h:94
smooth NULL
Definition: ftsmooth.c:416
LONG_PTR LPARAM
Definition: windef.h:208
#define LB_GETTEXTLEN
Definition: winuser.h:2032
__wchar_t WCHAR
Definition: xmlstorage.h:180
unsigned long DWORD
Definition: ntddk_ex.h:95
#define LB_GETTEXT
Definition: winuser.h:2031
GLenum GLsizei len
Definition: glext.h:6722
#define S_OK
Definition: intsafe.h:51
LRESULT WINAPI SendMessageW(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
#define LB_GETCURSEL
Definition: winuser.h:2021
BOOL WINAPI IsWindowVisible(_In_ HWND)
WCHAR * LPWSTR
Definition: xmlstorage.h:184
LPVOID WINAPI CoTaskMemAlloc(SIZE_T size)
Definition: ifs.c:426

◆ GetOptions()

HRESULT WINAPI CAutoComplete::GetOptions ( DWORD pdwFlag)
virtual

Implements IAutoComplete2.

Definition at line 255 of file CAutoComplete.cpp.

256 {
257  HRESULT hr = S_OK;
258 
259  TRACE("(%p) -> (%p)\n", this, pdwFlag);
260 
261  *pdwFlag = options;
262 
263  return hr;
264 }
HRESULT hr
Definition: shlfolder.c:183
#define TRACE(s)
Definition: solgame.cpp:4
LONG HRESULT
Definition: typedefs.h:79
AUTOCOMPLETEOPTIONS options
Definition: CAutoComplete.h:42
#define S_OK
Definition: intsafe.h:51

◆ Init()

HRESULT WINAPI CAutoComplete::Init ( HWND  hwndEdit,
IUnknown punkACL,
LPCOLESTR  pwzsRegKeyPath,
LPCOLESTR  pwszQuickComplete 
)
virtual

Implements IAutoComplete.

Definition at line 117 of file CAutoComplete.cpp.

118 {
119  TRACE("(%p)->(0x%08lx, %p, %s, %s)\n",
120  this, hwndEdit, punkACL, debugstr_w(pwzsRegKeyPath), debugstr_w(pwszQuickComplete));
121 
122  if (options & ACO_AUTOSUGGEST)
123  TRACE(" ACO_AUTOSUGGEST\n");
124  if (options & ACO_AUTOAPPEND)
125  TRACE(" ACO_AUTOAPPEND\n");
126  if (options & ACO_SEARCH)
127  FIXME(" ACO_SEARCH not supported\n");
129  FIXME(" ACO_FILTERPREFIXES not supported\n");
130  if (options & ACO_USETAB)
131  FIXME(" ACO_USETAB not supported\n");
133  TRACE(" ACO_UPDOWNKEYDROPSLIST\n");
134  if (options & ACO_RTLREADING)
135  FIXME(" ACO_RTLREADING not supported\n");
136 
137  if (!hwndEdit || !punkACL)
138  return E_INVALIDARG;
139 
140  if (this->initialized)
141  {
142  WARN("Autocompletion object is already initialized\n");
143  /* This->hwndEdit is set to NULL when the edit window is destroyed. */
144  return this->hwndEdit ? E_FAIL : E_UNEXPECTED;
145  }
146 
148  {
149  TRACE("No IEnumString interface\n");
150  return E_NOINTERFACE;
151  }
152 
153  this->hwndEdit = hwndEdit;
154  this->initialized = TRUE;
155 
156  /* Keep at least one reference to the object until the edit window is destroyed. */
157  this->AddRef();
158 
159  /* If another AutoComplete object was previously assigned to this edit control,
160  release it but keep the same callback on the control, to avoid an infinite
161  recursive loop in ACEditSubclassProc while the property is set to this object */
162  CAutoComplete *prev = static_cast<CAutoComplete *>(GetPropW(hwndEdit, autocomplete_propertyW));
163 
164  if (prev && prev->initialized)
165  {
166  this->wpOrigEditProc = prev->wpOrigEditProc;
168  prev->wpOrigEditProc = NULL;
169  prev->Release();
170  }
171  else
172  {
173  SetPropW( this->hwndEdit, autocomplete_propertyW, (HANDLE)this );
175  }
176 
177  if (options & ACO_AUTOSUGGEST)
178  {
179  this->CreateListbox();
180  }
181 
182  if (pwzsRegKeyPath)
183  {
184  WCHAR *key;
186  WCHAR *value;
187  HKEY hKey = 0;
188  LONG res;
189  LONG len;
190 
191  /* pwszRegKeyPath contains the key as well as the value, so we split */
192  key = (WCHAR *)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, (wcslen(pwzsRegKeyPath) + 1) * sizeof(WCHAR));
193 
194  if (key)
195  {
196  wcscpy(key, pwzsRegKeyPath);
197  value = const_cast<WCHAR *>(wcsrchr(key, '\\'));
198 
199  if (value)
200  {
201  *value = 0;
202  value++;
203  /* Now value contains the value and buffer the key */
205 
206  if (res != ERROR_SUCCESS)
207  {
208  /* if the key is not found, MSDN states we must seek in HKEY_LOCAL_MACHINE */
210  }
211 
212  if (res == ERROR_SUCCESS)
213  {
214  len = sizeof(result);
215  res = RegQueryValueW(hKey, value, result, &len);
216  if (res == ERROR_SUCCESS)
217  {
220  }
221  RegCloseKey(hKey);
222  }
223  }
224 
225  HeapFree(GetProcessHeap(), 0, key);
226  }
227  else
228  {
229  TRACE("HeapAlloc Failed when trying to alloca %d bytes\n", (wcslen(pwzsRegKeyPath) + 1) * sizeof(WCHAR));
230  return S_FALSE;
231  }
232  }
233 
234  if ((pwszQuickComplete) && (!quickComplete))
235  {
236  quickComplete = (WCHAR *)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, (wcslen(pwszQuickComplete) + 1) * sizeof(WCHAR));
237 
238  if (quickComplete)
239  {
240  wcscpy(quickComplete, pwszQuickComplete);
241  }
242  else
243  {
244  TRACE("HeapAlloc Failed when trying to alloca %d bytes\n", (wcslen(pwszQuickComplete) + 1) * sizeof(WCHAR));
245  return S_FALSE;
246  }
247  }
248 
249  return S_OK;
250 }
static LRESULT APIENTRY ACEditSubclassProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
#define E_NOINTERFACE
Definition: winerror.h:2364
#define ERROR_SUCCESS
Definition: deptool.c:10
#define KEY_READ
Definition: nt_native.h:1023
#define TRUE
Definition: types.h:120
#define HKEY_CURRENT_USER
Definition: winreg.h:11
#define WARN(fmt,...)
Definition: debug.h:112
CComPtr< IEnumString > enumstr
Definition: CAutoComplete.h:41
#define IID_PPV_ARG(Itype, ppType)
#define E_FAIL
Definition: ddrawi.h:102
LONG WINAPI RegCloseKey(HKEY hKey)
Definition: reg.c:423
long LONG
Definition: pedump.c:60
#define debugstr_w
Definition: kernel32.h:32
#define FIXME(fmt,...)
Definition: debug.h:111
ULONG Release()
#define S_FALSE
Definition: winerror.h:2357
#define E_INVALIDARG
Definition: ddrawi.h:101
smooth NULL
Definition: ftsmooth.c:416
WCHAR * quickComplete
Definition: CAutoComplete.h:40
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:484
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
BOOL WINAPI SetPropW(_In_ HWND, _In_ LPCWSTR, _In_opt_ HANDLE)
__wchar_t WCHAR
Definition: xmlstorage.h:180
LSTATUS WINAPI RegQueryValueW(HKEY hkey, LPCWSTR name, LPWSTR data, LPLONG count)
Definition: reg.c:4254
#define MAX_PATH
Definition: compat.h:34
ULONG AddRef()
_CRTIMP wchar_t *__cdecl wcscpy(_Out_writes_z_(_String_length_(_Source)+1) wchar_t *_Dest, _In_z_ const wchar_t *_Source)
HKEY key
Definition: reg.c:42
GLenum GLsizei len
Definition: glext.h:6722
#define wcsrchr
Definition: compat.h:16
GLsizei const GLfloat * value
Definition: glext.h:6069
#define GWLP_WNDPROC
Definition: treelist.c:66
LRESULT(CALLBACK * WNDPROC)(HWND, UINT, WPARAM, LPARAM)
Definition: winuser.h:2881
#define S_OK
Definition: intsafe.h:51
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
WNDPROC wpOrigEditProc
Definition: CAutoComplete.h:37
HANDLE WINAPI GetPropW(_In_ HWND, _In_ LPCWSTR)
#define HEAP_ZERO_MEMORY
Definition: compat.h:134
#define E_UNEXPECTED
Definition: winerror.h:2456
HRESULT QueryInterface([in] REFIID riid, [out, iid_is(riid)] void **ppvObject)
GLuint res
Definition: glext.h:9613
LONG WINAPI RegOpenKeyExW(HKEY hKey, LPCWSTR lpSubKey, DWORD ulOptions, REGSAM samDesired, PHKEY phkResult)
Definition: reg.c:3366
#define SetWindowLongPtrW
Definition: winuser.h:5321
GLuint64EXT * result
Definition: glext.h:11304
static const WCHAR autocomplete_propertyW[]
void CreateListbox()
size_t __cdecl wcslen(_In_z_ const wchar_t *_Str)
#define HeapFree(x, y, z)
Definition: compat.h:483
#define SUCCEEDED(hr)
Definition: intsafe.h:49
Definition: path.c:41
#define HKEY_LOCAL_MACHINE
Definition: winreg.h:12

◆ Next()

HRESULT STDMETHODCALLTYPE CAutoComplete::Next ( ULONG  celt,
LPOLESTR rgelt,
ULONG pceltFetched 
)
virtual

Implements IEnumString.

Definition at line 664 of file CAutoComplete.cpp.

665 {
666  FIXME("(%p, %d, %p, %p): stub\n", this, celt, rgelt, pceltFetched);
667  *pceltFetched = 0;
668  return E_NOTIMPL;
669 }
#define FIXME(fmt,...)
Definition: debug.h:111
#define E_NOTIMPL
Definition: ddrawi.h:99

◆ Reset()

HRESULT STDMETHODCALLTYPE CAutoComplete::Reset ( void  )
virtual

Implements IEnumString.

Definition at line 677 of file CAutoComplete.cpp.

678 {
679  FIXME("(%p): stub\n", this);
680  return E_NOTIMPL;
681 }
#define FIXME(fmt,...)
Definition: debug.h:111
#define E_NOTIMPL
Definition: ddrawi.h:99

◆ ResetEnumerator()

HRESULT STDMETHODCALLTYPE CAutoComplete::ResetEnumerator ( )
virtual

Implements IAutoCompleteDropDown.

Definition at line 655 of file CAutoComplete.cpp.

656 {
657  FIXME("(%p): stub\n", this);
658  return E_NOTIMPL;
659 }
#define FIXME(fmt,...)
Definition: debug.h:111
#define E_NOTIMPL
Definition: ddrawi.h:99

◆ SetOptions()

HRESULT WINAPI CAutoComplete::SetOptions ( DWORD  dwFlag)
virtual

Implements IAutoComplete2.

Definition at line 269 of file CAutoComplete.cpp.

270 {
271  HRESULT hr = S_OK;
272 
273  TRACE("(%p) -> (0x%x)\n", this, dwFlag);
274 
275  options = (AUTOCOMPLETEOPTIONS)dwFlag;
276 
278  CreateListbox();
279 
280  return hr;
281 }
HRESULT hr
Definition: shlfolder.c:183
#define TRACE(s)
Definition: solgame.cpp:4
LONG HRESULT
Definition: typedefs.h:79
enum IAutoComplete2::_tagAUTOCOMPLETEOPTIONS AUTOCOMPLETEOPTIONS
#define S_OK
Definition: intsafe.h:51
void CreateListbox()

◆ Skip()

HRESULT STDMETHODCALLTYPE CAutoComplete::Skip ( ULONG  celt)
virtual

Implements IEnumString.

Definition at line 671 of file CAutoComplete.cpp.

672 {
673  FIXME("(%p, %d): stub\n", this, celt);
674  return E_NOTIMPL;
675 }
#define FIXME(fmt,...)
Definition: debug.h:111
#define E_NOTIMPL
Definition: ddrawi.h:99

Member Data Documentation

◆ enabled

BOOL CAutoComplete::enabled
private

Definition at line 33 of file CAutoComplete.h.

Referenced by ACEditSubclassProc().

◆ enumstr

CComPtr<IEnumString> CAutoComplete::enumstr
private

Definition at line 41 of file CAutoComplete.h.

Referenced by ACEditSubclassProc(), and Init().

◆ hwndEdit

HWND CAutoComplete::hwndEdit
private

◆ hwndListBox

HWND CAutoComplete::hwndListBox
private

◆ initialized

BOOL CAutoComplete::initialized
private

Definition at line 34 of file CAutoComplete.h.

Referenced by CAutoComplete(), and Init().

◆ options

AUTOCOMPLETEOPTIONS CAutoComplete::options
private

Definition at line 42 of file CAutoComplete.h.

Referenced by ACEditSubclassProc(), and GetOptions().

◆ quickComplete

WCHAR* CAutoComplete::quickComplete
private

Definition at line 40 of file CAutoComplete.h.

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

◆ txtbackup

WCHAR* CAutoComplete::txtbackup
private

Definition at line 39 of file CAutoComplete.h.

Referenced by ACEditSubclassProc(), CAutoComplete(), and ~CAutoComplete().

◆ wpOrigEditProc

WNDPROC CAutoComplete::wpOrigEditProc
private

Definition at line 37 of file CAutoComplete.h.

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

◆ wpOrigLBoxProc

WNDPROC CAutoComplete::wpOrigLBoxProc
private

Definition at line 38 of file CAutoComplete.h.

Referenced by ACLBoxSubclassProc(), CAutoComplete(), and CreateListbox().


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