public WindowTreeNode AddWindow(IntPtr hwnd) { WindowTreeNode node; if (!hwndNodeMap.ContainsKey(hwnd)) { node = new WindowTreeNode(hwnd); IntPtr hwndParent = UnmanagedMethods.GetParent(hwnd); if (hwndParent == IntPtr.Zero) { rootNode.Nodes.Add(node); } else { WindowTreeNode parentNode = AddWindow(hwndParent); parentNode.Nodes.Add(node); } hwndNodeMap[hwnd] = node; } else { node = (WindowTreeNode)hwndNodeMap[hwnd]; } return(node); }
public WindowTreeNode AddWindow(IntPtr hwnd) { WindowTreeNode node; if (!hwndNodeMap.ContainsKey(hwnd)) { node = new WindowTreeNode(hwnd); IntPtr hwndParent = UnmanagedMethods.GetParent(hwnd); if (hwndParent == IntPtr.Zero) { rootNode.Nodes.Add(node); } else { WindowTreeNode parentNode = AddWindow(hwndParent); parentNode.Nodes.Add(node); } hwndNodeMap[hwnd] = node; } else { node = (WindowTreeNode)hwndNodeMap[hwnd]; } return node; }
public void RemoveNode(IntPtr hwnd) { WindowTreeNode node = (WindowTreeNode)hwndNodeMap[hwnd]; if (node != null) { hwndNodeMap.Remove(hwnd); node.Remove(); } }
private void details_Click(object sender, System.EventArgs e) { WindowTreeNode node = (WindowTreeNode)windowTree.SelectedNode; WindowPropertiesForm propForm = new WindowPropertiesForm(); propForm.TargetWindowHandle = node.Hwnd; FormSizeSaver saver = new FormSizeSaver(propForm); propForm.ShowDialog(); }
public bool HasManagedChild(WindowTreeNode parentNode) { bool ret = false; foreach (WindowTreeNode node in parentNode.Nodes) { if (node.IsManaged || HasManagedChild(node)) { ret = true; break; } } return(ret); }
public void FilterUnmanagedWindows(WindowTreeNode parentNode) { for (int i = 0; i < parentNode.Nodes.Count; i++) { WindowTreeNode node = (WindowTreeNode)parentNode.Nodes[i]; if (!node.IsManaged && !HasManagedChild(node)) { parentNode.Nodes.RemoveAt(i); i--; } else { FilterUnmanagedWindows(node); } } }
public void FilterUnmanagedWindows(WindowTreeNode parentNode) { for(int i = 0; i < parentNode.Nodes.Count; i++) { WindowTreeNode node = (WindowTreeNode)parentNode.Nodes[i]; if (!node.IsManaged && !HasManagedChild(node)) { parentNode.Nodes.RemoveAt(i); i--; } else { FilterUnmanagedWindows(node); } } }
public void Expand() { if (previousWindowTreeBuilder != null) { foreach (DictionaryEntry entry in previousWindowTreeBuilder.hwndNodeMap) { if (hwndNodeMap.ContainsKey(entry.Key)) { WindowTreeNode oldWindowTreeNode = (WindowTreeNode)entry.Value; if (oldWindowTreeNode.IsExpanded) { WindowTreeNode newWindowTreeNode = (WindowTreeNode)hwndNodeMap[entry.Key]; newWindowTreeNode.Expand(); } } } } RootNode.Expand(); }
public bool HasManagedChild(WindowTreeNode parentNode) { bool ret = false; foreach(WindowTreeNode node in parentNode.Nodes) { if (node.IsManaged || HasManagedChild(node)) { ret = true; break; } } return ret; }