mirror of
https://github.com/mirror/processhacker
synced 2026-06-08 16:03:24 +00:00
improved window finding algorithm
git-svn-id: svn://svn.code.sf.net/p/processhacker/code@3594 21ef857c-d57f-4fe0-8362-d861dc6d29cd
This commit is contained in:
@@ -3201,13 +3201,18 @@ BOOL CALLBACK PhpEnumProcessWindowsProc(
|
||||
)
|
||||
{
|
||||
ULONG processId;
|
||||
HWND parentWindow;
|
||||
|
||||
if (!IsWindowVisible(hwnd))
|
||||
return TRUE;
|
||||
|
||||
GetWindowThreadProcessId(hwnd, &processId);
|
||||
|
||||
if (processId == (ULONG)lParam)
|
||||
if (
|
||||
processId == (ULONG)lParam &&
|
||||
!((parentWindow = GetParent(hwnd)) && IsWindowVisible(parentWindow)) && // skip windows with a visible parent
|
||||
GetWindowTextLength(hwnd) != 0
|
||||
)
|
||||
{
|
||||
SelectedProcessWindowHandle = hwnd;
|
||||
return FALSE;
|
||||
|
||||
@@ -572,6 +572,15 @@ BOOL CALLBACK PhpEnumProcessNodeWindowsProc(
|
||||
|
||||
if (UlongToHandle(processId) == processNode->ProcessId)
|
||||
{
|
||||
HWND parentWindow;
|
||||
|
||||
if (
|
||||
!IsWindowVisible(hwnd) || // skip invisible windows
|
||||
((parentWindow = GetParent(hwnd)) && IsWindowVisible(parentWindow)) || // skip windows with visible parents
|
||||
GetWindowTextLength(hwnd) == 0 // skip windows with no title
|
||||
)
|
||||
return TRUE;
|
||||
|
||||
processNode->WindowHandle = hwnd;
|
||||
return FALSE;
|
||||
}
|
||||
@@ -592,18 +601,7 @@ VOID PhpUpdateProcessNodeWindow(
|
||||
|
||||
if (ProcessNode->WindowHandle)
|
||||
{
|
||||
ProcessNode->WindowText = PhCreateStringEx(NULL, 128);
|
||||
|
||||
if (InternalGetWindowText(ProcessNode->WindowHandle,
|
||||
ProcessNode->WindowText->Buffer, ProcessNode->WindowText->Length / sizeof(WCHAR)) != 0)
|
||||
{
|
||||
PhTrimToNullTerminatorString(ProcessNode->WindowText);
|
||||
}
|
||||
else
|
||||
{
|
||||
PhSwapReference(&ProcessNode->WindowText, NULL);
|
||||
}
|
||||
|
||||
ProcessNode->WindowText = PhGetWindowText(ProcessNode->WindowHandle);
|
||||
ProcessNode->WindowHung = !!IsHungAppWindow(ProcessNode->WindowHandle);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user