27 typedef struct _WINDOWS_CONTEXT
35 HWND HighlightingWindow;
36 ULONG HighlightingWindowCount;
50 static RECT MinimumSize = { -1, -1, -1, -1 };
53 _In_ HWND ParentWindowHandle,
73 hwnd = CreateDialogParam(
80 ShowWindow(hwnd, SW_SHOW);
87 switch (Selector->Type)
103 hwnd = Node->WindowHandle;
105 GetClassName(hwnd, Node->WindowClass,
sizeof(Node->WindowClass) /
sizeof(WCHAR));
108 if (!Node->WindowText)
111 threadId = GetWindowThreadProcessId(hwnd, &processId);
112 Node->ClientId.UniqueProcess = UlongToHandle(processId);
113 Node->ClientId.UniqueThread = UlongToHandle(threadId);
115 Node->WindowVisible = !!IsWindowVisible(hwnd);
116 Node->HasChildren = !!FindWindowEx(hwnd, NULL, NULL, NULL);
136 childNode->
Parent = ParentNode;
150 _In_opt_ HANDLE FilterProcessId,
151 _In_opt_ HANDLE FilterThreadId
154 HWND childWindow = NULL;
159 while (i < 0x800 && (childWindow = FindWindowEx(hwnd, childWindow, NULL, NULL)))
164 threadId = GetWindowThreadProcessId(childWindow, &processId);
167 (!FilterProcessId || UlongToHandle(processId) == FilterProcessId) &&
168 (!FilterThreadId || UlongToHandle(threadId) == FilterThreadId)
192 _In_ PWSTR DesktopName
197 if (desktopHandle = OpenDesktop(DesktopName, 0,
FALSE, DESKTOP_ENUMERATE))
200 CloseDesktop(desktopHandle);
212 switch (Context->Selector.Type)
222 PhAddItemList(Context->TreeContext.NodeRootList, desktopNode);
232 WepAddChildWindows(Context, NULL, GetDesktopWindow(), NULL, Context->Selector.Thread.ThreadId);
237 WepAddChildWindows(Context, NULL, GetDesktopWindow(), Context->Selector.Process.ProcessId, NULL);
258 switch (Selector->Type)
267 return PhFormatString(L
"Windows - Thread %lu", HandleToUlong(Selector->Thread.ThreadId));
284 return PhFormatString(L
"Windows - Desktop \"%s\"", Selector->Desktop.DesktopName->Buffer);
301 if (uMsg == WM_INITDIALOG)
304 SetProp(hwndDlg, L
"Context", (HANDLE)context);
310 if (uMsg == WM_DESTROY)
311 RemoveProp(hwndDlg, L
"Context");
324 context->TreeNewHandle = GetDlgItem(hwndDlg,
IDC_LIST);
332 if (MinimumSize.left == -1)
340 MapDialogRect(hwndDlg, &rect);
342 MinimumSize.left = 0;
351 MoveWindow(hwndDlg, windowRectangle.
Left, windowRectangle.
Top,
355 windowRectangle.
Left += 20;
356 windowRectangle.
Top += 20;
360 SetWindowText(hwndDlg, windowTitle->
Buffer);
380 switch (LOWORD(wParam))
384 DestroyWindow(hwndDlg);
393 ULONG numberOfWindows;
396 point.x = (SHORT)LOWORD(lParam);
397 point.y = (SHORT)HIWORD(lParam);
400 &context->TreeContext,
405 if (numberOfWindows != 0)
411 if (numberOfWindows == 1)
413 WINDOWPLACEMENT placement = {
sizeof(placement) };
421 GetWindowPlacement(windows[0]->WindowHandle, &placement);
423 if (placement.showCmd == SW_MINIMIZE)
425 else if (placement.showCmd == SW_MAXIMIZE)
427 else if (placement.showCmd == SW_NORMAL)
433 (GetWindowLong(windows[0]->WindowHandle, GWL_STYLE) & WS_VISIBLE) ?
PH_EMENU_CHECKED : 0);
438 !(GetWindowLong(windows[0]->WindowHandle, GWL_STYLE) & WS_DISABLED) ? PH_EMENU_CHECKED : 0);
443 (GetWindowLong(windows[0]->WindowHandle, GWL_EXSTYLE) & WS_EX_TOPMOST) ? PH_EMENU_CHECKED : 0);
447 if (GetLayeredWindowAttributes(windows[0]->WindowHandle, NULL, &alpha, &flags))
449 if (!(flags & LWA_ALPHA))
466 for (i = 0; i < 10; i++)
468 if (alpha == (BYTE)(255 * (i + 1) / 10))
499 WINDOWPLACEMENT placement = {
sizeof(placement) };
501 GetWindowPlacement(selectedNode->
WindowHandle, &placement);
503 if (placement.showCmd == SW_MINIMIZE)
504 ShowWindowAsync(selectedNode->
WindowHandle, SW_RESTORE);
516 ShowWindowAsync(selectedNode->
WindowHandle, SW_RESTORE);
526 ShowWindowAsync(selectedNode->
WindowHandle, SW_MINIMIZE);
536 ShowWindowAsync(selectedNode->
WindowHandle, SW_MAXIMIZE);
546 PostMessage(selectedNode->
WindowHandle, WM_CLOSE, 0, 0);
590 topMost = GetWindowLong(selectedNode->
WindowHandle, GWL_EXSTYLE) & WS_EX_TOPMOST;
591 SetWindowPos(selectedNode->
WindowHandle, topMost ? HWND_NOTOPMOST : HWND_TOPMOST,
592 0, 0, 0, 0, SWP_NOACTIVATE | SWP_NOMOVE | SWP_NOSIZE);
619 RedrawWindow(selectedNode->
WindowHandle, NULL, NULL, RDW_ERASE | RDW_INVALIDATE | RDW_FRAME | RDW_ALLCHILDREN);
625 SetLayeredWindowAttributes(selectedNode->
WindowHandle, 0, (BYTE)(255 * opacity / 10), LWA_ALPHA);
636 if (context->HighlightingWindow)
638 if (context->HighlightingWindowCount & 1)
642 context->HighlightingWindow = selectedNode->
WindowHandle;
643 context->HighlightingWindowCount = 10;
644 SetTimer(hwndDlg, 9, 100, NULL);
669 PhShowError(hwndDlg, L
"The process does not exist.");
702 if (--context->HighlightingWindowCount == 0)
703 KillTimer(hwndDlg, 9);