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:
wj32
2010-09-11 03:47:37 +00:00
parent d1005d11a4
commit bc1f143a02
2 changed files with 16 additions and 13 deletions
+6 -1
View File
@@ -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;
+10 -12
View File
@@ -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);
}