- Generate machine-local IPIDs.
[wine.git] / dlls / shell32 / autocomplete.c
blobf4f9b42548ed9363127ec955beaa875e913a284a
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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
36 #include "config.h"
38 #include <stdarg.h>
39 #include <stdlib.h>
40 #include <string.h>
42 #define COBJMACROS
44 #include "wine/debug.h"
45 #include "windef.h"
46 #include "winbase.h"
47 #include "winreg.h"
48 #include "undocshell.h"
49 #include "shlwapi.h"
50 #include "winerror.h"
51 #include "objbase.h"
53 #include "pidl.h"
54 #include "shlguid.h"
55 #include "shlobj.h"
56 #include "shldisp.h"
57 #include "debughlp.h"
59 #include "wine/unicode.h"
61 WINE_DEFAULT_DEBUG_CHANNEL(shell);
63 typedef struct
65 IAutoCompleteVtbl *lpVtbl;
66 IAutoComplete2Vtbl *lpvtblAutoComplete2;
67 DWORD ref;
68 BOOL enabled;
69 HWND hwndEdit;
70 HWND hwndListBox;
71 WNDPROC wpOrigEditProc;
72 WNDPROC wpOrigLBoxProc;
73 WCHAR *txtbackup;
74 WCHAR *quickComplete;
75 IEnumString *enumstr;
76 AUTOCOMPLETEOPTIONS options;
77 } IAutoCompleteImpl;
79 static struct IAutoCompleteVtbl acvt;
80 static struct IAutoComplete2Vtbl ac2vt;
82 #define _IAutoComplete2_Offset ((int)(&(((IAutoCompleteImpl*)0)->lpvtblAutoComplete2)))
83 #define _ICOM_THIS_From_IAutoComplete2(class, name) class* This = (class*)(((char*)name)-_IAutoComplete2_Offset);
86 converts This to a interface pointer
88 #define _IUnknown_(This) (IUnknown*)&(This->lpVtbl)
89 #define _IAutoComplete2_(This) (IAutoComplete2*)&(This->lpvtblAutoComplete2)
91 static LRESULT APIENTRY ACEditSubclassProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
92 static LRESULT APIENTRY ACLBoxSubclassProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
94 /**************************************************************************
95 * IAutoComplete_Constructor
97 HRESULT WINAPI IAutoComplete_Constructor(IUnknown * pUnkOuter, REFIID riid, LPVOID * ppv)
99 IAutoCompleteImpl *lpac;
101 if (pUnkOuter && !IsEqualIID (riid, &IID_IUnknown))
102 return CLASS_E_NOAGGREGATION;
104 lpac = (IAutoCompleteImpl*)HeapAlloc(GetProcessHeap(),
105 HEAP_ZERO_MEMORY, sizeof(IAutoCompleteImpl));
106 if (!lpac)
107 return E_OUTOFMEMORY;
109 lpac->ref = 1;
110 lpac->lpVtbl = &acvt;
111 lpac->lpvtblAutoComplete2 = &ac2vt;
112 lpac->enabled = TRUE;
113 lpac->enumstr = NULL;
114 lpac->options = ACO_AUTOAPPEND;
115 lpac->wpOrigEditProc = NULL;
116 lpac->hwndListBox = NULL;
117 lpac->txtbackup = NULL;
118 lpac->quickComplete = NULL;
120 if (!SUCCEEDED (IUnknown_QueryInterface (_IUnknown_ (lpac), riid, ppv))) {
121 IUnknown_Release (_IUnknown_ (lpac));
122 return E_NOINTERFACE;
125 TRACE("-- (%p)->\n",lpac);
127 return S_OK;
130 /**************************************************************************
131 * AutoComplete_QueryInterface
133 static HRESULT WINAPI IAutoComplete_fnQueryInterface(
134 IAutoComplete * iface,
135 REFIID riid,
136 LPVOID *ppvObj)
138 IAutoCompleteImpl *This = (IAutoCompleteImpl *)iface;
140 TRACE("(%p)->(\n\tIID:\t%s,%p)\n", This, shdebugstr_guid(riid), ppvObj);
141 *ppvObj = NULL;
143 if(IsEqualIID(riid, &IID_IUnknown))
145 *ppvObj = This;
147 else if(IsEqualIID(riid, &IID_IAutoComplete))
149 *ppvObj = (IAutoComplete*)This;
151 else if(IsEqualIID(riid, &IID_IAutoComplete2))
153 *ppvObj = _IAutoComplete2_ (This);
156 if (*ppvObj)
158 IAutoComplete_AddRef((IAutoComplete*)*ppvObj);
159 TRACE("-- Interface: (%p)->(%p)\n", ppvObj, *ppvObj);
160 return S_OK;
162 TRACE("-- Interface: E_NOINTERFACE\n");
163 return E_NOINTERFACE;
166 /******************************************************************************
167 * IAutoComplete_fnAddRef
169 static ULONG WINAPI IAutoComplete_fnAddRef(
170 IAutoComplete * iface)
172 IAutoCompleteImpl *This = (IAutoCompleteImpl *)iface;
173 ULONG refCount = InterlockedIncrement(&This->ref);
175 TRACE("(%p)->(%lu)\n", This, refCount - 1);
177 return refCount;
180 /******************************************************************************
181 * IAutoComplete_fnRelease
183 static ULONG WINAPI IAutoComplete_fnRelease(
184 IAutoComplete * iface)
186 IAutoCompleteImpl *This = (IAutoCompleteImpl *)iface;
187 ULONG refCount = InterlockedDecrement(&This->ref);
189 TRACE("(%p)->(%lu)\n", This, refCount + 1);
191 if (!refCount) {
192 TRACE(" destroying IAutoComplete(%p)\n",This);
193 HeapFree(GetProcessHeap(), 0, This->quickComplete);
194 HeapFree(GetProcessHeap(), 0, This->txtbackup);
195 if (This->hwndListBox)
196 DestroyWindow(This->hwndListBox);
197 if (This->enumstr)
198 IEnumString_Release(This->enumstr);
199 HeapFree(GetProcessHeap(), 0, This);
201 return refCount;
204 /******************************************************************************
205 * IAutoComplete_fnEnable
207 static HRESULT WINAPI IAutoComplete_fnEnable(
208 IAutoComplete * iface,
209 BOOL fEnable)
211 IAutoCompleteImpl *This = (IAutoCompleteImpl *)iface;
213 HRESULT hr = S_OK;
215 TRACE("(%p)->(%s)\n", This, (fEnable)?"true":"false");
217 This->enabled = fEnable;
219 return hr;
222 /******************************************************************************
223 * IAutoComplete_fnInit
225 static HRESULT WINAPI IAutoComplete_fnInit(
226 IAutoComplete * iface,
227 HWND hwndEdit,
228 IUnknown *punkACL,
229 LPCOLESTR pwzsRegKeyPath,
230 LPCOLESTR pwszQuickComplete)
232 IAutoCompleteImpl *This = (IAutoCompleteImpl *)iface;
233 static const WCHAR lbName[] = {'L','i','s','t','B','o','x',0};
235 TRACE("(%p)->(0x%08lx, %p, %s, %s)\n",
236 This, (long)hwndEdit, punkACL, debugstr_w(pwzsRegKeyPath), debugstr_w(pwszQuickComplete));
238 if (This->options & ACO_AUTOSUGGEST) TRACE(" ACO_AUTOSUGGEST\n");
239 if (This->options & ACO_AUTOAPPEND) TRACE(" ACO_AUTOAPPEND\n");
240 if (This->options & ACO_SEARCH) FIXME(" ACO_SEARCH not supported\n");
241 if (This->options & ACO_FILTERPREFIXES) FIXME(" ACO_FILTERPREFIXES not supported\n");
242 if (This->options & ACO_USETAB) FIXME(" ACO_USETAB not supported\n");
243 if (This->options & ACO_UPDOWNKEYDROPSLIST) TRACE(" ACO_UPDOWNKEYDROPSLIST\n");
244 if (This->options & ACO_RTLREADING) FIXME(" ACO_RTLREADING not supported\n");
246 This->hwndEdit = hwndEdit;
248 if (!SUCCEEDED (IUnknown_QueryInterface (punkACL, &IID_IEnumString, (LPVOID*)&This->enumstr))) {
249 TRACE("No IEnumString interface\n");
250 return E_NOINTERFACE;
253 This->wpOrigEditProc = (WNDPROC) SetWindowLongPtrW( hwndEdit, GWLP_WNDPROC, (LONG_PTR) ACEditSubclassProc);
254 SetWindowLongPtrW( hwndEdit, GWLP_USERDATA, (LONG_PTR)This);
256 if (This->options & ACO_AUTOSUGGEST) {
257 HWND hwndParent;
259 hwndParent = GetParent(This->hwndEdit);
261 /* FIXME : The listbox should be resizable with the mouse. WS_THICKFRAME looks ugly */
262 This->hwndListBox = CreateWindowExW(0, lbName, NULL,
263 WS_BORDER | WS_CHILD | WS_VSCROLL | LBS_HASSTRINGS | LBS_NOTIFY | LBS_NOINTEGRALHEIGHT,
264 CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
265 hwndParent, NULL,
266 (HINSTANCE)GetWindowLongPtrW( hwndParent, GWLP_HINSTANCE ), NULL);
268 if (This->hwndListBox) {
269 This->wpOrigLBoxProc = (WNDPROC) SetWindowLongPtrW( This->hwndListBox, GWLP_WNDPROC, (LONG_PTR) ACLBoxSubclassProc);
270 SetWindowLongPtrW( This->hwndListBox, GWLP_USERDATA, (LONG_PTR)This);
274 if (pwzsRegKeyPath) {
275 WCHAR *key;
276 WCHAR result[MAX_PATH];
277 WCHAR *value;
278 HKEY hKey = 0;
279 LONG res;
280 LONG len;
282 /* pwszRegKeyPath contains the key as well as the value, so we split */
283 key = (WCHAR*)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, (lstrlenW(pwzsRegKeyPath)+1)*sizeof(WCHAR));
284 strcpyW(key, pwzsRegKeyPath);
285 value = strrchrW(key, '\\');
286 *value = 0;
287 value++;
288 /* Now value contains the value and buffer the key */
289 res = RegOpenKeyExW(HKEY_CURRENT_USER, key, 0, KEY_READ, &hKey);
290 if (res != ERROR_SUCCESS) {
291 /* if the key is not found, MSDN states we must seek in HKEY_LOCAL_MACHINE */
292 res = RegOpenKeyExW(HKEY_LOCAL_MACHINE, key, 0, KEY_READ, &hKey);
294 if (res == ERROR_SUCCESS) {
295 res = RegQueryValueW(hKey, value, result, &len);
296 if (res == ERROR_SUCCESS) {
297 This->quickComplete = (WCHAR*)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, len*sizeof(WCHAR));
298 strcpyW(This->quickComplete, result);
300 RegCloseKey(hKey);
302 HeapFree(GetProcessHeap(), 0, key);
305 if ((pwszQuickComplete) && (!This->quickComplete)) {
306 This->quickComplete = (WCHAR*)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, (lstrlenW(pwszQuickComplete)+1)*sizeof(WCHAR));
307 lstrcpyW(This->quickComplete, pwszQuickComplete);
310 return S_OK;
313 /**************************************************************************
314 * IAutoComplete_fnVTable
316 static IAutoCompleteVtbl acvt =
318 IAutoComplete_fnQueryInterface,
319 IAutoComplete_fnAddRef,
320 IAutoComplete_fnRelease,
321 IAutoComplete_fnInit,
322 IAutoComplete_fnEnable,
325 /**************************************************************************
326 * AutoComplete2_QueryInterface
328 static HRESULT WINAPI IAutoComplete2_fnQueryInterface(
329 IAutoComplete2 * iface,
330 REFIID riid,
331 LPVOID *ppvObj)
333 _ICOM_THIS_From_IAutoComplete2(IAutoCompleteImpl, iface);
335 TRACE ("(%p)->(%s,%p)\n", This, shdebugstr_guid (riid), ppvObj);
337 return IAutoComplete_QueryInterface((IAutoComplete*)This, riid, ppvObj);
340 /******************************************************************************
341 * IAutoComplete2_fnAddRef
343 static ULONG WINAPI IAutoComplete2_fnAddRef(
344 IAutoComplete2 * iface)
346 _ICOM_THIS_From_IAutoComplete2(IAutoCompleteImpl,iface);
348 TRACE ("(%p)->(count=%lu)\n", This, This->ref);
350 return IAutoComplete2_AddRef((IAutoComplete*)This);
353 /******************************************************************************
354 * IAutoComplete2_fnRelease
356 static ULONG WINAPI IAutoComplete2_fnRelease(
357 IAutoComplete2 * iface)
359 _ICOM_THIS_From_IAutoComplete2(IAutoCompleteImpl,iface);
361 TRACE ("(%p)->(count=%lu)\n", This, This->ref);
363 return IAutoComplete_Release((IAutoComplete*)This);
366 /******************************************************************************
367 * IAutoComplete2_fnEnable
369 static HRESULT WINAPI IAutoComplete2_fnEnable(
370 IAutoComplete2 * iface,
371 BOOL fEnable)
373 _ICOM_THIS_From_IAutoComplete2(IAutoCompleteImpl, iface);
375 TRACE ("(%p)->(%s)\n", This, (fEnable)?"true":"false");
377 return IAutoComplete_Enable((IAutoComplete*)This, fEnable);
380 /******************************************************************************
381 * IAutoComplete2_fnInit
383 static HRESULT WINAPI IAutoComplete2_fnInit(
384 IAutoComplete2 * iface,
385 HWND hwndEdit,
386 IUnknown *punkACL,
387 LPCOLESTR pwzsRegKeyPath,
388 LPCOLESTR pwszQuickComplete)
390 _ICOM_THIS_From_IAutoComplete2(IAutoCompleteImpl, iface);
392 TRACE("(%p)\n", This);
394 return IAutoComplete_Init((IAutoComplete*)This, hwndEdit, punkACL, pwzsRegKeyPath, pwszQuickComplete);
397 /**************************************************************************
398 * IAutoComplete_fnGetOptions
400 static HRESULT WINAPI IAutoComplete2_fnGetOptions(
401 IAutoComplete2 * iface,
402 DWORD *pdwFlag)
404 HRESULT hr = S_OK;
406 _ICOM_THIS_From_IAutoComplete2(IAutoCompleteImpl, iface);
408 TRACE("(%p) -> (%p)\n", This, pdwFlag);
410 *pdwFlag = This->options;
412 return hr;
415 /**************************************************************************
416 * IAutoComplete_fnSetOptions
418 static HRESULT WINAPI IAutoComplete2_fnSetOptions(
419 IAutoComplete2 * iface,
420 DWORD dwFlag)
422 HRESULT hr = S_OK;
424 _ICOM_THIS_From_IAutoComplete2(IAutoCompleteImpl, iface);
426 TRACE("(%p) -> (0x%lx)\n", This, dwFlag);
428 This->options = dwFlag;
430 return hr;
433 /**************************************************************************
434 * IAutoComplete2_fnVTable
436 static IAutoComplete2Vtbl ac2vt =
438 IAutoComplete2_fnQueryInterface,
439 IAutoComplete2_fnAddRef,
440 IAutoComplete2_fnRelease,
441 IAutoComplete2_fnInit,
442 IAutoComplete2_fnEnable,
443 /* IAutoComplete2 */
444 IAutoComplete2_fnSetOptions,
445 IAutoComplete2_fnGetOptions,
449 Window procedure for autocompletion
451 static LRESULT APIENTRY ACEditSubclassProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
453 IAutoCompleteImpl *This = (IAutoCompleteImpl *)GetWindowLongPtrW(hwnd, GWLP_USERDATA);
454 LPOLESTR strs;
455 HRESULT hr;
456 WCHAR hwndText[255];
457 WCHAR *hwndQCText;
458 RECT r;
459 BOOL control, filled, displayall = FALSE;
460 int cpt, height, sel;
462 if (!This->enabled) return CallWindowProcW(This->wpOrigEditProc, hwnd, uMsg, wParam, lParam);
464 switch (uMsg)
466 case CB_SHOWDROPDOWN:
467 ShowWindow(This->hwndListBox, SW_HIDE);
468 break;
469 case WM_KILLFOCUS:
470 if ((This->options && ACO_AUTOSUGGEST) &&
471 ((HWND)wParam != This->hwndListBox))
473 ShowWindow(This->hwndListBox, SW_HIDE);
475 break;
476 case WM_KEYUP:
478 GetWindowTextW( hwnd, (LPWSTR)hwndText, 255);
480 switch(wParam) {
481 case VK_RETURN:
482 /* If quickComplete is set and control is pressed, replace the string */
483 control = GetKeyState(VK_CONTROL) & 0x8000;
484 if (control && This->quickComplete) {
485 hwndQCText = (WCHAR*)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
486 (lstrlenW(This->quickComplete)+lstrlenW(hwndText))*sizeof(WCHAR));
487 sel = sprintfW(hwndQCText, This->quickComplete, hwndText);
488 SendMessageW(hwnd, WM_SETTEXT, 0, (LPARAM)hwndQCText);
489 SendMessageW(hwnd, EM_SETSEL, 0, sel);
490 HeapFree(GetProcessHeap(), 0, hwndQCText);
493 ShowWindow(This->hwndListBox, SW_HIDE);
494 return 0;
495 case VK_LEFT:
496 case VK_RIGHT:
497 return 0;
498 case VK_UP:
499 case VK_DOWN:
500 /* Two cases here :
501 - if the listbox is not visible, displays it
502 with all the entries if the style ACO_UPDOWNKEYDROPSLIST
503 is present but does not select anything.
504 - if the listbox is visible, change the selection
506 if ( (This->options & (ACO_AUTOSUGGEST | ACO_UPDOWNKEYDROPSLIST))
507 && (!IsWindowVisible(This->hwndListBox) && (! *hwndText)) )
509 /* We must dispays all the entries */
510 displayall = TRUE;
511 } else {
512 if (IsWindowVisible(This->hwndListBox)) {
513 int count;
515 count = SendMessageW(This->hwndListBox, LB_GETCOUNT, 0, 0);
516 /* Change the selection */
517 sel = SendMessageW(This->hwndListBox, LB_GETCURSEL, 0, 0);
518 if (wParam == VK_UP)
519 sel = ((sel-1)<0)?count-1:sel-1;
520 else
521 sel = ((sel+1)>= count)?-1:sel+1;
522 SendMessageW(This->hwndListBox, LB_SETCURSEL, sel, 0);
523 if (sel != -1) {
524 WCHAR *msg;
525 int len;
527 len = SendMessageW(This->hwndListBox, LB_GETTEXTLEN, sel, (LPARAM)NULL);
528 msg = (WCHAR*) HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, (len+1)*sizeof(WCHAR));
529 SendMessageW(This->hwndListBox, LB_GETTEXT, sel, (LPARAM)msg);
530 SendMessageW(hwnd, WM_SETTEXT, 0, (LPARAM)msg);
531 SendMessageW(hwnd, EM_SETSEL, lstrlenW(msg), lstrlenW(msg));
532 HeapFree(GetProcessHeap(), 0, msg);
533 } else {
534 SendMessageW(hwnd, WM_SETTEXT, 0, (LPARAM)This->txtbackup);
535 SendMessageW(hwnd, EM_SETSEL, lstrlenW(This->txtbackup), lstrlenW(This->txtbackup));
538 return 0;
540 break;
541 case VK_BACK:
542 case VK_DELETE:
543 if ((! *hwndText) && (This->options & ACO_AUTOSUGGEST)) {
544 ShowWindow(This->hwndListBox, SW_HIDE);
545 return CallWindowProcW(This->wpOrigEditProc, hwnd, uMsg, wParam, lParam);
547 if (This->options & ACO_AUTOAPPEND) {
548 DWORD b;
549 SendMessageW(hwnd, EM_GETSEL, (WPARAM)&b, (LPARAM)NULL);
550 if (b>1) {
551 hwndText[b-1] = '\0';
552 } else {
553 hwndText[0] = '\0';
554 SetWindowTextW(hwnd, hwndText);
557 break;
558 default:
562 SendMessageW(This->hwndListBox, LB_RESETCONTENT, 0, 0);
564 HeapFree(GetProcessHeap(), 0, This->txtbackup);
565 This->txtbackup = (WCHAR*) HeapAlloc(GetProcessHeap(),
566 HEAP_ZERO_MEMORY, (lstrlenW(hwndText)+1)*sizeof(WCHAR));
567 lstrcpyW(This->txtbackup, hwndText);
569 /* Returns if there is no text to search and we doesn't want to display all the entries */
570 if ((!displayall) && (! *hwndText) )
571 break;
573 IEnumString_Reset(This->enumstr);
574 filled = FALSE;
575 for(cpt = 0;;) {
576 hr = IEnumString_Next(This->enumstr, 1, &strs, NULL);
577 if (hr != S_OK)
578 break;
580 if ((LPWSTR)strstrW(strs, hwndText) == strs) {
582 if (This->options & ACO_AUTOAPPEND) {
583 SetWindowTextW(hwnd, strs);
584 SendMessageW(hwnd, EM_SETSEL, lstrlenW(hwndText), lstrlenW(strs));
585 break;
588 if (This->options & ACO_AUTOSUGGEST) {
589 SendMessageW(This->hwndListBox, LB_ADDSTRING, 0, (LPARAM)strs);
590 filled = TRUE;
591 cpt++;
596 if (This->options & ACO_AUTOSUGGEST) {
597 if (filled) {
598 height = SendMessageW(This->hwndListBox, LB_GETITEMHEIGHT, 0, 0);
599 SendMessageW(This->hwndListBox, LB_CARETOFF, 0, 0);
600 GetWindowRect(hwnd, &r);
601 SetParent(This->hwndListBox, HWND_DESKTOP);
602 /* It seems that Windows XP displays 7 lines at most
603 and otherwise displays a vertical scroll bar */
604 SetWindowPos(This->hwndListBox, HWND_TOP,
605 r.left, r.bottom + 1, r.right - r.left, min(height * 7, height*(cpt+1)),
606 SWP_SHOWWINDOW );
607 } else {
608 ShowWindow(This->hwndListBox, SW_HIDE);
612 break;
613 default:
614 return CallWindowProcW(This->wpOrigEditProc, hwnd, uMsg, wParam, lParam);
618 return 0;
621 static LRESULT APIENTRY ACLBoxSubclassProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
623 IAutoCompleteImpl *This = (IAutoCompleteImpl *)GetWindowLongPtrW(hwnd, GWLP_USERDATA);
624 WCHAR *msg;
625 int sel = -1, len;
627 switch (uMsg) {
628 case WM_MOUSEMOVE:
629 sel = SendMessageW(hwnd, LB_ITEMFROMPOINT, 0, lParam);
630 SendMessageW(hwnd, LB_SETCURSEL, (WPARAM)sel, (LPARAM)0);
631 break;
632 case WM_LBUTTONDOWN:
633 len = SendMessageW(This->hwndListBox, LB_GETTEXTLEN, sel, (LPARAM)NULL);
634 msg = (WCHAR*) HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, (len+1)*sizeof(WCHAR));
635 sel = (INT)SendMessageW(hwnd, LB_GETCURSEL, 0, 0);
636 SendMessageW(hwnd, LB_GETTEXT, sel, (LPARAM)msg);
637 SendMessageW(This->hwndEdit, WM_SETTEXT, 0, (LPARAM)msg);
638 SendMessageW(This->hwndEdit, EM_SETSEL, 0, lstrlenW(msg));
639 ShowWindow(hwnd, SW_HIDE);
640 HeapFree(GetProcessHeap(), 0, msg);
641 break;
642 default:
643 return CallWindowProcW(This->wpOrigLBoxProc, hwnd, uMsg, wParam, lParam);
645 return 0;