advapi32/tests: Statically link to ConvertSidToStringSidA().
[wine.git] / dlls / shell32 / autocomplete.c
blob1a02c8301ed6b150da843059896c9d2bc9040455
1 /*
2 * AutoComplete interfaces implementation.
4 * Copyright 2004 Maxime Bellengé <maxime.bellenge@laposte.net>
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
22 Implemented:
23 - ACO_AUTOAPPEND style
24 - ACO_AUTOSUGGEST style
25 - ACO_UPDOWNKEYDROPSLIST style
27 - Handle pwzsRegKeyPath and pwszQuickComplete in Init
29 TODO:
30 - implement ACO_SEARCH style
31 - implement ACO_FILTERPREFIXES style
32 - implement ACO_USETAB style
33 - implement ACO_RTLREADING style
34 - implement ResetEnumerator
35 - string compares should be case-insensitive, the content of the list should be sorted
38 #include "config.h"
40 #include <stdarg.h>
41 #include <stdlib.h>
42 #include <string.h>
44 #define COBJMACROS
46 #include "wine/debug.h"
47 #include "windef.h"
48 #include "winbase.h"
49 #include "winreg.h"
50 #include "undocshell.h"
51 #include "shlwapi.h"
52 #include "winerror.h"
53 #include "objbase.h"
55 #include "pidl.h"
56 #include "shlobj.h"
57 #include "shldisp.h"
58 #include "debughlp.h"
59 #include "shell32_main.h"
61 #include "wine/unicode.h"
63 WINE_DEFAULT_DEBUG_CHANNEL(shell);
65 typedef struct
67 IAutoComplete2 IAutoComplete2_iface;
68 IAutoCompleteDropDown IAutoCompleteDropDown_iface;
69 LONG ref;
70 BOOL initialized;
71 BOOL enabled;
72 HWND hwndEdit;
73 HWND hwndListBox;
74 WNDPROC wpOrigEditProc;
75 WNDPROC wpOrigLBoxProc;
76 WCHAR *txtbackup;
77 WCHAR *quickComplete;
78 IEnumString *enumstr;
79 AUTOCOMPLETEOPTIONS options;
80 } IAutoCompleteImpl;
82 static const WCHAR autocomplete_propertyW[] = {'W','i','n','e',' ','A','u','t','o',
83 'c','o','m','p','l','e','t','e',' ',
84 'c','o','n','t','r','o','l',0};
86 static inline IAutoCompleteImpl *impl_from_IAutoComplete2(IAutoComplete2 *iface)
88 return CONTAINING_RECORD(iface, IAutoCompleteImpl, IAutoComplete2_iface);
91 static inline IAutoCompleteImpl *impl_from_IAutoCompleteDropDown(IAutoCompleteDropDown *iface)
93 return CONTAINING_RECORD(iface, IAutoCompleteImpl, IAutoCompleteDropDown_iface);
97 Window procedure for autocompletion
99 static LRESULT APIENTRY ACEditSubclassProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
101 IAutoCompleteImpl *This = GetPropW(hwnd, autocomplete_propertyW);
102 HRESULT hr;
103 WCHAR hwndText[255];
104 WCHAR *hwndQCText;
105 RECT r;
106 BOOL control, filled, displayall = FALSE;
107 int cpt, height, sel;
109 if (!This->enabled) return CallWindowProcW(This->wpOrigEditProc, hwnd, uMsg, wParam, lParam);
111 switch (uMsg)
113 case CB_SHOWDROPDOWN:
114 ShowWindow(This->hwndListBox, SW_HIDE);
115 break;
116 case WM_KILLFOCUS:
117 if ((This->options & ACO_AUTOSUGGEST) && ((HWND)wParam != This->hwndListBox))
119 ShowWindow(This->hwndListBox, SW_HIDE);
121 return CallWindowProcW(This->wpOrigEditProc, hwnd, uMsg, wParam, lParam);
122 case WM_KEYUP:
124 int len;
126 GetWindowTextW( hwnd, hwndText, sizeof(hwndText)/sizeof(WCHAR));
128 switch(wParam) {
129 case VK_RETURN:
130 /* If quickComplete is set and control is pressed, replace the string */
131 control = GetKeyState(VK_CONTROL) & 0x8000;
132 if (control && This->quickComplete) {
133 hwndQCText = HeapAlloc(GetProcessHeap(), 0,
134 (lstrlenW(This->quickComplete)+lstrlenW(hwndText))*sizeof(WCHAR));
135 sel = sprintfW(hwndQCText, This->quickComplete, hwndText);
136 SendMessageW(hwnd, WM_SETTEXT, 0, (LPARAM)hwndQCText);
137 SendMessageW(hwnd, EM_SETSEL, 0, sel);
138 HeapFree(GetProcessHeap(), 0, hwndQCText);
141 ShowWindow(This->hwndListBox, SW_HIDE);
142 return 0;
143 case VK_LEFT:
144 case VK_RIGHT:
145 return 0;
146 case VK_UP:
147 case VK_DOWN:
148 /* Two cases here :
149 - if the listbox is not visible, displays it
150 with all the entries if the style ACO_UPDOWNKEYDROPSLIST
151 is present but does not select anything.
152 - if the listbox is visible, change the selection
154 if ( (This->options & (ACO_AUTOSUGGEST | ACO_UPDOWNKEYDROPSLIST))
155 && (!IsWindowVisible(This->hwndListBox) && (! *hwndText)) )
157 /* We must display all the entries */
158 displayall = TRUE;
159 } else {
160 if (IsWindowVisible(This->hwndListBox)) {
161 int count;
163 count = SendMessageW(This->hwndListBox, LB_GETCOUNT, 0, 0);
164 /* Change the selection */
165 sel = SendMessageW(This->hwndListBox, LB_GETCURSEL, 0, 0);
166 if (wParam == VK_UP)
167 sel = ((sel-1) < 0) ? count-1 : sel-1;
168 else
169 sel = ((sel+1) >= count) ? -1 : sel+1;
170 SendMessageW(This->hwndListBox, LB_SETCURSEL, sel, 0);
171 if (sel != -1) {
172 WCHAR *msg;
173 int len;
175 len = SendMessageW(This->hwndListBox, LB_GETTEXTLEN, sel, 0);
176 msg = HeapAlloc(GetProcessHeap(), 0, (len+1)*sizeof(WCHAR));
177 SendMessageW(This->hwndListBox, LB_GETTEXT, sel, (LPARAM)msg);
178 SendMessageW(hwnd, WM_SETTEXT, 0, (LPARAM)msg);
179 SendMessageW(hwnd, EM_SETSEL, lstrlenW(msg), lstrlenW(msg));
180 HeapFree(GetProcessHeap(), 0, msg);
181 } else {
182 SendMessageW(hwnd, WM_SETTEXT, 0, (LPARAM)This->txtbackup);
183 SendMessageW(hwnd, EM_SETSEL, lstrlenW(This->txtbackup), lstrlenW(This->txtbackup));
186 return 0;
188 break;
189 case VK_BACK:
190 case VK_DELETE:
191 if ((! *hwndText) && (This->options & ACO_AUTOSUGGEST)) {
192 ShowWindow(This->hwndListBox, SW_HIDE);
193 return CallWindowProcW(This->wpOrigEditProc, hwnd, uMsg, wParam, lParam);
195 if (This->options & ACO_AUTOAPPEND) {
196 DWORD b;
197 SendMessageW(hwnd, EM_GETSEL, (WPARAM)&b, 0);
198 if (b>1) {
199 hwndText[b-1] = '\0';
200 } else {
201 hwndText[0] = '\0';
202 SetWindowTextW(hwnd, hwndText);
205 break;
206 default:
210 SendMessageW(This->hwndListBox, LB_RESETCONTENT, 0, 0);
212 HeapFree(GetProcessHeap(), 0, This->txtbackup);
213 len = strlenW(hwndText);
214 This->txtbackup = HeapAlloc(GetProcessHeap(), 0, (len + 1)*sizeof(WCHAR));
215 lstrcpyW(This->txtbackup, hwndText);
217 /* Returns if there is no text to search and we doesn't want to display all the entries */
218 if ((!displayall) && (! *hwndText) )
219 break;
221 IEnumString_Reset(This->enumstr);
222 filled = FALSE;
223 for(cpt = 0;;) {
224 LPOLESTR strs = NULL;
225 ULONG fetched;
227 hr = IEnumString_Next(This->enumstr, 1, &strs, &fetched);
228 if (hr != S_OK)
229 break;
231 if (!strncmpiW(hwndText, strs, len)) {
232 if (!filled && (This->options & ACO_AUTOAPPEND)) {
233 WCHAR buffW[255];
235 strcpyW(buffW, hwndText);
236 strcatW(buffW, &strs[len]);
237 SetWindowTextW(hwnd, buffW);
238 SendMessageW(hwnd, EM_SETSEL, len, strlenW(strs));
239 if (!(This->options & ACO_AUTOSUGGEST)) {
240 CoTaskMemFree(strs);
241 break;
245 if (This->options & ACO_AUTOSUGGEST) {
246 SendMessageW(This->hwndListBox, LB_ADDSTRING, 0, (LPARAM)strs);
247 cpt++;
250 filled = TRUE;
253 CoTaskMemFree(strs);
256 if (This->options & ACO_AUTOSUGGEST) {
257 if (filled) {
258 height = SendMessageW(This->hwndListBox, LB_GETITEMHEIGHT, 0, 0);
259 SendMessageW(This->hwndListBox, LB_CARETOFF, 0, 0);
260 GetWindowRect(hwnd, &r);
261 SetParent(This->hwndListBox, HWND_DESKTOP);
262 /* It seems that Windows XP displays 7 lines at most
263 and otherwise displays a vertical scroll bar */
264 SetWindowPos(This->hwndListBox, HWND_TOP,
265 r.left, r.bottom + 1, r.right - r.left, min(height * 7, height*(cpt+1)),
266 SWP_SHOWWINDOW );
267 } else {
268 ShowWindow(This->hwndListBox, SW_HIDE);
272 break;
274 case WM_DESTROY:
276 WNDPROC proc = This->wpOrigEditProc;
278 RemovePropW(hwnd, autocomplete_propertyW);
279 SetWindowLongPtrW(hwnd, GWLP_WNDPROC, (LONG_PTR)proc);
280 This->hwndEdit = NULL;
281 if (This->hwndListBox)
282 DestroyWindow(This->hwndListBox);
283 IAutoComplete2_Release(&This->IAutoComplete2_iface);
284 return CallWindowProcW(proc, hwnd, uMsg, wParam, lParam);
286 default:
287 return CallWindowProcW(This->wpOrigEditProc, hwnd, uMsg, wParam, lParam);
291 return 0;
294 static LRESULT APIENTRY ACLBoxSubclassProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
296 IAutoCompleteImpl *This = (IAutoCompleteImpl *)GetWindowLongPtrW(hwnd, GWLP_USERDATA);
297 WCHAR *msg;
298 int sel, len;
300 switch (uMsg) {
301 case WM_MOUSEMOVE:
302 sel = SendMessageW(hwnd, LB_ITEMFROMPOINT, 0, lParam);
303 SendMessageW(hwnd, LB_SETCURSEL, sel, 0);
304 break;
305 case WM_LBUTTONDOWN:
306 sel = SendMessageW(hwnd, LB_GETCURSEL, 0, 0);
307 if (sel < 0)
308 break;
309 len = SendMessageW(This->hwndListBox, LB_GETTEXTLEN, sel, 0);
310 msg = HeapAlloc(GetProcessHeap(), 0, (len+1)*sizeof(WCHAR));
311 SendMessageW(hwnd, LB_GETTEXT, sel, (LPARAM)msg);
312 SendMessageW(This->hwndEdit, WM_SETTEXT, 0, (LPARAM)msg);
313 SendMessageW(This->hwndEdit, EM_SETSEL, 0, lstrlenW(msg));
314 ShowWindow(hwnd, SW_HIDE);
315 HeapFree(GetProcessHeap(), 0, msg);
316 break;
317 default:
318 return CallWindowProcW(This->wpOrigLBoxProc, hwnd, uMsg, wParam, lParam);
320 return 0;
323 static void create_listbox(IAutoCompleteImpl *This)
325 HWND hwndParent;
327 hwndParent = GetParent(This->hwndEdit);
329 /* FIXME : The listbox should be resizable with the mouse. WS_THICKFRAME looks ugly */
330 This->hwndListBox = CreateWindowExW(0, WC_LISTBOXW, NULL,
331 WS_BORDER | WS_CHILD | WS_VSCROLL | LBS_HASSTRINGS | LBS_NOTIFY | LBS_NOINTEGRALHEIGHT,
332 CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
333 hwndParent, NULL, shell32_hInstance, NULL );
335 if (This->hwndListBox) {
336 This->wpOrigLBoxProc = (WNDPROC) SetWindowLongPtrW( This->hwndListBox, GWLP_WNDPROC, (LONG_PTR) ACLBoxSubclassProc);
337 SetWindowLongPtrW( This->hwndListBox, GWLP_USERDATA, (LONG_PTR)This);
341 /**************************************************************************
342 * AutoComplete_QueryInterface
344 static HRESULT WINAPI IAutoComplete2_fnQueryInterface(
345 IAutoComplete2 * iface,
346 REFIID riid,
347 LPVOID *ppvObj)
349 IAutoCompleteImpl *This = impl_from_IAutoComplete2(iface);
351 TRACE("(%p)->(IID:%s,%p)\n", This, shdebugstr_guid(riid), ppvObj);
352 *ppvObj = NULL;
354 if (IsEqualIID(riid, &IID_IUnknown) ||
355 IsEqualIID(riid, &IID_IAutoComplete) ||
356 IsEqualIID(riid, &IID_IAutoComplete2))
358 *ppvObj = &This->IAutoComplete2_iface;
360 else if (IsEqualIID(riid, &IID_IAutoCompleteDropDown))
362 *ppvObj = &This->IAutoCompleteDropDown_iface;
365 if (*ppvObj)
367 IUnknown_AddRef((IUnknown*)*ppvObj);
368 TRACE("-- Interface: (%p)->(%p)\n", ppvObj, *ppvObj);
369 return S_OK;
371 WARN("unsupported interface: %s\n", debugstr_guid(riid));
372 return E_NOINTERFACE;
375 /******************************************************************************
376 * IAutoComplete2_fnAddRef
378 static ULONG WINAPI IAutoComplete2_fnAddRef(
379 IAutoComplete2 * iface)
381 IAutoCompleteImpl *This = impl_from_IAutoComplete2(iface);
382 ULONG refCount = InterlockedIncrement(&This->ref);
384 TRACE("(%p)->(%u)\n", This, refCount - 1);
386 return refCount;
389 /******************************************************************************
390 * IAutoComplete2_fnRelease
392 static ULONG WINAPI IAutoComplete2_fnRelease(
393 IAutoComplete2 * iface)
395 IAutoCompleteImpl *This = impl_from_IAutoComplete2(iface);
396 ULONG refCount = InterlockedDecrement(&This->ref);
398 TRACE("(%p)->(%u)\n", This, refCount + 1);
400 if (!refCount) {
401 TRACE("destroying IAutoComplete(%p)\n", This);
402 HeapFree(GetProcessHeap(), 0, This->quickComplete);
403 HeapFree(GetProcessHeap(), 0, This->txtbackup);
404 if (This->enumstr)
405 IEnumString_Release(This->enumstr);
406 HeapFree(GetProcessHeap(), 0, This);
408 return refCount;
411 /******************************************************************************
412 * IAutoComplete2_fnEnable
414 static HRESULT WINAPI IAutoComplete2_fnEnable(
415 IAutoComplete2 * iface,
416 BOOL fEnable)
418 IAutoCompleteImpl *This = impl_from_IAutoComplete2(iface);
419 HRESULT hr = S_OK;
421 TRACE("(%p)->(%s)\n", This, (fEnable)?"true":"false");
423 This->enabled = fEnable;
425 return hr;
428 /******************************************************************************
429 * IAutoComplete2_fnInit
431 static HRESULT WINAPI IAutoComplete2_fnInit(
432 IAutoComplete2 * iface,
433 HWND hwndEdit,
434 IUnknown *punkACL,
435 LPCOLESTR pwzsRegKeyPath,
436 LPCOLESTR pwszQuickComplete)
438 IAutoCompleteImpl *This = impl_from_IAutoComplete2(iface);
440 TRACE("(%p)->(%p, %p, %s, %s)\n",
441 This, hwndEdit, punkACL, debugstr_w(pwzsRegKeyPath), debugstr_w(pwszQuickComplete));
443 if (This->options & ACO_SEARCH) FIXME(" ACO_SEARCH not supported\n");
444 if (This->options & ACO_FILTERPREFIXES) FIXME(" ACO_FILTERPREFIXES not supported\n");
445 if (This->options & ACO_USETAB) FIXME(" ACO_USETAB not supported\n");
446 if (This->options & ACO_RTLREADING) FIXME(" ACO_RTLREADING not supported\n");
448 if (!hwndEdit || !punkACL)
449 return E_INVALIDARG;
451 if (This->initialized)
453 WARN("Autocompletion object is already initialized\n");
454 /* This->hwndEdit is set to NULL when the edit window is destroyed. */
455 return This->hwndEdit ? E_FAIL : E_UNEXPECTED;
458 if (FAILED (IUnknown_QueryInterface (punkACL, &IID_IEnumString, (LPVOID*)&This->enumstr))) {
459 WARN("No IEnumString interface\n");
460 return E_NOINTERFACE;
463 This->initialized = TRUE;
464 This->hwndEdit = hwndEdit;
465 This->wpOrigEditProc = (WNDPROC) SetWindowLongPtrW( hwndEdit, GWLP_WNDPROC, (LONG_PTR) ACEditSubclassProc);
466 /* Keep at least one reference to the object until the edit window is destroyed. */
467 IAutoComplete2_AddRef(&This->IAutoComplete2_iface);
468 SetPropW( hwndEdit, autocomplete_propertyW, This );
470 if (This->options & ACO_AUTOSUGGEST)
471 create_listbox(This);
473 if (pwzsRegKeyPath) {
474 WCHAR *key;
475 WCHAR result[MAX_PATH];
476 WCHAR *value;
477 HKEY hKey = 0;
478 LONG res;
479 LONG len;
481 /* pwszRegKeyPath contains the key as well as the value, so we split */
482 key = HeapAlloc(GetProcessHeap(), 0, (lstrlenW(pwzsRegKeyPath)+1)*sizeof(WCHAR));
483 strcpyW(key, pwzsRegKeyPath);
484 value = strrchrW(key, '\\');
485 *value = 0;
486 value++;
487 /* Now value contains the value and buffer the key */
488 res = RegOpenKeyExW(HKEY_CURRENT_USER, key, 0, KEY_READ, &hKey);
489 if (res != ERROR_SUCCESS) {
490 /* if the key is not found, MSDN states we must seek in HKEY_LOCAL_MACHINE */
491 res = RegOpenKeyExW(HKEY_LOCAL_MACHINE, key, 0, KEY_READ, &hKey);
493 if (res == ERROR_SUCCESS) {
494 res = RegQueryValueW(hKey, value, result, &len);
495 if (res == ERROR_SUCCESS) {
496 This->quickComplete = HeapAlloc(GetProcessHeap(), 0, len*sizeof(WCHAR));
497 strcpyW(This->quickComplete, result);
499 RegCloseKey(hKey);
501 HeapFree(GetProcessHeap(), 0, key);
504 if ((pwszQuickComplete) && (!This->quickComplete)) {
505 This->quickComplete = HeapAlloc(GetProcessHeap(), 0, (lstrlenW(pwszQuickComplete)+1)*sizeof(WCHAR));
506 lstrcpyW(This->quickComplete, pwszQuickComplete);
509 return S_OK;
512 /**************************************************************************
513 * IAutoComplete2_fnGetOptions
515 static HRESULT WINAPI IAutoComplete2_fnGetOptions(
516 IAutoComplete2 * iface,
517 DWORD *pdwFlag)
519 IAutoCompleteImpl *This = impl_from_IAutoComplete2(iface);
520 HRESULT hr = S_OK;
522 TRACE("(%p) -> (%p)\n", This, pdwFlag);
524 *pdwFlag = This->options;
526 return hr;
529 /**************************************************************************
530 * IAutoComplete2_fnSetOptions
532 static HRESULT WINAPI IAutoComplete2_fnSetOptions(
533 IAutoComplete2 * iface,
534 DWORD dwFlag)
536 IAutoCompleteImpl *This = impl_from_IAutoComplete2(iface);
537 HRESULT hr = S_OK;
539 TRACE("(%p) -> (0x%x)\n", This, dwFlag);
541 This->options = dwFlag;
543 if ((This->options & ACO_AUTOSUGGEST) && This->hwndEdit && !This->hwndListBox)
544 create_listbox(This);
546 return hr;
549 /**************************************************************************
550 * IAutoComplete2 VTable
552 static const IAutoComplete2Vtbl acvt =
554 IAutoComplete2_fnQueryInterface,
555 IAutoComplete2_fnAddRef,
556 IAutoComplete2_fnRelease,
557 IAutoComplete2_fnInit,
558 IAutoComplete2_fnEnable,
559 /* IAutoComplete2 */
560 IAutoComplete2_fnSetOptions,
561 IAutoComplete2_fnGetOptions,
565 static HRESULT WINAPI IAutoCompleteDropDown_fnQueryInterface(IAutoCompleteDropDown *iface,
566 REFIID riid, LPVOID *ppvObj)
568 IAutoCompleteImpl *This = impl_from_IAutoCompleteDropDown(iface);
569 return IAutoComplete2_QueryInterface(&This->IAutoComplete2_iface, riid, ppvObj);
572 static ULONG WINAPI IAutoCompleteDropDown_fnAddRef(IAutoCompleteDropDown *iface)
574 IAutoCompleteImpl *This = impl_from_IAutoCompleteDropDown(iface);
575 return IAutoComplete2_AddRef(&This->IAutoComplete2_iface);
578 static ULONG WINAPI IAutoCompleteDropDown_fnRelease(IAutoCompleteDropDown *iface)
580 IAutoCompleteImpl *This = impl_from_IAutoCompleteDropDown(iface);
581 return IAutoComplete2_Release(&This->IAutoComplete2_iface);
584 /**************************************************************************
585 * IAutoCompleteDropDown_fnGetDropDownStatus
587 static HRESULT WINAPI IAutoCompleteDropDown_fnGetDropDownStatus(
588 IAutoCompleteDropDown *iface,
589 DWORD *pdwFlags,
590 LPWSTR *ppwszString)
592 IAutoCompleteImpl *This = impl_from_IAutoCompleteDropDown(iface);
593 BOOL dropped;
595 TRACE("(%p) -> (%p, %p)\n", This, pdwFlags, ppwszString);
597 dropped = IsWindowVisible(This->hwndListBox);
599 if (pdwFlags)
600 *pdwFlags = (dropped ? ACDD_VISIBLE : 0);
602 if (ppwszString) {
603 if (dropped) {
604 int sel;
606 sel = SendMessageW(This->hwndListBox, LB_GETCURSEL, 0, 0);
607 if (sel >= 0)
609 DWORD len;
611 len = SendMessageW(This->hwndListBox, LB_GETTEXTLEN, sel, 0);
612 *ppwszString = CoTaskMemAlloc((len+1)*sizeof(WCHAR));
613 SendMessageW(This->hwndListBox, LB_GETTEXT, sel, (LPARAM)*ppwszString);
615 else
616 *ppwszString = NULL;
618 else
619 *ppwszString = NULL;
622 return S_OK;
625 /**************************************************************************
626 * IAutoCompleteDropDown_fnResetEnumarator
628 static HRESULT WINAPI IAutoCompleteDropDown_fnResetEnumerator(
629 IAutoCompleteDropDown *iface)
631 IAutoCompleteImpl *This = impl_from_IAutoCompleteDropDown(iface);
633 FIXME("(%p): stub\n", This);
635 return E_NOTIMPL;
638 /**************************************************************************
639 * IAutoCompleteDropDown VTable
641 static const IAutoCompleteDropDownVtbl acdropdownvt =
643 IAutoCompleteDropDown_fnQueryInterface,
644 IAutoCompleteDropDown_fnAddRef,
645 IAutoCompleteDropDown_fnRelease,
646 IAutoCompleteDropDown_fnGetDropDownStatus,
647 IAutoCompleteDropDown_fnResetEnumerator,
650 /**************************************************************************
651 * IAutoComplete_Constructor
653 HRESULT WINAPI IAutoComplete_Constructor(IUnknown * pUnkOuter, REFIID riid, LPVOID * ppv)
655 IAutoCompleteImpl *lpac;
656 HRESULT hr;
658 if (pUnkOuter && !IsEqualIID (riid, &IID_IUnknown))
659 return CLASS_E_NOAGGREGATION;
661 lpac = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IAutoCompleteImpl));
662 if (!lpac)
663 return E_OUTOFMEMORY;
665 lpac->ref = 1;
666 lpac->IAutoComplete2_iface.lpVtbl = &acvt;
667 lpac->IAutoCompleteDropDown_iface.lpVtbl = &acdropdownvt;
668 lpac->enabled = TRUE;
669 lpac->options = ACO_AUTOAPPEND;
671 hr = IAutoComplete2_QueryInterface(&lpac->IAutoComplete2_iface, riid, ppv);
672 IAutoComplete2_Release(&lpac->IAutoComplete2_iface);
674 TRACE("-- (%p)->\n",lpac);
676 return hr;