[SHELL32]

Claudiu Mihail:
* Formatting fixes.
* autocomplete test fix.

svn path=/branches/shell32_new-bringup/; revision=53376
This commit is contained in:
Amine Khaldi 2011-08-22 16:28:51 +00:00
parent efa1f39fbc
commit a3621e43e3

View file

@ -88,17 +88,25 @@ HRESULT WINAPI CAutoComplete::Init(HWND hwndEdit, IUnknown *punkACL, LPCOLESTR p
TRACE("(%p)->(0x%08lx, %p, %s, %s)\n", TRACE("(%p)->(0x%08lx, %p, %s, %s)\n",
this, hwndEdit, punkACL, debugstr_w(pwzsRegKeyPath), debugstr_w(pwszQuickComplete)); this, hwndEdit, punkACL, debugstr_w(pwzsRegKeyPath), debugstr_w(pwszQuickComplete));
if (options & ACO_AUTOSUGGEST) TRACE(" ACO_AUTOSUGGEST\n"); if (options & ACO_AUTOSUGGEST)
if (options & ACO_AUTOAPPEND) TRACE(" ACO_AUTOAPPEND\n"); TRACE(" ACO_AUTOSUGGEST\n");
if (options & ACO_SEARCH) FIXME(" ACO_SEARCH not supported\n"); if (options & ACO_AUTOAPPEND)
if (options & ACO_FILTERPREFIXES) FIXME(" ACO_FILTERPREFIXES not supported\n"); TRACE(" ACO_AUTOAPPEND\n");
if (options & ACO_USETAB) FIXME(" ACO_USETAB not supported\n"); if (options & ACO_SEARCH)
if (options & ACO_UPDOWNKEYDROPSLIST) TRACE(" ACO_UPDOWNKEYDROPSLIST\n"); FIXME(" ACO_SEARCH not supported\n");
if (options & ACO_RTLREADING) FIXME(" ACO_RTLREADING not supported\n"); if (options & ACO_FILTERPREFIXES)
FIXME(" ACO_FILTERPREFIXES not supported\n");
if (options & ACO_USETAB)
FIXME(" ACO_USETAB not supported\n");
if (options & ACO_UPDOWNKEYDROPSLIST)
TRACE(" ACO_UPDOWNKEYDROPSLIST\n");
if (options & ACO_RTLREADING)
FIXME(" ACO_RTLREADING not supported\n");
hwndEdit = hwndEdit; hwndEdit = hwndEdit;
if (!SUCCEEDED (punkACL->QueryInterface(IID_IEnumString, (LPVOID *)&enumstr))) { if (!SUCCEEDED (punkACL->QueryInterface(IID_IEnumString, (LPVOID *)&enumstr)))
{
TRACE("No IEnumString interface\n"); TRACE("No IEnumString interface\n");
return E_NOINTERFACE; return E_NOINTERFACE;
} }
@ -106,7 +114,8 @@ HRESULT WINAPI CAutoComplete::Init(HWND hwndEdit, IUnknown *punkACL, LPCOLESTR p
wpOrigEditProc = (WNDPROC)SetWindowLongPtrW(hwndEdit, GWLP_WNDPROC, (LONG_PTR) ACEditSubclassProc); wpOrigEditProc = (WNDPROC)SetWindowLongPtrW(hwndEdit, GWLP_WNDPROC, (LONG_PTR) ACEditSubclassProc);
SetWindowLongPtrW(hwndEdit, GWLP_USERDATA, (LONG_PTR)this); SetWindowLongPtrW(hwndEdit, GWLP_USERDATA, (LONG_PTR)this);
if (options & ACO_AUTOSUGGEST) { if (options & ACO_AUTOSUGGEST)
{
HWND hwndParent; HWND hwndParent;
hwndParent = GetParent(hwndEdit); hwndParent = GetParent(hwndEdit);
@ -118,13 +127,15 @@ HRESULT WINAPI CAutoComplete::Init(HWND hwndEdit, IUnknown *punkACL, LPCOLESTR p
hwndParent, NULL, hwndParent, NULL,
(HINSTANCE)GetWindowLongPtrW(hwndParent, GWLP_HINSTANCE), NULL); (HINSTANCE)GetWindowLongPtrW(hwndParent, GWLP_HINSTANCE), NULL);
if (hwndListBox) { if (hwndListBox)
{
wpOrigLBoxProc = (WNDPROC)SetWindowLongPtrW(hwndListBox, GWLP_WNDPROC, (LONG_PTR)ACLBoxSubclassProc); wpOrigLBoxProc = (WNDPROC)SetWindowLongPtrW(hwndListBox, GWLP_WNDPROC, (LONG_PTR)ACLBoxSubclassProc);
SetWindowLongPtrW(hwndListBox, GWLP_USERDATA, (LONG_PTR)this); SetWindowLongPtrW(hwndListBox, GWLP_USERDATA, (LONG_PTR)this);
} }
} }
if (pwzsRegKeyPath) { if (pwzsRegKeyPath)
{
WCHAR *key; WCHAR *key;
WCHAR result[MAX_PATH]; WCHAR result[MAX_PATH];
WCHAR *value; WCHAR *value;
@ -140,13 +151,18 @@ HRESULT WINAPI CAutoComplete::Init(HWND hwndEdit, IUnknown *punkACL, LPCOLESTR p
value++; value++;
/* Now value contains the value and buffer the key */ /* Now value contains the value and buffer the key */
res = RegOpenKeyExW(HKEY_CURRENT_USER, key, 0, KEY_READ, &hKey); res = RegOpenKeyExW(HKEY_CURRENT_USER, key, 0, KEY_READ, &hKey);
if (res != ERROR_SUCCESS) {
if (res != ERROR_SUCCESS)
{
/* if the key is not found, MSDN states we must seek in HKEY_LOCAL_MACHINE */ /* if the key is not found, MSDN states we must seek in HKEY_LOCAL_MACHINE */
res = RegOpenKeyExW(HKEY_LOCAL_MACHINE, key, 0, KEY_READ, &hKey); res = RegOpenKeyExW(HKEY_LOCAL_MACHINE, key, 0, KEY_READ, &hKey);
} }
if (res == ERROR_SUCCESS) {
if (res == ERROR_SUCCESS)
{
res = RegQueryValueW(hKey, value, result, &len); res = RegQueryValueW(hKey, value, result, &len);
if (res == ERROR_SUCCESS) { if (res == ERROR_SUCCESS)
{
quickComplete = (WCHAR *)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, len * sizeof(WCHAR)); quickComplete = (WCHAR *)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, len * sizeof(WCHAR));
wcscpy(quickComplete, result); wcscpy(quickComplete, result);
} }
@ -155,7 +171,8 @@ HRESULT WINAPI CAutoComplete::Init(HWND hwndEdit, IUnknown *punkACL, LPCOLESTR p
HeapFree(GetProcessHeap(), 0, key); HeapFree(GetProcessHeap(), 0, key);
} }
if ((pwszQuickComplete) && (!quickComplete)) { if ((pwszQuickComplete) && (!quickComplete))
{
quickComplete = (WCHAR *)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, (wcslen(pwszQuickComplete) + 1) * sizeof(WCHAR)); quickComplete = (WCHAR *)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, (wcslen(pwszQuickComplete) + 1) * sizeof(WCHAR));
wcscpy(quickComplete, pwszQuickComplete); wcscpy(quickComplete, pwszQuickComplete);
} }
@ -205,29 +222,39 @@ LRESULT APIENTRY CAutoComplete::ACEditSubclassProc(HWND hwnd, UINT uMsg, WPARAM
BOOL control, filled, displayall = FALSE; BOOL control, filled, displayall = FALSE;
int cpt, height, sel; int cpt, height, sel;
if (!pThis->enabled) return CallWindowProcW(pThis->wpOrigEditProc, hwnd, uMsg, wParam, lParam); if (!pThis->enabled)
{
return CallWindowProcW(pThis->wpOrigEditProc, hwnd, uMsg, wParam, lParam);
}
switch (uMsg) switch (uMsg)
{ {
case CB_SHOWDROPDOWN: case CB_SHOWDROPDOWN:
{
ShowWindow(pThis->hwndListBox, SW_HIDE); ShowWindow(pThis->hwndListBox, SW_HIDE);
break; }; break;
case WM_KILLFOCUS: case WM_KILLFOCUS:
if ((pThis->options & ACO_AUTOSUGGEST) && {
((HWND)wParam != pThis->hwndListBox)) if ((pThis->options & ACO_AUTOSUGGEST) && ((HWND)wParam != pThis->hwndListBox))
{ {
ShowWindow(pThis->hwndListBox, SW_HIDE); ShowWindow(pThis->hwndListBox, SW_HIDE);
} }
break; return CallWindowProcW(pThis->wpOrigEditProc, hwnd, uMsg, wParam, lParam);
case WM_KEYUP: }; break;
case WM_KEYUP:
{
GetWindowTextW(hwnd, (LPWSTR)hwndText, 255); GetWindowTextW(hwnd, (LPWSTR)hwndText, 255);
switch(wParam) { switch(wParam)
{
case VK_RETURN: case VK_RETURN:
{
/* If quickComplete is set and control is pressed, replace the string */ /* If quickComplete is set and control is pressed, replace the string */
control = GetKeyState(VK_CONTROL) & 0x8000; control = GetKeyState(VK_CONTROL) & 0x8000;
if (control && pThis->quickComplete) { if (control && pThis->quickComplete)
{
hwndQCText = (WCHAR *)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, hwndQCText = (WCHAR *)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY,
(wcslen(pThis->quickComplete)+wcslen(hwndText))*sizeof(WCHAR)); (wcslen(pThis->quickComplete)+wcslen(hwndText))*sizeof(WCHAR));
sel = swprintf(hwndQCText, pThis->quickComplete, hwndText); sel = swprintf(hwndQCText, pThis->quickComplete, hwndText);
@ -238,11 +265,17 @@ LRESULT APIENTRY CAutoComplete::ACEditSubclassProc(HWND hwnd, UINT uMsg, WPARAM
ShowWindow(pThis->hwndListBox, SW_HIDE); ShowWindow(pThis->hwndListBox, SW_HIDE);
return 0; return 0;
}; break;
case VK_LEFT: case VK_LEFT:
case VK_RIGHT: case VK_RIGHT:
{
return 0; return 0;
}; break;
case VK_UP: case VK_UP:
case VK_DOWN: case VK_DOWN:
{
/* Two cases here : /* Two cases here :
- if the listbox is not visible, displays it - if the listbox is not visible, displays it
with all the entries if the style ACO_UPDOWNKEYDROPSLIST with all the entries if the style ACO_UPDOWNKEYDROPSLIST
@ -254,8 +287,11 @@ LRESULT APIENTRY CAutoComplete::ACEditSubclassProc(HWND hwnd, UINT uMsg, WPARAM
{ {
/* We must display all the entries */ /* We must display all the entries */
displayall = TRUE; displayall = TRUE;
} else { }
if (IsWindowVisible(pThis->hwndListBox)) { else
{
if (IsWindowVisible(pThis->hwndListBox))
{
int count; int count;
count = SendMessageW(pThis->hwndListBox, LB_GETCOUNT, 0, 0); count = SendMessageW(pThis->hwndListBox, LB_GETCOUNT, 0, 0);
@ -265,42 +301,58 @@ LRESULT APIENTRY CAutoComplete::ACEditSubclassProc(HWND hwnd, UINT uMsg, WPARAM
sel = ((sel-1)<0)?count-1:sel-1; sel = ((sel-1)<0)?count-1:sel-1;
else else
sel = ((sel+1)>= count)?-1:sel+1; sel = ((sel+1)>= count)?-1:sel+1;
SendMessageW(pThis->hwndListBox, LB_SETCURSEL, sel, 0); SendMessageW(pThis->hwndListBox, LB_SETCURSEL, sel, 0);
if (sel != -1) {
if (sel != -1)
{
WCHAR *msg; WCHAR *msg;
int len; int len;
len = SendMessageW(pThis->hwndListBox, LB_GETTEXTLEN, sel, (LPARAM)NULL); len = SendMessageW(pThis->hwndListBox, LB_GETTEXTLEN, sel, (LPARAM)NULL);
msg = (WCHAR *)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, (len + 1) * sizeof(WCHAR)); msg = (WCHAR *)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, (len + 1) * sizeof(WCHAR));
SendMessageW(pThis->hwndListBox, LB_GETTEXT, sel, (LPARAM)msg); SendMessageW(pThis->hwndListBox, LB_GETTEXT, sel, (LPARAM)msg);
SendMessageW(hwnd, WM_SETTEXT, 0, (LPARAM)msg); SendMessageW(hwnd, WM_SETTEXT, 0, (LPARAM)msg);
SendMessageW(hwnd, EM_SETSEL, wcslen(msg), wcslen(msg)); SendMessageW(hwnd, EM_SETSEL, wcslen(msg), wcslen(msg));
HeapFree(GetProcessHeap(), 0, msg); HeapFree(GetProcessHeap(), 0, msg);
} else { }
else
{
SendMessageW(hwnd, WM_SETTEXT, 0, (LPARAM)pThis->txtbackup); SendMessageW(hwnd, WM_SETTEXT, 0, (LPARAM)pThis->txtbackup);
SendMessageW(hwnd, EM_SETSEL, wcslen(pThis->txtbackup), wcslen(pThis->txtbackup)); SendMessageW(hwnd, EM_SETSEL, wcslen(pThis->txtbackup), wcslen(pThis->txtbackup));
} }
} }
return 0; return 0;
} }
break; }; break;
case VK_BACK: case VK_BACK:
case VK_DELETE: case VK_DELETE:
if ((! *hwndText) && (pThis->options & ACO_AUTOSUGGEST)) { {
if ((! *hwndText) && (pThis->options & ACO_AUTOSUGGEST))
{
ShowWindow(pThis->hwndListBox, SW_HIDE); ShowWindow(pThis->hwndListBox, SW_HIDE);
return CallWindowProcW(pThis->wpOrigEditProc, hwnd, uMsg, wParam, lParam); return CallWindowProcW(pThis->wpOrigEditProc, hwnd, uMsg, wParam, lParam);
} }
if (pThis->options & ACO_AUTOAPPEND) {
if (pThis->options & ACO_AUTOAPPEND)
{
DWORD b; DWORD b;
SendMessageW(hwnd, EM_GETSEL, (WPARAM)&b, (LPARAM)NULL); SendMessageW(hwnd, EM_GETSEL, (WPARAM)&b, (LPARAM)NULL);
if (b>1) { if (b>1)
{
hwndText[b-1] = '\0'; hwndText[b-1] = '\0';
} else { }
else
{
hwndText[0] = '\0'; hwndText[0] = '\0';
SetWindowTextW(hwnd, hwndText); SetWindowTextW(hwnd, hwndText);
} }
} }
break; }; break;
default: default:
; ;
} }
@ -318,20 +370,25 @@ LRESULT APIENTRY CAutoComplete::ACEditSubclassProc(HWND hwnd, UINT uMsg, WPARAM
pThis->enumstr->Reset(); pThis->enumstr->Reset();
filled = FALSE; filled = FALSE;
for(cpt = 0;;) {
for(cpt = 0;;)
{
hr = pThis->enumstr->Next(1, &strs, NULL); hr = pThis->enumstr->Next(1, &strs, NULL);
if (hr != S_OK) if (hr != S_OK)
break; break;
if ((LPWSTR)strstrW(strs, hwndText) == strs) { if ((LPWSTR)strstrW(strs, hwndText) == strs)
{
if (pThis->options & ACO_AUTOAPPEND) { if (pThis->options & ACO_AUTOAPPEND)
{
SetWindowTextW(hwnd, strs); SetWindowTextW(hwnd, strs);
SendMessageW(hwnd, EM_SETSEL, wcslen(hwndText), wcslen(strs)); SendMessageW(hwnd, EM_SETSEL, wcslen(hwndText), wcslen(strs));
break; break;
} }
if (pThis->options & ACO_AUTOSUGGEST) { if (pThis->options & ACO_AUTOSUGGEST)
{
SendMessageW(pThis->hwndListBox, LB_ADDSTRING, 0, (LPARAM)strs); SendMessageW(pThis->hwndListBox, LB_ADDSTRING, 0, (LPARAM)strs);
filled = TRUE; filled = TRUE;
cpt++; cpt++;
@ -339,8 +396,10 @@ LRESULT APIENTRY CAutoComplete::ACEditSubclassProc(HWND hwnd, UINT uMsg, WPARAM
} }
} }
if (pThis->options & ACO_AUTOSUGGEST) { if (pThis->options & ACO_AUTOSUGGEST)
if (filled) { {
if (filled)
{
height = SendMessageW(pThis->hwndListBox, LB_GETITEMHEIGHT, 0, 0); height = SendMessageW(pThis->hwndListBox, LB_GETITEMHEIGHT, 0, 0);
SendMessageW(pThis->hwndListBox, LB_CARETOFF, 0, 0); SendMessageW(pThis->hwndListBox, LB_CARETOFF, 0, 0);
GetWindowRect(hwnd, &r); GetWindowRect(hwnd, &r);
@ -350,14 +409,19 @@ LRESULT APIENTRY CAutoComplete::ACEditSubclassProc(HWND hwnd, UINT uMsg, WPARAM
SetWindowPos(pThis->hwndListBox, HWND_TOP, SetWindowPos(pThis->hwndListBox, HWND_TOP,
r.left, r.bottom + 1, r.right - r.left, min(height * 7, height * (cpt + 1)), r.left, r.bottom + 1, r.right - r.left, min(height * 7, height * (cpt + 1)),
SWP_SHOWWINDOW ); SWP_SHOWWINDOW );
} else { }
else
{
ShowWindow(pThis->hwndListBox, SW_HIDE); ShowWindow(pThis->hwndListBox, SW_HIDE);
} }
} }
break; }; break;
default: default:
{
return CallWindowProcW(pThis->wpOrigEditProc, hwnd, uMsg, wParam, lParam); return CallWindowProcW(pThis->wpOrigEditProc, hwnd, uMsg, wParam, lParam);
}
} }
@ -370,23 +434,33 @@ LRESULT APIENTRY CAutoComplete::ACLBoxSubclassProc(HWND hwnd, UINT uMsg, WPARAM
WCHAR *msg; WCHAR *msg;
int sel, len; int sel, len;
switch (uMsg) { switch (uMsg)
{
case WM_MOUSEMOVE: case WM_MOUSEMOVE:
{
sel = SendMessageW(hwnd, LB_ITEMFROMPOINT, 0, lParam); sel = SendMessageW(hwnd, LB_ITEMFROMPOINT, 0, lParam);
SendMessageW(hwnd, LB_SETCURSEL, (WPARAM)sel, (LPARAM)0); SendMessageW(hwnd, LB_SETCURSEL, (WPARAM)sel, (LPARAM)0);
break; }; break;
case WM_LBUTTONDOWN: case WM_LBUTTONDOWN:
{
sel = SendMessageW(hwnd, LB_GETCURSEL, 0, 0); sel = SendMessageW(hwnd, LB_GETCURSEL, 0, 0);
if (sel < 0) if (sel < 0)
break; break;
len = SendMessageW(pThis->hwndListBox, LB_GETTEXTLEN, sel, 0); len = SendMessageW(pThis->hwndListBox, LB_GETTEXTLEN, sel, 0);
msg = (WCHAR *)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, (len + 1) * sizeof(WCHAR)); msg = (WCHAR *)HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, (len + 1) * sizeof(WCHAR));
SendMessageW(hwnd, LB_GETTEXT, sel, (LPARAM)msg); SendMessageW(hwnd, LB_GETTEXT, sel, (LPARAM)msg);
SendMessageW(pThis->hwndEdit, WM_SETTEXT, 0, (LPARAM)msg); SendMessageW(pThis->hwndEdit, WM_SETTEXT, 0, (LPARAM)msg);
SendMessageW(pThis->hwndEdit, EM_SETSEL, 0, wcslen(msg)); SendMessageW(pThis->hwndEdit, EM_SETSEL, 0, wcslen(msg));
ShowWindow(hwnd, SW_HIDE); ShowWindow(hwnd, SW_HIDE);
HeapFree(GetProcessHeap(), 0, msg); HeapFree(GetProcessHeap(), 0, msg);
break;
}; break;
default: default:
return CallWindowProcW(pThis->wpOrigLBoxProc, hwnd, uMsg, wParam, lParam); return CallWindowProcW(pThis->wpOrigLBoxProc, hwnd, uMsg, wParam, lParam);
} }