2004-04-19 21:26:57 +02:00
|
|
|
/*
|
|
|
|
* AutoComplete interfaces implementation.
|
|
|
|
*
|
2008-10-18 19:20:53 +02:00
|
|
|
* Copyright 2004 Maxime Bellengé <maxime.bellenge@laposte.net>
|
2004-04-19 21:26:57 +02:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2004-04-19 21:26:57 +02:00
|
|
|
*/
|
|
|
|
|
2004-04-26 22:06:24 +02:00
|
|
|
/*
|
|
|
|
Implemented:
|
|
|
|
- ACO_AUTOAPPEND style
|
|
|
|
- ACO_AUTOSUGGEST style
|
|
|
|
- ACO_UPDOWNKEYDROPSLIST style
|
|
|
|
|
2004-04-30 06:14:33 +02:00
|
|
|
- Handle pwzsRegKeyPath and pwszQuickComplete in Init
|
|
|
|
|
2004-04-26 22:06:24 +02:00
|
|
|
TODO:
|
|
|
|
- implement ACO_SEARCH style
|
|
|
|
- implement ACO_FILTERPREFIXES style
|
|
|
|
- implement ACO_USETAB style
|
|
|
|
- implement ACO_RTLREADING style
|
2008-09-17 21:46:40 +02:00
|
|
|
- implement ResetEnumerator
|
|
|
|
- string compares should be case-insensitive, the content of the list should be sorted
|
2004-04-26 22:06:24 +02:00
|
|
|
|
|
|
|
*/
|
|
|
|
#include "config.h"
|
|
|
|
|
2004-04-19 21:26:57 +02:00
|
|
|
#include <stdarg.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
2004-10-07 05:06:48 +02:00
|
|
|
|
|
|
|
#define COBJMACROS
|
|
|
|
|
2004-04-19 21:26:57 +02:00
|
|
|
#include "wine/debug.h"
|
|
|
|
#include "windef.h"
|
|
|
|
#include "winbase.h"
|
|
|
|
#include "winreg.h"
|
|
|
|
#include "undocshell.h"
|
|
|
|
#include "shlwapi.h"
|
|
|
|
#include "winerror.h"
|
|
|
|
#include "objbase.h"
|
|
|
|
|
|
|
|
#include "pidl.h"
|
|
|
|
#include "shlobj.h"
|
|
|
|
#include "shldisp.h"
|
|
|
|
#include "debughlp.h"
|
2009-12-23 17:59:33 +01:00
|
|
|
#include "shell32_main.h"
|
2004-04-19 21:26:57 +02:00
|
|
|
|
2004-04-26 22:06:24 +02:00
|
|
|
#include "wine/unicode.h"
|
|
|
|
|
2004-04-19 21:26:57 +02:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(shell);
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
{
|
2011-05-30 13:57:12 +02:00
|
|
|
IAutoComplete2 IAutoComplete2_iface;
|
|
|
|
IAutoCompleteDropDown IAutoCompleteDropDown_iface;
|
2005-07-03 14:03:35 +02:00
|
|
|
LONG ref;
|
2011-02-01 11:16:20 +01:00
|
|
|
BOOL initialized;
|
|
|
|
BOOL enabled;
|
2004-04-26 22:06:24 +02:00
|
|
|
HWND hwndEdit;
|
|
|
|
HWND hwndListBox;
|
|
|
|
WNDPROC wpOrigEditProc;
|
|
|
|
WNDPROC wpOrigLBoxProc;
|
|
|
|
WCHAR *txtbackup;
|
2004-04-30 06:14:33 +02:00
|
|
|
WCHAR *quickComplete;
|
2004-04-26 22:06:24 +02:00
|
|
|
IEnumString *enumstr;
|
2004-04-19 21:26:57 +02:00
|
|
|
AUTOCOMPLETEOPTIONS options;
|
|
|
|
} IAutoCompleteImpl;
|
|
|
|
|
2018-09-17 21:23:10 +02:00
|
|
|
enum autoappend_flag
|
|
|
|
{
|
|
|
|
autoappend_flag_yes,
|
|
|
|
autoappend_flag_no,
|
|
|
|
autoappend_flag_displayempty
|
|
|
|
};
|
|
|
|
|
2011-02-01 11:16:30 +01:00
|
|
|
static const WCHAR autocomplete_propertyW[] = {'W','i','n','e',' ','A','u','t','o',
|
|
|
|
'c','o','m','p','l','e','t','e',' ',
|
|
|
|
'c','o','n','t','r','o','l',0};
|
2011-05-30 13:57:12 +02:00
|
|
|
|
|
|
|
static inline IAutoCompleteImpl *impl_from_IAutoComplete2(IAutoComplete2 *iface)
|
|
|
|
{
|
|
|
|
return CONTAINING_RECORD(iface, IAutoCompleteImpl, IAutoComplete2_iface);
|
|
|
|
}
|
2008-09-17 21:42:36 +02:00
|
|
|
|
|
|
|
static inline IAutoCompleteImpl *impl_from_IAutoCompleteDropDown(IAutoCompleteDropDown *iface)
|
|
|
|
{
|
2011-05-30 13:57:12 +02:00
|
|
|
return CONTAINING_RECORD(iface, IAutoCompleteImpl, IAutoCompleteDropDown_iface);
|
2008-09-17 21:42:36 +02:00
|
|
|
}
|
2004-04-19 21:26:57 +02:00
|
|
|
|
2018-09-22 16:53:43 +02:00
|
|
|
static void set_text_and_selection(IAutoCompleteImpl *ac, HWND hwnd, WCHAR *text, WPARAM start, LPARAM end)
|
|
|
|
{
|
|
|
|
/* Send it directly to the edit control to match Windows behavior */
|
|
|
|
WNDPROC proc = ac->wpOrigEditProc;
|
|
|
|
if (CallWindowProcW(proc, hwnd, WM_SETTEXT, 0, (LPARAM)text))
|
|
|
|
CallWindowProcW(proc, hwnd, EM_SETSEL, start, end);
|
|
|
|
}
|
|
|
|
|
2018-09-10 21:09:31 +02:00
|
|
|
static size_t format_quick_complete(WCHAR *dst, const WCHAR *qc, const WCHAR *str, size_t str_len)
|
|
|
|
{
|
|
|
|
/* Replace the first %s directly without using snprintf, to avoid
|
|
|
|
exploits since the format string can be retrieved from the registry */
|
|
|
|
WCHAR *base = dst;
|
|
|
|
UINT args = 0;
|
|
|
|
while (*qc != '\0')
|
|
|
|
{
|
|
|
|
if (qc[0] == '%')
|
|
|
|
{
|
|
|
|
if (args < 1 && qc[1] == 's')
|
|
|
|
{
|
|
|
|
memcpy(dst, str, str_len * sizeof(WCHAR));
|
|
|
|
dst += str_len;
|
|
|
|
qc += 2;
|
|
|
|
args++;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
qc += (qc[1] == '%');
|
|
|
|
}
|
|
|
|
*dst++ = *qc++;
|
|
|
|
}
|
|
|
|
*dst = '\0';
|
|
|
|
return dst - base;
|
|
|
|
}
|
|
|
|
|
2018-09-18 22:59:53 +02:00
|
|
|
static void autoappend_str(IAutoCompleteImpl *ac, WCHAR *text, UINT len, WCHAR *str, HWND hwnd)
|
|
|
|
{
|
|
|
|
WCHAR *tmp;
|
|
|
|
size_t size;
|
|
|
|
|
|
|
|
/* The character capitalization can be different,
|
|
|
|
so merge text and str into a new string */
|
|
|
|
size = len + strlenW(&str[len]) + 1;
|
|
|
|
|
|
|
|
if ((tmp = heap_alloc(size * sizeof(*tmp))))
|
|
|
|
{
|
|
|
|
memcpy(tmp, text, len * sizeof(*tmp));
|
|
|
|
memcpy(&tmp[len], &str[len], (size - len) * sizeof(*tmp));
|
|
|
|
}
|
|
|
|
else tmp = str;
|
|
|
|
|
2018-09-22 16:53:43 +02:00
|
|
|
set_text_and_selection(ac, hwnd, tmp, len, size - 1);
|
2018-09-18 22:59:53 +02:00
|
|
|
if (tmp != str)
|
|
|
|
heap_free(tmp);
|
|
|
|
}
|
|
|
|
|
2018-09-17 21:23:10 +02:00
|
|
|
static void autocomplete_text(IAutoCompleteImpl *ac, HWND hwnd, enum autoappend_flag flag)
|
2018-09-17 21:23:09 +02:00
|
|
|
{
|
|
|
|
HRESULT hr;
|
2018-09-17 21:23:10 +02:00
|
|
|
WCHAR *text;
|
|
|
|
UINT cpt, size, len = SendMessageW(hwnd, WM_GETTEXTLENGTH, 0, 0);
|
|
|
|
|
|
|
|
if (flag != autoappend_flag_displayempty && len == 0)
|
|
|
|
{
|
|
|
|
if (ac->options & ACO_AUTOSUGGEST)
|
|
|
|
ShowWindow(ac->hwndListBox, SW_HIDE);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
size = len + 1;
|
|
|
|
if (!(text = heap_alloc(size * sizeof(WCHAR))))
|
|
|
|
return;
|
|
|
|
len = SendMessageW(hwnd, WM_GETTEXT, size, (LPARAM)text);
|
|
|
|
if (len + 1 != size)
|
|
|
|
text = heap_realloc(text, (len + 1) * sizeof(WCHAR));
|
2018-09-17 21:23:09 +02:00
|
|
|
|
|
|
|
SendMessageW(ac->hwndListBox, LB_RESETCONTENT, 0, 0);
|
|
|
|
|
|
|
|
/* Set txtbackup to point to text itself (which must not be released) */
|
|
|
|
heap_free(ac->txtbackup);
|
|
|
|
ac->txtbackup = text;
|
|
|
|
|
|
|
|
IEnumString_Reset(ac->enumstr);
|
|
|
|
for (cpt = 0;;)
|
|
|
|
{
|
|
|
|
LPOLESTR strs = NULL;
|
|
|
|
ULONG fetched;
|
|
|
|
|
|
|
|
hr = IEnumString_Next(ac->enumstr, 1, &strs, &fetched);
|
|
|
|
if (hr != S_OK)
|
|
|
|
break;
|
|
|
|
|
|
|
|
if (!strncmpiW(text, strs, len))
|
|
|
|
{
|
2018-09-17 21:23:10 +02:00
|
|
|
if (cpt == 0 && flag == autoappend_flag_yes)
|
2018-09-17 21:23:09 +02:00
|
|
|
{
|
2018-09-18 22:59:53 +02:00
|
|
|
autoappend_str(ac, text, len, strs, hwnd);
|
2018-09-17 21:23:09 +02:00
|
|
|
if (!(ac->options & ACO_AUTOSUGGEST))
|
|
|
|
{
|
|
|
|
CoTaskMemFree(strs);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ac->options & ACO_AUTOSUGGEST)
|
|
|
|
SendMessageW(ac->hwndListBox, LB_ADDSTRING, 0, (LPARAM)strs);
|
|
|
|
|
|
|
|
cpt++;
|
|
|
|
}
|
|
|
|
|
|
|
|
CoTaskMemFree(strs);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ac->options & ACO_AUTOSUGGEST)
|
|
|
|
{
|
|
|
|
if (cpt)
|
|
|
|
{
|
|
|
|
RECT r;
|
|
|
|
UINT height = SendMessageW(ac->hwndListBox, LB_GETITEMHEIGHT, 0, 0);
|
|
|
|
SendMessageW(ac->hwndListBox, LB_CARETOFF, 0, 0);
|
|
|
|
GetWindowRect(hwnd, &r);
|
|
|
|
SetParent(ac->hwndListBox, HWND_DESKTOP);
|
|
|
|
/* It seems that Windows XP displays 7 lines at most
|
|
|
|
and otherwise displays a vertical scroll bar */
|
|
|
|
SetWindowPos(ac->hwndListBox, HWND_TOP,
|
2018-09-18 22:59:54 +02:00
|
|
|
r.left, r.bottom + 1, r.right - r.left, height * min(cpt + 1, 7),
|
2018-09-17 21:23:09 +02:00
|
|
|
SWP_SHOWWINDOW );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
ShowWindow(ac->hwndListBox, SW_HIDE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-08-27 19:10:46 +02:00
|
|
|
static void destroy_autocomplete_object(IAutoCompleteImpl *ac)
|
|
|
|
{
|
|
|
|
ac->hwndEdit = NULL;
|
|
|
|
if (ac->hwndListBox)
|
|
|
|
DestroyWindow(ac->hwndListBox);
|
|
|
|
IAutoComplete2_Release(&ac->IAutoComplete2_iface);
|
|
|
|
}
|
|
|
|
|
2018-09-17 21:23:09 +02:00
|
|
|
/*
|
|
|
|
Helper for ACEditSubclassProc
|
|
|
|
*/
|
2018-09-17 21:23:10 +02:00
|
|
|
static LRESULT ACEditSubclassProc_KeyDown(IAutoCompleteImpl *ac, HWND hwnd, UINT uMsg,
|
|
|
|
WPARAM wParam, LPARAM lParam)
|
2018-09-17 21:23:09 +02:00
|
|
|
{
|
|
|
|
switch (wParam)
|
|
|
|
{
|
|
|
|
case VK_RETURN:
|
|
|
|
/* If quickComplete is set and control is pressed, replace the string */
|
|
|
|
if (ac->quickComplete && (GetKeyState(VK_CONTROL) & 0x8000))
|
|
|
|
{
|
2018-09-17 21:23:10 +02:00
|
|
|
WCHAR *text, *buf;
|
|
|
|
size_t sz;
|
|
|
|
UINT len = SendMessageW(hwnd, WM_GETTEXTLENGTH, 0, 0);
|
|
|
|
if (!(text = heap_alloc((len + 1) * sizeof(WCHAR))))
|
|
|
|
return 0;
|
|
|
|
len = SendMessageW(hwnd, WM_GETTEXT, len + 1, (LPARAM)text);
|
|
|
|
sz = strlenW(ac->quickComplete) + 1 + len;
|
|
|
|
|
2018-09-17 21:23:09 +02:00
|
|
|
if ((buf = heap_alloc(sz * sizeof(WCHAR))))
|
|
|
|
{
|
|
|
|
len = format_quick_complete(buf, ac->quickComplete, text, len);
|
2018-09-22 16:53:43 +02:00
|
|
|
set_text_and_selection(ac, hwnd, buf, 0, len);
|
2018-09-17 21:23:09 +02:00
|
|
|
heap_free(buf);
|
|
|
|
}
|
2018-09-17 21:23:10 +02:00
|
|
|
|
|
|
|
if (ac->options & ACO_AUTOSUGGEST)
|
|
|
|
ShowWindow(ac->hwndListBox, SW_HIDE);
|
|
|
|
heap_free(text);
|
|
|
|
return 0;
|
2018-09-17 21:23:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (ac->options & ACO_AUTOSUGGEST)
|
|
|
|
ShowWindow(ac->hwndListBox, SW_HIDE);
|
2018-09-17 21:23:10 +02:00
|
|
|
break;
|
2018-09-17 21:23:09 +02:00
|
|
|
case VK_UP:
|
|
|
|
case VK_DOWN:
|
|
|
|
/* Two cases here:
|
|
|
|
- if the listbox is not visible and ACO_UPDOWNKEYDROPSLIST is
|
|
|
|
set, display it with all the entries, without selecting any
|
|
|
|
- if the listbox is visible, change the selection
|
|
|
|
*/
|
2018-09-17 21:23:10 +02:00
|
|
|
if (!(ac->options & ACO_AUTOSUGGEST))
|
|
|
|
break;
|
|
|
|
|
|
|
|
if (!IsWindowVisible(ac->hwndListBox))
|
2018-09-17 21:23:09 +02:00
|
|
|
{
|
2018-09-17 21:23:10 +02:00
|
|
|
if (ac->options & ACO_UPDOWNKEYDROPSLIST)
|
|
|
|
{
|
|
|
|
autocomplete_text(ac, hwnd, autoappend_flag_displayempty);
|
|
|
|
return 0;
|
|
|
|
}
|
2018-09-17 21:23:09 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
INT count, sel;
|
|
|
|
count = SendMessageW(ac->hwndListBox, LB_GETCOUNT, 0, 0);
|
|
|
|
|
|
|
|
/* Change the selection */
|
|
|
|
sel = SendMessageW(ac->hwndListBox, LB_GETCURSEL, 0, 0);
|
|
|
|
if (wParam == VK_UP)
|
2018-09-20 13:55:34 +02:00
|
|
|
sel = ((sel - 1) < -1) ? count - 1 : sel - 1;
|
2018-09-17 21:23:09 +02:00
|
|
|
else
|
|
|
|
sel = ((sel + 1) >= count) ? -1 : sel + 1;
|
|
|
|
SendMessageW(ac->hwndListBox, LB_SETCURSEL, sel, 0);
|
|
|
|
if (sel >= 0)
|
|
|
|
{
|
|
|
|
WCHAR *msg;
|
|
|
|
UINT len;
|
|
|
|
|
|
|
|
len = SendMessageW(ac->hwndListBox, LB_GETTEXTLEN, sel, 0);
|
|
|
|
if (!(msg = heap_alloc((len + 1) * sizeof(WCHAR))))
|
|
|
|
return 0;
|
|
|
|
len = SendMessageW(ac->hwndListBox, LB_GETTEXT, sel, (LPARAM)msg);
|
2018-09-22 16:53:43 +02:00
|
|
|
set_text_and_selection(ac, hwnd, msg, len, len);
|
2018-09-17 21:23:09 +02:00
|
|
|
heap_free(msg);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2018-09-22 16:53:43 +02:00
|
|
|
UINT len = strlenW(ac->txtbackup);
|
|
|
|
set_text_and_selection(ac, hwnd, ac->txtbackup, len, len);
|
2018-09-17 21:23:09 +02:00
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case VK_DELETE:
|
2018-09-17 21:23:10 +02:00
|
|
|
{
|
|
|
|
LRESULT ret = CallWindowProcW(ac->wpOrigEditProc, hwnd, uMsg, wParam, lParam);
|
|
|
|
autocomplete_text(ac, hwnd, autoappend_flag_no);
|
|
|
|
return ret;
|
|
|
|
}
|
2018-09-17 21:23:09 +02:00
|
|
|
}
|
2018-09-17 21:23:10 +02:00
|
|
|
return CallWindowProcW(ac->wpOrigEditProc, hwnd, uMsg, wParam, lParam);
|
2018-09-17 21:23:09 +02:00
|
|
|
}
|
|
|
|
|
2012-01-11 22:25:31 +01:00
|
|
|
/*
|
|
|
|
Window procedure for autocompletion
|
|
|
|
*/
|
|
|
|
static LRESULT APIENTRY ACEditSubclassProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
|
|
|
{
|
|
|
|
IAutoCompleteImpl *This = GetPropW(hwnd, autocomplete_propertyW);
|
2018-09-17 21:23:10 +02:00
|
|
|
LRESULT ret;
|
2012-01-11 22:25:31 +01:00
|
|
|
|
|
|
|
if (!This->enabled) return CallWindowProcW(This->wpOrigEditProc, hwnd, uMsg, wParam, lParam);
|
|
|
|
|
|
|
|
switch (uMsg)
|
|
|
|
{
|
|
|
|
case CB_SHOWDROPDOWN:
|
2018-09-10 21:09:34 +02:00
|
|
|
if (This->options & ACO_AUTOSUGGEST)
|
|
|
|
ShowWindow(This->hwndListBox, SW_HIDE);
|
2018-09-20 13:55:36 +02:00
|
|
|
return 0;
|
2012-01-11 22:25:31 +01:00
|
|
|
case WM_KILLFOCUS:
|
|
|
|
if ((This->options & ACO_AUTOSUGGEST) && ((HWND)wParam != This->hwndListBox))
|
|
|
|
{
|
|
|
|
ShowWindow(This->hwndListBox, SW_HIDE);
|
|
|
|
}
|
2018-09-20 13:55:36 +02:00
|
|
|
break;
|
2018-09-17 21:23:10 +02:00
|
|
|
case WM_KEYDOWN:
|
|
|
|
return ACEditSubclassProc_KeyDown(This, hwnd, uMsg, wParam, lParam);
|
|
|
|
case WM_CHAR:
|
|
|
|
case WM_UNICHAR:
|
2018-09-22 16:53:42 +02:00
|
|
|
/* Don't autocomplete at all on most control characters */
|
|
|
|
if (iscntrlW(wParam) && !(wParam >= '\b' && wParam <= '\r'))
|
|
|
|
break;
|
|
|
|
|
2018-09-17 21:23:10 +02:00
|
|
|
ret = CallWindowProcW(This->wpOrigEditProc, hwnd, uMsg, wParam, lParam);
|
2018-09-18 22:59:52 +02:00
|
|
|
autocomplete_text(This, hwnd, (This->options & ACO_AUTOAPPEND) && wParam >= ' '
|
2018-09-17 21:23:10 +02:00
|
|
|
? autoappend_flag_yes : autoappend_flag_no);
|
|
|
|
return ret;
|
2018-09-22 16:53:44 +02:00
|
|
|
case WM_SETTEXT:
|
2018-09-20 13:55:35 +02:00
|
|
|
case WM_CUT:
|
|
|
|
case WM_CLEAR:
|
|
|
|
case WM_UNDO:
|
|
|
|
ret = CallWindowProcW(This->wpOrigEditProc, hwnd, uMsg, wParam, lParam);
|
|
|
|
autocomplete_text(This, hwnd, autoappend_flag_no);
|
|
|
|
return ret;
|
|
|
|
case WM_PASTE:
|
|
|
|
ret = CallWindowProcW(This->wpOrigEditProc, hwnd, uMsg, wParam, lParam);
|
|
|
|
autocomplete_text(This, hwnd, autoappend_flag_yes);
|
|
|
|
return ret;
|
2012-01-11 22:25:31 +01:00
|
|
|
case WM_DESTROY:
|
|
|
|
{
|
|
|
|
WNDPROC proc = This->wpOrigEditProc;
|
|
|
|
|
|
|
|
SetWindowLongPtrW(hwnd, GWLP_WNDPROC, (LONG_PTR)proc);
|
2018-09-18 22:59:55 +02:00
|
|
|
RemovePropW(hwnd, autocomplete_propertyW);
|
2018-08-27 19:10:46 +02:00
|
|
|
destroy_autocomplete_object(This);
|
2012-01-11 22:25:31 +01:00
|
|
|
return CallWindowProcW(proc, hwnd, uMsg, wParam, lParam);
|
|
|
|
}
|
|
|
|
}
|
2018-09-20 13:55:36 +02:00
|
|
|
return CallWindowProcW(This->wpOrigEditProc, hwnd, uMsg, wParam, lParam);
|
2012-01-11 22:25:31 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static LRESULT APIENTRY ACLBoxSubclassProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
|
|
|
|
{
|
|
|
|
IAutoCompleteImpl *This = (IAutoCompleteImpl *)GetWindowLongPtrW(hwnd, GWLP_USERDATA);
|
|
|
|
WCHAR *msg;
|
|
|
|
int sel, len;
|
|
|
|
|
|
|
|
switch (uMsg) {
|
|
|
|
case WM_MOUSEMOVE:
|
|
|
|
sel = SendMessageW(hwnd, LB_ITEMFROMPOINT, 0, lParam);
|
|
|
|
SendMessageW(hwnd, LB_SETCURSEL, sel, 0);
|
|
|
|
break;
|
|
|
|
case WM_LBUTTONDOWN:
|
|
|
|
sel = SendMessageW(hwnd, LB_GETCURSEL, 0, 0);
|
|
|
|
if (sel < 0)
|
|
|
|
break;
|
2018-09-22 16:53:45 +02:00
|
|
|
len = SendMessageW(hwnd, LB_GETTEXTLEN, sel, 0);
|
2018-09-10 21:09:32 +02:00
|
|
|
if (!(msg = heap_alloc((len + 1) * sizeof(WCHAR))))
|
|
|
|
break;
|
2018-09-10 21:09:33 +02:00
|
|
|
len = SendMessageW(hwnd, LB_GETTEXT, sel, (LPARAM)msg);
|
2018-09-22 16:53:43 +02:00
|
|
|
set_text_and_selection(This, This->hwndEdit, msg, 0, len);
|
2012-01-11 22:25:31 +01:00
|
|
|
ShowWindow(hwnd, SW_HIDE);
|
2018-02-22 08:43:28 +01:00
|
|
|
heap_free(msg);
|
2012-01-11 22:25:31 +01:00
|
|
|
break;
|
|
|
|
default:
|
|
|
|
return CallWindowProcW(This->wpOrigLBoxProc, hwnd, uMsg, wParam, lParam);
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
2004-04-26 22:06:24 +02:00
|
|
|
|
2008-09-17 21:42:41 +02:00
|
|
|
static void create_listbox(IAutoCompleteImpl *This)
|
|
|
|
{
|
|
|
|
HWND hwndParent;
|
|
|
|
|
|
|
|
hwndParent = GetParent(This->hwndEdit);
|
|
|
|
|
|
|
|
/* FIXME : The listbox should be resizable with the mouse. WS_THICKFRAME looks ugly */
|
|
|
|
This->hwndListBox = CreateWindowExW(0, WC_LISTBOXW, NULL,
|
|
|
|
WS_BORDER | WS_CHILD | WS_VSCROLL | LBS_HASSTRINGS | LBS_NOTIFY | LBS_NOINTEGRALHEIGHT,
|
|
|
|
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
|
2009-12-23 17:59:33 +01:00
|
|
|
hwndParent, NULL, shell32_hInstance, NULL );
|
2008-09-17 21:42:41 +02:00
|
|
|
|
|
|
|
if (This->hwndListBox) {
|
|
|
|
This->wpOrigLBoxProc = (WNDPROC) SetWindowLongPtrW( This->hwndListBox, GWLP_WNDPROC, (LONG_PTR) ACLBoxSubclassProc);
|
|
|
|
SetWindowLongPtrW( This->hwndListBox, GWLP_USERDATA, (LONG_PTR)This);
|
|
|
|
}
|
2018-09-10 21:09:34 +02:00
|
|
|
else
|
|
|
|
This->options &= ~ACO_AUTOSUGGEST;
|
2008-09-17 21:42:41 +02:00
|
|
|
}
|
|
|
|
|
2004-04-19 21:26:57 +02:00
|
|
|
/**************************************************************************
|
|
|
|
* AutoComplete_QueryInterface
|
|
|
|
*/
|
2008-07-29 17:23:09 +02:00
|
|
|
static HRESULT WINAPI IAutoComplete2_fnQueryInterface(
|
|
|
|
IAutoComplete2 * iface,
|
2004-04-19 21:26:57 +02:00
|
|
|
REFIID riid,
|
|
|
|
LPVOID *ppvObj)
|
|
|
|
{
|
2011-05-30 13:57:12 +02:00
|
|
|
IAutoCompleteImpl *This = impl_from_IAutoComplete2(iface);
|
|
|
|
|
2009-05-21 17:17:26 +02:00
|
|
|
TRACE("(%p)->(IID:%s,%p)\n", This, shdebugstr_guid(riid), ppvObj);
|
2004-04-19 21:26:57 +02:00
|
|
|
*ppvObj = NULL;
|
|
|
|
|
2008-07-29 17:23:09 +02:00
|
|
|
if (IsEqualIID(riid, &IID_IUnknown) ||
|
|
|
|
IsEqualIID(riid, &IID_IAutoComplete) ||
|
|
|
|
IsEqualIID(riid, &IID_IAutoComplete2))
|
2004-04-19 21:26:57 +02:00
|
|
|
{
|
2013-09-03 15:09:07 +02:00
|
|
|
*ppvObj = &This->IAutoComplete2_iface;
|
2004-04-19 21:26:57 +02:00
|
|
|
}
|
2008-09-17 21:42:36 +02:00
|
|
|
else if (IsEqualIID(riid, &IID_IAutoCompleteDropDown))
|
|
|
|
{
|
2011-05-30 13:57:12 +02:00
|
|
|
*ppvObj = &This->IAutoCompleteDropDown_iface;
|
2008-09-17 21:42:36 +02:00
|
|
|
}
|
2004-04-19 21:26:57 +02:00
|
|
|
|
|
|
|
if (*ppvObj)
|
|
|
|
{
|
2008-07-29 17:23:09 +02:00
|
|
|
IUnknown_AddRef((IUnknown*)*ppvObj);
|
2004-04-19 21:26:57 +02:00
|
|
|
TRACE("-- Interface: (%p)->(%p)\n", ppvObj, *ppvObj);
|
|
|
|
return S_OK;
|
|
|
|
}
|
2008-09-17 21:42:36 +02:00
|
|
|
WARN("unsupported interface: %s\n", debugstr_guid(riid));
|
2012-01-11 22:25:31 +01:00
|
|
|
return E_NOINTERFACE;
|
2004-04-19 21:26:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
2008-07-29 17:23:09 +02:00
|
|
|
* IAutoComplete2_fnAddRef
|
2004-04-19 21:26:57 +02:00
|
|
|
*/
|
2008-07-29 17:23:09 +02:00
|
|
|
static ULONG WINAPI IAutoComplete2_fnAddRef(
|
|
|
|
IAutoComplete2 * iface)
|
2004-04-19 21:26:57 +02:00
|
|
|
{
|
2011-05-30 13:57:12 +02:00
|
|
|
IAutoCompleteImpl *This = impl_from_IAutoComplete2(iface);
|
2005-01-14 17:02:20 +01:00
|
|
|
ULONG refCount = InterlockedIncrement(&This->ref);
|
2011-05-30 13:57:12 +02:00
|
|
|
|
2006-10-07 20:18:14 +02:00
|
|
|
TRACE("(%p)->(%u)\n", This, refCount - 1);
|
2005-01-14 17:02:20 +01:00
|
|
|
|
|
|
|
return refCount;
|
2004-04-19 21:26:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
2008-07-29 17:23:09 +02:00
|
|
|
* IAutoComplete2_fnRelease
|
2004-04-19 21:26:57 +02:00
|
|
|
*/
|
2008-07-29 17:23:09 +02:00
|
|
|
static ULONG WINAPI IAutoComplete2_fnRelease(
|
|
|
|
IAutoComplete2 * iface)
|
2004-04-19 21:26:57 +02:00
|
|
|
{
|
2011-05-30 13:57:12 +02:00
|
|
|
IAutoCompleteImpl *This = impl_from_IAutoComplete2(iface);
|
2005-01-14 17:02:20 +01:00
|
|
|
ULONG refCount = InterlockedDecrement(&This->ref);
|
2011-02-01 11:16:38 +01:00
|
|
|
|
2006-10-07 20:18:14 +02:00
|
|
|
TRACE("(%p)->(%u)\n", This, refCount + 1);
|
2004-04-19 21:26:57 +02:00
|
|
|
|
2005-01-14 17:02:20 +01:00
|
|
|
if (!refCount) {
|
2011-02-01 11:16:38 +01:00
|
|
|
TRACE("destroying IAutoComplete(%p)\n", This);
|
2018-02-22 08:43:28 +01:00
|
|
|
heap_free(This->quickComplete);
|
|
|
|
heap_free(This->txtbackup);
|
2011-02-01 11:16:38 +01:00
|
|
|
if (This->enumstr)
|
|
|
|
IEnumString_Release(This->enumstr);
|
2018-02-22 08:43:28 +01:00
|
|
|
heap_free(This);
|
2004-04-19 21:26:57 +02:00
|
|
|
}
|
2005-01-14 17:02:20 +01:00
|
|
|
return refCount;
|
2004-04-19 21:26:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
2008-07-29 17:23:09 +02:00
|
|
|
* IAutoComplete2_fnEnable
|
2004-04-19 21:26:57 +02:00
|
|
|
*/
|
2008-07-29 17:23:09 +02:00
|
|
|
static HRESULT WINAPI IAutoComplete2_fnEnable(
|
|
|
|
IAutoComplete2 * iface,
|
2004-04-19 21:26:57 +02:00
|
|
|
BOOL fEnable)
|
|
|
|
{
|
2011-05-30 13:57:12 +02:00
|
|
|
IAutoCompleteImpl *This = impl_from_IAutoComplete2(iface);
|
2004-04-19 21:26:57 +02:00
|
|
|
HRESULT hr = S_OK;
|
|
|
|
|
|
|
|
TRACE("(%p)->(%s)\n", This, (fEnable)?"true":"false");
|
|
|
|
|
2004-04-30 06:14:33 +02:00
|
|
|
This->enabled = fEnable;
|
2004-04-19 21:26:57 +02:00
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
/******************************************************************************
|
2008-07-29 17:23:09 +02:00
|
|
|
* IAutoComplete2_fnInit
|
2004-04-19 21:26:57 +02:00
|
|
|
*/
|
2008-07-29 17:23:09 +02:00
|
|
|
static HRESULT WINAPI IAutoComplete2_fnInit(
|
|
|
|
IAutoComplete2 * iface,
|
2004-04-19 21:26:57 +02:00
|
|
|
HWND hwndEdit,
|
|
|
|
IUnknown *punkACL,
|
|
|
|
LPCOLESTR pwzsRegKeyPath,
|
|
|
|
LPCOLESTR pwszQuickComplete)
|
|
|
|
{
|
2018-08-27 19:10:46 +02:00
|
|
|
IAutoCompleteImpl *prev, *This = impl_from_IAutoComplete2(iface);
|
2004-04-19 21:26:57 +02:00
|
|
|
|
2011-02-01 11:16:20 +01:00
|
|
|
TRACE("(%p)->(%p, %p, %s, %s)\n",
|
|
|
|
This, hwndEdit, punkACL, debugstr_w(pwzsRegKeyPath), debugstr_w(pwszQuickComplete));
|
2004-04-19 21:26:57 +02:00
|
|
|
|
2004-04-26 22:06:24 +02:00
|
|
|
if (This->options & ACO_SEARCH) FIXME(" ACO_SEARCH not supported\n");
|
|
|
|
if (This->options & ACO_FILTERPREFIXES) FIXME(" ACO_FILTERPREFIXES not supported\n");
|
|
|
|
if (This->options & ACO_USETAB) FIXME(" ACO_USETAB not supported\n");
|
|
|
|
if (This->options & ACO_RTLREADING) FIXME(" ACO_RTLREADING not supported\n");
|
|
|
|
|
2011-02-01 11:16:20 +01:00
|
|
|
if (!hwndEdit || !punkACL)
|
|
|
|
return E_INVALIDARG;
|
|
|
|
|
|
|
|
if (This->initialized)
|
|
|
|
{
|
|
|
|
WARN("Autocompletion object is already initialized\n");
|
|
|
|
/* This->hwndEdit is set to NULL when the edit window is destroyed. */
|
|
|
|
return This->hwndEdit ? E_FAIL : E_UNEXPECTED;
|
|
|
|
}
|
2004-04-26 22:06:24 +02:00
|
|
|
|
2008-10-08 01:32:38 +02:00
|
|
|
if (FAILED (IUnknown_QueryInterface (punkACL, &IID_IEnumString, (LPVOID*)&This->enumstr))) {
|
2011-02-01 11:16:20 +01:00
|
|
|
WARN("No IEnumString interface\n");
|
|
|
|
return E_NOINTERFACE;
|
2004-04-26 22:06:24 +02:00
|
|
|
}
|
|
|
|
|
2011-02-01 11:16:20 +01:00
|
|
|
This->initialized = TRUE;
|
|
|
|
This->hwndEdit = hwndEdit;
|
2018-08-27 19:10:46 +02:00
|
|
|
|
|
|
|
/* If another AutoComplete object was previously assigned to this edit control,
|
|
|
|
release it but keep the same callback on the control, to avoid an infinite
|
|
|
|
recursive loop in ACEditSubclassProc while the property is set to this object */
|
|
|
|
prev = GetPropW(hwndEdit, autocomplete_propertyW);
|
|
|
|
SetPropW(hwndEdit, autocomplete_propertyW, This);
|
|
|
|
|
|
|
|
if (prev && prev->initialized) {
|
|
|
|
This->wpOrigEditProc = prev->wpOrigEditProc;
|
|
|
|
destroy_autocomplete_object(prev);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
This->wpOrigEditProc = (WNDPROC) SetWindowLongPtrW(hwndEdit, GWLP_WNDPROC, (LONG_PTR) ACEditSubclassProc);
|
|
|
|
|
|
|
|
/* Keep at least one reference to the object until the edit window is destroyed */
|
2011-05-30 13:57:12 +02:00
|
|
|
IAutoComplete2_AddRef(&This->IAutoComplete2_iface);
|
2004-04-26 22:06:24 +02:00
|
|
|
|
2008-09-17 21:42:41 +02:00
|
|
|
if (This->options & ACO_AUTOSUGGEST)
|
|
|
|
create_listbox(This);
|
2004-04-26 22:06:24 +02:00
|
|
|
|
2018-09-06 20:26:11 +02:00
|
|
|
if (pwzsRegKeyPath)
|
|
|
|
{
|
|
|
|
static const HKEY roots[] = { HKEY_CURRENT_USER, HKEY_LOCAL_MACHINE };
|
|
|
|
WCHAR *key, *value;
|
|
|
|
DWORD type, sz;
|
|
|
|
BYTE *qc;
|
|
|
|
HKEY hKey;
|
|
|
|
LSTATUS res;
|
|
|
|
size_t len;
|
|
|
|
UINT i;
|
|
|
|
|
|
|
|
/* pwszRegKeyPath contains the key as well as the value, so split it */
|
|
|
|
value = strrchrW(pwzsRegKeyPath, '\\');
|
|
|
|
len = value - pwzsRegKeyPath;
|
|
|
|
|
|
|
|
if (value && (key = heap_alloc((len+1) * sizeof(*key))) != NULL)
|
|
|
|
{
|
|
|
|
memcpy(key, pwzsRegKeyPath, len * sizeof(*key));
|
|
|
|
key[len] = '\0';
|
|
|
|
value++;
|
|
|
|
|
|
|
|
for (i = 0; i < ARRAY_SIZE(roots); i++)
|
|
|
|
{
|
|
|
|
if (RegOpenKeyExW(roots[i], key, 0, KEY_READ, &hKey) != ERROR_SUCCESS)
|
|
|
|
continue;
|
|
|
|
sz = MAX_PATH * sizeof(WCHAR);
|
|
|
|
|
|
|
|
while ((qc = heap_alloc(sz)) != NULL)
|
|
|
|
{
|
|
|
|
res = RegQueryValueExW(hKey, value, NULL, &type, qc, &sz);
|
|
|
|
if (res == ERROR_SUCCESS && type == REG_SZ)
|
|
|
|
{
|
|
|
|
This->quickComplete = heap_realloc(qc, sz);
|
|
|
|
i = ARRAY_SIZE(roots);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
heap_free(qc);
|
|
|
|
if (res != ERROR_MORE_DATA || type != REG_SZ)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
RegCloseKey(hKey);
|
|
|
|
}
|
|
|
|
heap_free(key);
|
|
|
|
}
|
2004-04-30 06:14:33 +02:00
|
|
|
}
|
|
|
|
|
2018-09-06 20:26:11 +02:00
|
|
|
if (!This->quickComplete && pwszQuickComplete)
|
|
|
|
{
|
|
|
|
size_t len = strlenW(pwszQuickComplete)+1;
|
|
|
|
if ((This->quickComplete = heap_alloc(len * sizeof(WCHAR))) != NULL)
|
|
|
|
memcpy(This->quickComplete, pwszQuickComplete, len * sizeof(WCHAR));
|
2004-04-30 06:14:33 +02:00
|
|
|
}
|
2004-04-26 22:06:24 +02:00
|
|
|
|
|
|
|
return S_OK;
|
2004-04-19 21:26:57 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************
|
2008-07-29 17:23:09 +02:00
|
|
|
* IAutoComplete2_fnGetOptions
|
2004-04-19 21:26:57 +02:00
|
|
|
*/
|
|
|
|
static HRESULT WINAPI IAutoComplete2_fnGetOptions(
|
|
|
|
IAutoComplete2 * iface,
|
|
|
|
DWORD *pdwFlag)
|
|
|
|
{
|
2011-05-30 13:57:12 +02:00
|
|
|
IAutoCompleteImpl *This = impl_from_IAutoComplete2(iface);
|
2004-04-19 21:26:57 +02:00
|
|
|
HRESULT hr = S_OK;
|
2004-04-30 06:14:33 +02:00
|
|
|
|
2004-04-19 21:26:57 +02:00
|
|
|
TRACE("(%p) -> (%p)\n", This, pdwFlag);
|
|
|
|
|
|
|
|
*pdwFlag = This->options;
|
|
|
|
|
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************
|
2008-07-29 17:23:09 +02:00
|
|
|
* IAutoComplete2_fnSetOptions
|
2004-04-19 21:26:57 +02:00
|
|
|
*/
|
|
|
|
static HRESULT WINAPI IAutoComplete2_fnSetOptions(
|
|
|
|
IAutoComplete2 * iface,
|
|
|
|
DWORD dwFlag)
|
|
|
|
{
|
2011-05-30 13:57:12 +02:00
|
|
|
IAutoCompleteImpl *This = impl_from_IAutoComplete2(iface);
|
2004-04-19 21:26:57 +02:00
|
|
|
HRESULT hr = S_OK;
|
|
|
|
|
2006-10-07 20:18:14 +02:00
|
|
|
TRACE("(%p) -> (0x%x)\n", This, dwFlag);
|
2004-04-26 22:06:24 +02:00
|
|
|
|
|
|
|
This->options = dwFlag;
|
2004-04-19 21:26:57 +02:00
|
|
|
|
2008-09-17 21:42:41 +02:00
|
|
|
if ((This->options & ACO_AUTOSUGGEST) && This->hwndEdit && !This->hwndListBox)
|
|
|
|
create_listbox(This);
|
|
|
|
|
2004-04-19 21:26:57 +02:00
|
|
|
return hr;
|
|
|
|
}
|
|
|
|
|
2012-01-11 22:25:31 +01:00
|
|
|
/**************************************************************************
|
|
|
|
* IAutoComplete2 VTable
|
|
|
|
*/
|
|
|
|
static const IAutoComplete2Vtbl acvt =
|
|
|
|
{
|
|
|
|
IAutoComplete2_fnQueryInterface,
|
|
|
|
IAutoComplete2_fnAddRef,
|
|
|
|
IAutoComplete2_fnRelease,
|
|
|
|
IAutoComplete2_fnInit,
|
|
|
|
IAutoComplete2_fnEnable,
|
|
|
|
/* IAutoComplete2 */
|
|
|
|
IAutoComplete2_fnSetOptions,
|
|
|
|
IAutoComplete2_fnGetOptions,
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
static HRESULT WINAPI IAutoCompleteDropDown_fnQueryInterface(IAutoCompleteDropDown *iface,
|
|
|
|
REFIID riid, LPVOID *ppvObj)
|
|
|
|
{
|
|
|
|
IAutoCompleteImpl *This = impl_from_IAutoCompleteDropDown(iface);
|
2013-09-03 15:09:07 +02:00
|
|
|
return IAutoComplete2_QueryInterface(&This->IAutoComplete2_iface, riid, ppvObj);
|
2012-01-11 22:25:31 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI IAutoCompleteDropDown_fnAddRef(IAutoCompleteDropDown *iface)
|
|
|
|
{
|
|
|
|
IAutoCompleteImpl *This = impl_from_IAutoCompleteDropDown(iface);
|
2013-09-03 15:09:07 +02:00
|
|
|
return IAutoComplete2_AddRef(&This->IAutoComplete2_iface);
|
2012-01-11 22:25:31 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
static ULONG WINAPI IAutoCompleteDropDown_fnRelease(IAutoCompleteDropDown *iface)
|
|
|
|
{
|
|
|
|
IAutoCompleteImpl *This = impl_from_IAutoCompleteDropDown(iface);
|
2013-09-03 15:09:07 +02:00
|
|
|
return IAutoComplete2_Release(&This->IAutoComplete2_iface);
|
2012-01-11 22:25:31 +01:00
|
|
|
}
|
|
|
|
|
2004-04-19 21:26:57 +02:00
|
|
|
/**************************************************************************
|
2008-09-17 21:42:36 +02:00
|
|
|
* IAutoCompleteDropDown_fnGetDropDownStatus
|
|
|
|
*/
|
|
|
|
static HRESULT WINAPI IAutoCompleteDropDown_fnGetDropDownStatus(
|
|
|
|
IAutoCompleteDropDown *iface,
|
|
|
|
DWORD *pdwFlags,
|
|
|
|
LPWSTR *ppwszString)
|
|
|
|
{
|
|
|
|
IAutoCompleteImpl *This = impl_from_IAutoCompleteDropDown(iface);
|
2008-09-17 21:42:46 +02:00
|
|
|
BOOL dropped;
|
2008-09-17 21:42:36 +02:00
|
|
|
|
2008-09-17 21:42:46 +02:00
|
|
|
TRACE("(%p) -> (%p, %p)\n", This, pdwFlags, ppwszString);
|
|
|
|
|
|
|
|
dropped = IsWindowVisible(This->hwndListBox);
|
2008-09-17 21:42:36 +02:00
|
|
|
|
|
|
|
if (pdwFlags)
|
2008-09-17 21:42:46 +02:00
|
|
|
*pdwFlags = (dropped ? ACDD_VISIBLE : 0);
|
|
|
|
|
|
|
|
if (ppwszString) {
|
|
|
|
if (dropped) {
|
|
|
|
int sel;
|
|
|
|
|
|
|
|
sel = SendMessageW(This->hwndListBox, LB_GETCURSEL, 0, 0);
|
|
|
|
if (sel >= 0)
|
|
|
|
{
|
|
|
|
DWORD len;
|
|
|
|
|
|
|
|
len = SendMessageW(This->hwndListBox, LB_GETTEXTLEN, sel, 0);
|
|
|
|
*ppwszString = CoTaskMemAlloc((len+1)*sizeof(WCHAR));
|
|
|
|
SendMessageW(This->hwndListBox, LB_GETTEXT, sel, (LPARAM)*ppwszString);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
*ppwszString = NULL;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
*ppwszString = NULL;
|
|
|
|
}
|
2008-09-17 21:42:36 +02:00
|
|
|
|
2008-09-17 21:42:46 +02:00
|
|
|
return S_OK;
|
2008-09-17 21:42:36 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
* IAutoCompleteDropDown_fnResetEnumarator
|
|
|
|
*/
|
|
|
|
static HRESULT WINAPI IAutoCompleteDropDown_fnResetEnumerator(
|
|
|
|
IAutoCompleteDropDown *iface)
|
|
|
|
{
|
|
|
|
IAutoCompleteImpl *This = impl_from_IAutoCompleteDropDown(iface);
|
|
|
|
|
|
|
|
FIXME("(%p): stub\n", This);
|
|
|
|
|
|
|
|
return E_NOTIMPL;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**************************************************************************
|
|
|
|
* IAutoCompleteDropDown VTable
|
|
|
|
*/
|
|
|
|
static const IAutoCompleteDropDownVtbl acdropdownvt =
|
|
|
|
{
|
|
|
|
IAutoCompleteDropDown_fnQueryInterface,
|
|
|
|
IAutoCompleteDropDown_fnAddRef,
|
|
|
|
IAutoCompleteDropDown_fnRelease,
|
|
|
|
IAutoCompleteDropDown_fnGetDropDownStatus,
|
|
|
|
IAutoCompleteDropDown_fnResetEnumerator,
|
|
|
|
};
|
|
|
|
|
2012-01-11 22:25:31 +01:00
|
|
|
/**************************************************************************
|
|
|
|
* IAutoComplete_Constructor
|
2004-04-26 22:06:24 +02:00
|
|
|
*/
|
2012-01-11 22:25:31 +01:00
|
|
|
HRESULT WINAPI IAutoComplete_Constructor(IUnknown * pUnkOuter, REFIID riid, LPVOID * ppv)
|
2004-04-26 22:06:24 +02:00
|
|
|
{
|
2012-01-11 22:25:31 +01:00
|
|
|
IAutoCompleteImpl *lpac;
|
2004-04-26 22:06:24 +02:00
|
|
|
HRESULT hr;
|
2011-07-24 20:42:25 +02:00
|
|
|
|
2012-01-11 22:25:31 +01:00
|
|
|
if (pUnkOuter && !IsEqualIID (riid, &IID_IUnknown))
|
|
|
|
return CLASS_E_NOAGGREGATION;
|
2004-04-26 22:06:24 +02:00
|
|
|
|
2018-02-22 08:43:28 +01:00
|
|
|
lpac = heap_alloc_zero(sizeof(*lpac));
|
2012-01-11 22:25:31 +01:00
|
|
|
if (!lpac)
|
|
|
|
return E_OUTOFMEMORY;
|
2008-09-17 21:42:41 +02:00
|
|
|
|
2012-01-11 22:25:31 +01:00
|
|
|
lpac->ref = 1;
|
|
|
|
lpac->IAutoComplete2_iface.lpVtbl = &acvt;
|
|
|
|
lpac->IAutoCompleteDropDown_iface.lpVtbl = &acdropdownvt;
|
|
|
|
lpac->enabled = TRUE;
|
|
|
|
lpac->options = ACO_AUTOAPPEND;
|
2004-04-26 22:06:24 +02:00
|
|
|
|
2012-01-11 22:25:31 +01:00
|
|
|
hr = IAutoComplete2_QueryInterface(&lpac->IAutoComplete2_iface, riid, ppv);
|
|
|
|
IAutoComplete2_Release(&lpac->IAutoComplete2_iface);
|
2004-04-26 22:06:24 +02:00
|
|
|
|
2012-01-11 22:25:31 +01:00
|
|
|
TRACE("-- (%p)->\n",lpac);
|
2004-04-26 22:06:24 +02:00
|
|
|
|
2012-01-11 22:25:31 +01:00
|
|
|
return hr;
|
2004-04-26 22:06:24 +02:00
|
|
|
}
|