Skip to content

Commit efd9777

Browse files
committed
Add ctrl+backspace to searchbox winsiderss#1014
1 parent c64fdab commit efd9777

File tree

1 file changed

+50
-1
lines changed

1 file changed

+50
-1
lines changed

ProcessHacker/searchbox.c

Lines changed: 50 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -678,7 +678,7 @@ LRESULT CALLBACK PhpSearchWndSubclassProc(
678678
if (
679679
PhIsNullOrEmptyString(context->CueBannerText) ||
680680
GetFocus() == hWnd ||
681-
Edit_GetTextLength(hWnd) > 0
681+
CallWindowProc(oldWndProc, hWnd, WM_GETTEXTLENGTH, 0, 0) > 0 // Edit_GetTextLength
682682
)
683683
{
684684
return CallWindowProc(oldWndProc, hWnd, uMsg, wParam, lParam);
@@ -740,6 +740,55 @@ LRESULT CALLBACK PhpSearchWndSubclassProc(
740740
return DefWindowProc(hWnd, uMsg, wParam, lParam);
741741
}
742742
break;
743+
case WM_KEYDOWN:
744+
{
745+
// Delete previous word for ctrl+backspace (thanks to Katayama Hirofumi MZ) (modified) (dmex)
746+
if (wParam == VK_BACK && GetAsyncKeyState(VK_CONTROL) < 0)
747+
{
748+
UINT textStart = 0;
749+
UINT textEnd = 0;
750+
UINT textLength;
751+
752+
textLength = (UINT)CallWindowProc(oldWndProc, hWnd, WM_GETTEXTLENGTH, 0, 0);
753+
CallWindowProc(oldWndProc, hWnd, EM_GETSEL, (WPARAM)&textStart, (LPARAM)&textEnd);
754+
755+
if (textLength > 0 && textStart == textEnd)
756+
{
757+
PWSTR textBuffer;
758+
759+
textBuffer = PhAllocateZero((textLength + 1) * sizeof(WCHAR));
760+
GetWindowText(hWnd, textBuffer, textLength);
761+
762+
for (; 0 < textStart; --textStart)
763+
{
764+
if (textBuffer[textStart - 1] == L' ' && iswalnum(textBuffer[textStart]))
765+
{
766+
CallWindowProc(oldWndProc, hWnd, EM_SETSEL, textStart, textEnd);
767+
CallWindowProc(oldWndProc, hWnd, EM_REPLACESEL, TRUE, (LPARAM)L"");
768+
PhFree(textBuffer);
769+
return 1;
770+
}
771+
}
772+
773+
if (textStart == 0)
774+
{
775+
SetWindowText(hWnd, L"");
776+
PhFree(textBuffer);
777+
return 1;
778+
}
779+
780+
PhFree(textBuffer);
781+
}
782+
}
783+
}
784+
break;
785+
case WM_CHAR:
786+
{
787+
// Delete previous word for ctrl+backspace (dmex)
788+
if (wParam == VK_F16 && GetAsyncKeyState(VK_CONTROL) < 0)
789+
return 1;
790+
}
791+
break;
743792
}
744793

745794
return CallWindowProc(oldWndProc, hWnd, uMsg, wParam, lParam);

0 commit comments

Comments
 (0)