shell32: Store the autocompletion object pointer in a window property rather than in the window user data.

This commit is contained in:
Andrew Nguyen 2011-02-01 04:16:30 -06:00 committed by Alexandre Julliard
parent 4dc304489f
commit 4145fe0ec2
2 changed files with 12 additions and 3 deletions

View File

@ -82,7 +82,9 @@ typedef struct
static const IAutoComplete2Vtbl acvt; static const IAutoComplete2Vtbl acvt;
static const IAutoCompleteDropDownVtbl acdropdownvt; static const IAutoCompleteDropDownVtbl acdropdownvt;
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};
/* /*
converts This to an interface pointer converts This to an interface pointer
*/ */
@ -273,7 +275,7 @@ static HRESULT WINAPI IAutoComplete2_fnInit(
This->initialized = TRUE; This->initialized = TRUE;
This->hwndEdit = hwndEdit; This->hwndEdit = hwndEdit;
This->wpOrigEditProc = (WNDPROC) SetWindowLongPtrW( hwndEdit, GWLP_WNDPROC, (LONG_PTR) ACEditSubclassProc); This->wpOrigEditProc = (WNDPROC) SetWindowLongPtrW( hwndEdit, GWLP_WNDPROC, (LONG_PTR) ACEditSubclassProc);
SetWindowLongPtrW( hwndEdit, GWLP_USERDATA, (LONG_PTR)This); SetPropW( hwndEdit, autocomplete_propertyW, This );
if (This->options & ACO_AUTOSUGGEST) if (This->options & ACO_AUTOSUGGEST)
create_listbox(This); create_listbox(This);
@ -464,7 +466,7 @@ static const IAutoCompleteDropDownVtbl acdropdownvt =
*/ */
static LRESULT APIENTRY ACEditSubclassProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) static LRESULT APIENTRY ACEditSubclassProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{ {
IAutoCompleteImpl *This = (IAutoCompleteImpl *)GetWindowLongPtrW(hwnd, GWLP_USERDATA); IAutoCompleteImpl *This = GetPropW(hwnd, autocomplete_propertyW);
LPOLESTR strs; LPOLESTR strs;
HRESULT hr; HRESULT hr;
WCHAR hwndText[255]; WCHAR hwndText[255];

View File

@ -141,6 +141,7 @@ static IAutoComplete *test_init(void)
HRESULT r; HRESULT r;
IAutoComplete *ac; IAutoComplete *ac;
IUnknown *acSource; IUnknown *acSource;
LONG_PTR user_data;
/* AutoComplete instance */ /* AutoComplete instance */
r = CoCreateInstance(&CLSID_AutoComplete, NULL, CLSCTX_INPROC_SERVER, r = CoCreateInstance(&CLSID_AutoComplete, NULL, CLSCTX_INPROC_SERVER,
@ -163,10 +164,16 @@ static IAutoComplete *test_init(void)
} }
ok(r == S_OK, "no IID_IACList (0x%08x)\n", r); ok(r == S_OK, "no IID_IACList (0x%08x)\n", r);
user_data = GetWindowLongPtrA(hEdit, GWLP_USERDATA);
ok(user_data == 0, "Expected the edit control user data to be zero\n");
/* bind to edit control */ /* bind to edit control */
r = IAutoComplete_Init(ac, hEdit, acSource, NULL, NULL); r = IAutoComplete_Init(ac, hEdit, acSource, NULL, NULL);
ok(r == S_OK, "Init returned 0x%08x\n", r); ok(r == S_OK, "Init returned 0x%08x\n", r);
user_data = GetWindowLongPtrA(hEdit, GWLP_USERDATA);
ok(user_data == 0, "Expected the edit control user data to be zero\n");
IUnknown_Release(acSource); IUnknown_Release(acSource);
return ac; return ac;