mirror of
https://github.com/reactos/reactos.git
synced 2025-08-05 17:42:58 +00:00
[BROWSEUI] Fix Edit_BackWord function (#3247)
Fix and improve Edit_BackWord function (for Ctrl+Back key combination on auto-completion in edit boxes) by using GetStringTypeW. CORE-1419
This commit is contained in:
parent
a822eadce6
commit
e1a01de7f7
1 changed files with 13 additions and 17 deletions
|
@ -287,32 +287,30 @@ static void Edit_BackWord(HWND hwndEdit)
|
||||||
iStart = iEnd = 0;
|
iStart = iEnd = 0;
|
||||||
SendMessageW(hwndEdit, EM_GETSEL, (WPARAM)&iStart, (LPARAM)&iEnd);
|
SendMessageW(hwndEdit, EM_GETSEL, (WPARAM)&iStart, (LPARAM)&iEnd);
|
||||||
|
|
||||||
if (iStart != iEnd)
|
if (iStart != iEnd || iStart < 0)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
DWORD cchText = GetWindowTextLengthW(hwndEdit);
|
size_t cchText = GetWindowTextLengthW(hwndEdit);
|
||||||
size_t cb = (cchText + 1) * sizeof(WCHAR);
|
if (cchText < (size_t)iStart || (INT)cchText <= 0)
|
||||||
LPWSTR pszText = (LPWSTR)CoTaskMemAlloc(cb);
|
return;
|
||||||
if (pszText == NULL)
|
|
||||||
|
CComHeapPtr<WCHAR> pszText;
|
||||||
|
if (!pszText.Allocate(cchText + 1))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if (GetWindowTextW(hwndEdit, pszText, cchText + 1) <= 0)
|
if (GetWindowTextW(hwndEdit, pszText, cchText + 1) <= 0)
|
||||||
{
|
|
||||||
CoTaskMemFree(pszText);
|
|
||||||
return;
|
return;
|
||||||
}
|
|
||||||
|
|
||||||
for (; 0 < iStart; --iStart)
|
WORD types[2];
|
||||||
|
for (--iStart; 0 < iStart; --iStart)
|
||||||
{
|
{
|
||||||
WCHAR ch1 = pszText[iStart - 1];
|
GetStringTypeW(CT_CTYPE1, &pszText[iStart - 1], 2, types);
|
||||||
WCHAR ch2 = pszText[iStart];
|
if (((types[0] & C1_PUNCT) && !(types[1] & C1_SPACE)) ||
|
||||||
if ((wcschr(L"\\/.:;", ch1) && ch2 && !IsCharSpaceW(ch2)) ||
|
((types[0] & C1_SPACE) && (types[1] & (C1_ALPHA | C1_DIGIT))))
|
||||||
(IsCharSpaceW(ch1) && IsCharAlphaNumericW(ch2)))
|
|
||||||
{
|
{
|
||||||
SendMessageW(hwndEdit, EM_SETSEL, iStart, iEnd);
|
SendMessageW(hwndEdit, EM_SETSEL, iStart, iEnd);
|
||||||
SendMessageW(hwndEdit, EM_REPLACESEL, TRUE, (LPARAM)L"");
|
SendMessageW(hwndEdit, EM_REPLACESEL, TRUE, (LPARAM)L"");
|
||||||
iStart = -1;
|
return;
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -321,8 +319,6 @@ static void Edit_BackWord(HWND hwndEdit)
|
||||||
SendMessageW(hwndEdit, EM_SETSEL, iStart, iEnd);
|
SendMessageW(hwndEdit, EM_SETSEL, iStart, iEnd);
|
||||||
SendMessageW(hwndEdit, EM_REPLACESEL, TRUE, (LPARAM)L"");
|
SendMessageW(hwndEdit, EM_REPLACESEL, TRUE, (LPARAM)L"");
|
||||||
}
|
}
|
||||||
|
|
||||||
CoTaskMemFree(pszText);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue