wined3d: Attach the correct surface the the fbo.
[wine/hacks.git] / dlls / shell32 / autocomplete.c
blobc80069e6f03e3567fc489e88c55bed22e3403692
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
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 "shlobj.h"
55 #include "shldisp.h"
56 #include "debughlp.h"
58 #include "wine/unicode.h"
60 WINE_DEFAULT_DEBUG_CHANNEL(shell);
62 typedef struct
64 const IAutoCompleteVtbl *lpVtbl;
65 const IAutoComplete2Vtbl *lpvtblAutoComplete2;
66 LONG ref;
67 BOOL enabled;
68 HWND hwndEdit;
69 HWND hwndListBox;
70 WNDPROC wpOrigEditProc;
71 WNDPROC wpOrigLBoxProc;
72 WCHAR *txtbackup;
73 WCHAR *quickComplete;
74 IEnumString *enumstr;
75 AUTOCOMPLETEOPTIONS options;
76 } IAutoCompleteImpl;
78 static const IAutoCompleteVtbl acvt;
79 static const IAutoComplete2Vtbl ac2vt;
81 static inline IAutoCompleteImpl *impl_from_IAutoComplete2( IAutoComplete2 *iface )
83 return (IAutoCompleteImpl *)((char*)iface - FIELD_OFFSET(IAutoCompleteImpl, lpvtblAutoComplete2));
88 converts This to an interface pointer
90 #define _IUnknown_(This) (IUnknown*)&(This->lpVtbl)
91 #define _IAutoComplete2_(This) (IAutoComplete2*)&(This->lpvtblAutoComplete2)
93 static LRESULT APIENTRY ACEditSubclassProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
94 static LRESULT APIENTRY ACLBoxSubclassProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
96 /**************************************************************************
97 * IAutoComplete_Constructor
99 HRESULT WINAPI IAutoComplete_Constructor(IUnknown * pUnkOuter, REFIID riid, LPVOID * ppv)
101 IAutoCompleteImpl *lpac;
103 if (pUnkOuter && !IsEqualIID (riid, &IID_IUnknown))
104 return CLASS_E_NOAGGREGATION;
106 lpac = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(IAutoCompleteImpl));
107 if (!lpac)
108 return E_OUTOFMEMORY;
110 lpac->ref = 1;
111 lpac->lpVtbl = &acvt;
112 lpac->lpvtblAutoComplete2 = &ac2vt;
113 lpac->enabled = TRUE;
114 lpac->enumstr = NULL;
115 lpac->options = ACO_AUTOAPPEND;
116 lpac->wpOrigEditProc = NULL;
117 lpac->hwndListBox = NULL;
118 lpac->txtbackup = NULL;
119 lpac->quickComplete = NULL;
121 if (!SUCCEEDED (IUnknown_QueryInterface (_IUnknown_ (lpac), riid, ppv))) {
122 IUnknown_Release (_IUnknown_ (lpac));
123 return E_NOINTERFACE;
126 TRACE("-- (%p)->\n",lpac);
128 return S_OK;
131 /**************************************************************************
132 * AutoComplete_QueryInterface
134 static HRESULT WINAPI IAutoComplete_fnQueryInterface(
135 IAutoComplete * iface,
136 REFIID riid,
137 LPVOID *ppvObj)
139 IAutoCompleteImpl *This = (IAutoCompleteImpl *)iface;
141 TRACE("(%p)->(\n\tIID:\t%s,%p)\n", This, shdebugstr_guid(riid), ppvObj);
142 *ppvObj = NULL;
144 if(IsEqualIID(riid, &IID_IUnknown))
146 *ppvObj = This;
148 else if(IsEqualIID(riid, &IID_IAutoComplete))
150 *ppvObj = (IAutoComplete*)This;
152 else if(IsEqualIID(riid, &IID_IAutoComplete2))
154 *ppvObj = _IAutoComplete2_ (This);
157 if (*ppvObj)
159 IAutoComplete_AddRef((IAutoComplete*)*ppvObj);
160 TRACE("-- Interface: (%p)->(%p)\n", ppvObj, *ppvObj);
161 return S_OK;
163 TRACE("-- Interface: E_NOINTERFACE\n");
164 return E_NOINTERFACE;
167 /******************************************************************************
168 * IAutoComplete_fnAddRef
170 static ULONG WINAPI IAutoComplete_fnAddRef(
171 IAutoComplete * iface)
173 IAutoCompleteImpl *This = (IAutoCompleteImpl *)iface;
174 ULONG refCount = InterlockedIncrement(&This->ref);
176 TRACE("(%p)->(%u)\n", This, refCount - 1);
178 return refCount;
181 /******************************************************************************
182 * IAutoComplete_fnRelease
184 static ULONG WINAPI IAutoComplete_fnRelease(
185 IAutoComplete * iface)
187 IAutoCompleteImpl *This = (IAutoCompleteImpl *)iface;
188 ULONG refCount = InterlockedDecrement(&This->ref);
190 TRACE("(%p)->(%u)\n", This, refCount + 1);
192 if (!refCount) {
193 TRACE(" destroying IAutoComplete(%p)\n",This);
194 HeapFree(GetProcessHeap(), 0, This->quickComplete);
195 HeapFree(GetProcessHeap(), 0, This->txtbackup);
196 if (This->hwndListBox)
197 DestroyWindow(This->hwndListBox);
198 if (This->enumstr)
199 IEnumString_Release(This->enumstr);
200 HeapFree(GetProcessHeap(), 0, This);
202 return refCount;
205 /******************************************************************************
206 * IAutoComplete_fnEnable
208 static HRESULT WINAPI IAutoComplete_fnEnable(
209 IAutoComplete * iface,
210 BOOL fEnable)
212 IAutoCompleteImpl *This = (IAutoCompleteImpl *)iface;
214 HRESULT hr = S_OK;
216 TRACE("(%p)->(%s)\n", This, (fEnable)?"true":"false");
218 This->enabled = fEnable;
220 return hr;
223 /******************************************************************************
224 * IAutoComplete_fnInit
226 static HRESULT WINAPI IAutoComplete_fnInit(
227 IAutoComplete * iface,
228 HWND hwndEdit,
229 IUnknown *punkACL,
230 LPCOLESTR pwzsRegKeyPath,
231 LPCOLESTR pwszQuickComplete)
233 IAutoCompleteImpl *This = (IAutoCompleteImpl *)iface;
234 static const WCHAR lbName[] = {'L','i','s','t','B','o','x',0};
236 TRACE("(%p)->(0x%08lx, %p, %s, %s)\n",
237 This, (long)hwndEdit, punkACL, debugstr_w(pwzsRegKeyPath), debugstr_w(pwszQuickComplete));
239 if (This->options & ACO_AUTOSUGGEST) TRACE(" ACO_AUTOSUGGEST\n");
240 if (This->options & ACO_AUTOAPPEND) TRACE(" ACO_AUTOAPPEND\n");
241 if (This->options & ACO_SEARCH) FIXME(" ACO_SEARCH not supported\n");
242 if (This->options & ACO_FILTERPREFIXES) FIXME(" ACO_FILTERPREFIXES not supported\n");
243 if (This->options & ACO_USETAB) FIXME(" ACO_USETAB not supported\n");
244 if (This->options & ACO_UPDOWNKEYDROPSLIST) TRACE(" ACO_UPDOWNKEYDROPSLIST\n");
245 if (This->options & ACO_RTLREADING) FIXME(" ACO_RTLREADING not supported\n");
247 This->hwndEdit = hwndEdit;
249 if (!SUCCEEDED (IUnknown_QueryInterface (punkACL, &IID_IEnumString, (LPVOID*)&This->enumstr))) {
250 TRACE("No IEnumString interface\n");
251 return E_NOINTERFACE;
254 This->wpOrigEditProc = (WNDPROC) SetWindowLongPtrW( hwndEdit, GWLP_WNDPROC, (LONG_PTR) ACEditSubclassProc);
255 SetWindowLongPtrW( hwndEdit, GWLP_USERDATA, (LONG_PTR)This);
257 if (This->options & ACO_AUTOSUGGEST) {
258 HWND hwndParent;
260 hwndParent = GetParent(This->hwndEdit);
262 /* FIXME : The listbox should be resizable with the mouse. WS_THICKFRAME looks ugly */
263 This->hwndListBox = CreateWindowExW(0, lbName, NULL,
264 WS_BORDER | WS_CHILD | WS_VSCROLL | LBS_HASSTRINGS | LBS_NOTIFY | LBS_NOINTEGRALHEIGHT,
265 CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
266 hwndParent, NULL,
267 (HINSTANCE)GetWindowLongPtrW( hwndParent, GWLP_HINSTANCE ), NULL);
269 if (This->hwndListBox) {
270 This->wpOrigLBoxProc = (WNDPROC) SetWindowLongPtrW( This->hwndListBox, GWLP_WNDPROC, (LONG_PTR) ACLBoxSubclassProc);
271 SetWindowLongPtrW( This->hwndListBox, GWLP_USERDATA, (LONG_PTR)This);
275 if (pwzsRegKeyPath) {
276 WCHAR *key;
277 WCHAR result[MAX_PATH];
278 WCHAR *value;
279 HKEY hKey = 0;
280 LONG res;
281 LONG len;
283 /* pwszRegKeyPath contains the key as well as the value, so we split */
284 key = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, (lstrlenW(pwzsRegKeyPath)+1)*sizeof(WCHAR));
285 strcpyW(key, pwzsRegKeyPath);
286 value = strrchrW(key, '\\');
287 *value = 0;
288 value++;
289 /* Now value contains the value and buffer the key */
290 res = RegOpenKeyExW(HKEY_CURRENT_USER, key, 0, KEY_READ, &hKey);
291 if (res != ERROR_SUCCESS) {
292 /* if the key is not found, MSDN states we must seek in HKEY_LOCAL_MACHINE */
293 res = RegOpenKeyExW(HKEY_LOCAL_MACHINE, key, 0, KEY_READ, &hKey);
295 if (res == ERROR_SUCCESS) {
296 res = RegQueryValueW(hKey, value, result, &len);
297 if (res == ERROR_SUCCESS) {
298 This->quickComplete = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, len*sizeof(WCHAR));
299 strcpyW(This->quickComplete, result);
301 RegCloseKey(hKey);
303 HeapFree(GetProcessHeap(), 0, key);
306 if ((pwszQuickComplete) && (!This->quickComplete)) {
307 This->quickComplete = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, (lstrlenW(pwszQuickComplete)+1)*sizeof(WCHAR));
308 lstrcpyW(This->quickComplete, pwszQuickComplete);
311 return S_OK;
314 /**************************************************************************
315 * IAutoComplete_fnVTable
317 static const IAutoCompleteVtbl acvt =
319 IAutoComplete_fnQueryInterface,
320 IAutoComplete_fnAddRef,
321 IAutoComplete_fnRelease,
322 IAutoComplete_fnInit,
323 IAutoComplete_fnEnable,
326 /**************************************************************************
327 * AutoComplete2_QueryInterface
329 static HRESULT WINAPI IAutoComplete2_fnQueryInterface(
330 IAutoComplete2 * iface,
331 REFIID riid,
332 LPVOID *ppvObj)
334 IAutoCompleteImpl *This = impl_from_IAutoComplete2(iface);
336 TRACE ("(%p)->(%s,%p)\n", This, shdebugstr_guid (riid), ppvObj);
338 return IAutoComplete_QueryInterface((IAutoComplete*)This, riid, ppvObj);
341 /******************************************************************************
342 * IAutoComplete2_fnAddRef
344 static ULONG WINAPI IAutoComplete2_fnAddRef(
345 IAutoComplete2 * iface)
347 IAutoCompleteImpl *This = impl_from_IAutoComplete2(iface);
349 TRACE ("(%p)->(count=%u)\n", This, This->ref);
351 return IAutoComplete2_AddRef((IAutoComplete*)This);
354 /******************************************************************************
355 * IAutoComplete2_fnRelease
357 static ULONG WINAPI IAutoComplete2_fnRelease(
358 IAutoComplete2 * iface)
360 IAutoCompleteImpl *This = impl_from_IAutoComplete2(iface);
362 TRACE ("(%p)->(count=%u)\n", This, This->ref);
364 return IAutoComplete_Release((IAutoComplete*)This);
367 /******************************************************************************
368 * IAutoComplete2_fnEnable
370 static HRESULT WINAPI IAutoComplete2_fnEnable(
371 IAutoComplete2 * iface,
372 BOOL fEnable)
374 IAutoCompleteImpl *This = impl_from_IAutoComplete2(iface);
376 TRACE ("(%p)->(%s)\n", This, (fEnable)?"true":"false");
378 return IAutoComplete_Enable((IAutoComplete*)This, fEnable);
381 /******************************************************************************
382 * IAutoComplete2_fnInit
384 static HRESULT WINAPI IAutoComplete2_fnInit(
385 IAutoComplete2 * iface,
386 HWND hwndEdit,
387 IUnknown *punkACL,
388 LPCOLESTR pwzsRegKeyPath,
389 LPCOLESTR pwszQuickComplete)
391 IAutoCompleteImpl *This = impl_from_IAutoComplete2(iface);
393 TRACE("(%p)\n", This);
395 return IAutoComplete_Init((IAutoComplete*)This, hwndEdit, punkACL, pwzsRegKeyPath, pwszQuickComplete);
398 /**************************************************************************
399 * IAutoComplete_fnGetOptions
401 static HRESULT WINAPI IAutoComplete2_fnGetOptions(
402 IAutoComplete2 * iface,
403 DWORD *pdwFlag)
405 HRESULT hr = S_OK;
407 IAutoCompleteImpl *This = impl_from_IAutoComplete2(iface);
409 TRACE("(%p) -> (%p)\n", This, pdwFlag);
411 *pdwFlag = This->options;
413 return hr;
416 /**************************************************************************
417 * IAutoComplete_fnSetOptions
419 static HRESULT WINAPI IAutoComplete2_fnSetOptions(
420 IAutoComplete2 * iface,
421 DWORD dwFlag)
423 HRESULT hr = S_OK;
425 IAutoCompleteImpl *This = impl_from_IAutoComplete2(iface);
427 TRACE("(%p) -> (0x%x)\n", This, dwFlag);
429 This->options = dwFlag;
431 return hr;
434 /**************************************************************************
435 * IAutoComplete2_fnVTable
437 static const IAutoComplete2Vtbl ac2vt =
439 IAutoComplete2_fnQueryInterface,
440 IAutoComplete2_fnAddRef,
441 IAutoComplete2_fnRelease,
442 IAutoComplete2_fnInit,
443 IAutoComplete2_fnEnable,
444 /* IAutoComplete2 */
445 IAutoComplete2_fnSetOptions,
446 IAutoComplete2_fnGetOptions,
450 Window procedure for autocompletion
452 static LRESULT APIENTRY ACEditSubclassProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
454 IAutoCompleteImpl *This = (IAutoCompleteImpl *)GetWindowLongPtrW(hwnd, GWLP_USERDATA);
455 LPOLESTR strs;
456 HRESULT hr;
457 WCHAR hwndText[255];
458 WCHAR *hwndQCText;
459 RECT r;
460 BOOL control, filled, displayall = FALSE;
461 int cpt, height, sel;
463 if (!This->enabled) return CallWindowProcW(This->wpOrigEditProc, hwnd, uMsg, wParam, lParam);
465 switch (uMsg)
467 case CB_SHOWDROPDOWN:
468 ShowWindow(This->hwndListBox, SW_HIDE);
469 break;
470 case WM_KILLFOCUS:
471 if ((This->options && ACO_AUTOSUGGEST) &&
472 ((HWND)wParam != This->hwndListBox))
474 ShowWindow(This->hwndListBox, SW_HIDE);
476 break;
477 case WM_KEYUP:
479 GetWindowTextW( hwnd, (LPWSTR)hwndText, 255);
481 switch(wParam) {
482 case VK_RETURN:
483 /* If quickComplete is set and control is pressed, replace the string */
484 control = GetKeyState(VK_CONTROL) & 0x8000;
485 if (control && This->quickComplete) {
486 hwndQCText = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
487 (lstrlenW(This->quickComplete)+lstrlenW(hwndText))*sizeof(WCHAR));
488 sel = sprintfW(hwndQCText, This->quickComplete, hwndText);
489 SendMessageW(hwnd, WM_SETTEXT, 0, (LPARAM)hwndQCText);
490 SendMessageW(hwnd, EM_SETSEL, 0, sel);
491 HeapFree(GetProcessHeap(), 0, hwndQCText);
494 ShowWindow(This->hwndListBox, SW_HIDE);
495 return 0;
496 case VK_LEFT:
497 case VK_RIGHT:
498 return 0;
499 case VK_UP:
500 case VK_DOWN:
501 /* Two cases here :
502 - if the listbox is not visible, displays it
503 with all the entries if the style ACO_UPDOWNKEYDROPSLIST
504 is present but does not select anything.
505 - if the listbox is visible, change the selection
507 if ( (This->options & (ACO_AUTOSUGGEST | ACO_UPDOWNKEYDROPSLIST))
508 && (!IsWindowVisible(This->hwndListBox) && (! *hwndText)) )
510 /* We must dispays all the entries */
511 displayall = TRUE;
512 } else {
513 if (IsWindowVisible(This->hwndListBox)) {
514 int count;
516 count = SendMessageW(This->hwndListBox, LB_GETCOUNT, 0, 0);
517 /* Change the selection */
518 sel = SendMessageW(This->hwndListBox, LB_GETCURSEL, 0, 0);
519 if (wParam == VK_UP)
520 sel = ((sel-1)<0)?count-1:sel-1;
521 else
522 sel = ((sel+1)>= count)?-1:sel+1;
523 SendMessageW(This->hwndListBox, LB_SETCURSEL, sel, 0);
524 if (sel != -1) {
525 WCHAR *msg;
526 int len;
528 len = SendMessageW(This->hwndListBox, LB_GETTEXTLEN, sel, (LPARAM)NULL);
529 msg = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, (len+1)*sizeof(WCHAR));
530 SendMessageW(This->hwndListBox, LB_GETTEXT, sel, (LPARAM)msg);
531 SendMessageW(hwnd, WM_SETTEXT, 0, (LPARAM)msg);
532 SendMessageW(hwnd, EM_SETSEL, lstrlenW(msg), lstrlenW(msg));
533 HeapFree(GetProcessHeap(), 0, msg);
534 } else {
535 SendMessageW(hwnd, WM_SETTEXT, 0, (LPARAM)This->txtbackup);
536 SendMessageW(hwnd, EM_SETSEL, lstrlenW(This->txtbackup), lstrlenW(This->txtbackup));
539 return 0;
541 break;
542 case VK_BACK:
543 case VK_DELETE:
544 if ((! *hwndText) && (This->options & ACO_AUTOSUGGEST)) {
545 ShowWindow(This->hwndListBox, SW_HIDE);
546 return CallWindowProcW(This->wpOrigEditProc, hwnd, uMsg, wParam, lParam);
548 if (This->options & ACO_AUTOAPPEND) {
549 DWORD b;
550 SendMessageW(hwnd, EM_GETSEL, (WPARAM)&b, (LPARAM)NULL);
551 if (b>1) {
552 hwndText[b-1] = '\0';
553 } else {
554 hwndText[0] = '\0';
555 SetWindowTextW(hwnd, hwndText);
558 break;
559 default:
563 SendMessageW(This->hwndListBox, LB_RESETCONTENT, 0, 0);
565 HeapFree(GetProcessHeap(), 0, This->txtbackup);
566 This->txtbackup = HeapAlloc(GetProcessHeap(),
567 HEAP_ZERO_MEMORY, (lstrlenW(hwndText)+1)*sizeof(WCHAR));
568 lstrcpyW(This->txtbackup, hwndText);
570 /* Returns if there is no text to search and we doesn't want to display all the entries */
571 if ((!displayall) && (! *hwndText) )
572 break;
574 IEnumString_Reset(This->enumstr);
575 filled = FALSE;
576 for(cpt = 0;;) {
577 hr = IEnumString_Next(This->enumstr, 1, &strs, NULL);
578 if (hr != S_OK)
579 break;
581 if ((LPWSTR)strstrW(strs, hwndText) == strs) {
583 if (This->options & ACO_AUTOAPPEND) {
584 SetWindowTextW(hwnd, strs);
585 SendMessageW(hwnd, EM_SETSEL, lstrlenW(hwndText), lstrlenW(strs));
586 break;
589 if (This->options & ACO_AUTOSUGGEST) {
590 SendMessageW(This->hwndListBox, LB_ADDSTRING, 0, (LPARAM)strs);
591 filled = TRUE;
592 cpt++;
597 if (This->options & ACO_AUTOSUGGEST) {
598 if (filled) {
599 height = SendMessageW(This->hwndListBox, LB_GETITEMHEIGHT, 0, 0);
600 SendMessageW(This->hwndListBox, LB_CARETOFF, 0, 0);
601 GetWindowRect(hwnd, &r);
602 SetParent(This->hwndListBox, HWND_DESKTOP);
603 /* It seems that Windows XP displays 7 lines at most
604 and otherwise displays a vertical scroll bar */
605 SetWindowPos(This->hwndListBox, HWND_TOP,
606 r.left, r.bottom + 1, r.right - r.left, min(height * 7, height*(cpt+1)),
607 SWP_SHOWWINDOW );
608 } else {
609 ShowWindow(This->hwndListBox, SW_HIDE);
613 break;
614 default:
615 return CallWindowProcW(This->wpOrigEditProc, hwnd, uMsg, wParam, lParam);
619 return 0;
622 static LRESULT APIENTRY ACLBoxSubclassProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
624 IAutoCompleteImpl *This = (IAutoCompleteImpl *)GetWindowLongPtrW(hwnd, GWLP_USERDATA);
625 WCHAR *msg;
626 int sel, len;
628 switch (uMsg) {
629 case WM_MOUSEMOVE:
630 sel = SendMessageW(hwnd, LB_ITEMFROMPOINT, 0, lParam);
631 SendMessageW(hwnd, LB_SETCURSEL, (WPARAM)sel, (LPARAM)0);
632 break;
633 case WM_LBUTTONDOWN:
634 sel = SendMessageW(hwnd, LB_GETCURSEL, 0, 0);
635 if (sel < 0)
636 break;
637 len = SendMessageW(This->hwndListBox, LB_GETTEXTLEN, sel, 0);
638 msg = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, (len+1)*sizeof(WCHAR));
639 SendMessageW(hwnd, LB_GETTEXT, sel, (LPARAM)msg);
640 SendMessageW(This->hwndEdit, WM_SETTEXT, 0, (LPARAM)msg);
641 SendMessageW(This->hwndEdit, EM_SETSEL, 0, lstrlenW(msg));
642 ShowWindow(hwnd, SW_HIDE);
643 HeapFree(GetProcessHeap(), 0, msg);
644 break;
645 default:
646 return CallWindowProcW(This->wpOrigLBoxProc, hwnd, uMsg, wParam, lParam);
648 return 0;