Beispiel #1
0
        public static 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);
                }
            }
        }
Beispiel #2
0
 private void SetWindowTreeNodeImage(ImageList imageList, WindowTreeNode node)
 {
     this.SetNodeImage(imageList, node);
     if (node.Nodes.Count > 0)
     {
         foreach (WindowTreeNode subNode in node.Nodes)
         {
             this.SetWindowTreeNodeImage(imageList, subNode);
         }
     }
 }
Beispiel #3
0
 private void SetNodeImage(ImageList imageList, WindowTreeNode node)
 {
     IntPtr hIcon = NativeMethods.GetClassLongPtr(node.Hwnd, NativeMethods.GCLP_HICON);
     if (IntPtr.Zero == hIcon)
     {
         if (node.IsManaged)
         {
             imageList.Images.Add(node.Hwnd.ToString(), Resources.DotNetWindow);
         }
         else
         {
             imageList.Images.Add(node.Hwnd.ToString(), Resources.Window);
         }
     }
     else
     {
         Icon icon = Icon.FromHandle(hIcon);
         if (null == icon)
         {
             hIcon = NativeMethods.SendMessage(
                 node.Hwnd,
                 NativeMethods.WM_GETICON,
                 new IntPtr(NativeMethods.ICON_BIG),
                 IntPtr.Zero);
         }
         if (null != icon)
         {
             imageList.Images.Add(node.Hwnd.ToString(), icon);
         }
     }
     node.ImageKey = node.Hwnd.ToString();
     node.SelectedImageKey = node.Hwnd.ToString();
     node.StateImageKey = node.Hwnd.ToString();
 }
Beispiel #4
0
        public bool HasManagedChild(WindowTreeNode parentNode)
        {
            bool ret = false;

            foreach(WindowTreeNode node in parentNode.Nodes)
            {
                if (node.IsManaged || HasManagedChild(node))
                {
                    ret = true;
                    break;
                }
            }

            return ret;
        }
Beispiel #5
0
        private WindowTreeNode AddWindowNode(WindowTreeNode node)
        {
            IntPtr hwndParent = NativeMethods.GetParent(node.Hwnd);
            if (hwndNodeMap.ContainsKey(hwndParent))
            {
                WindowTreeNode parentNode = (WindowTreeNode)hwndNodeMap[hwndParent];
                if (parentNode != null) parentNode.Nodes.Add(node);
            }
            else
            {
                this.RootNode.Nodes.Add(node);
            }

            return node;
        }
Beispiel #6
0
        private WindowTreeNode AddWindow(IntPtr hwnd, bool isManaged)
        {
            WindowTreeNode node = new WindowTreeNode(hwnd, isManaged);
            if (!isManaged)
            {
                NativeWindow native = new NativeWindow();
                native.Handle = hwnd;
                native.ClassName = node.WindowClassName;
                native.Text = node.WindowText;

                node.Tag = native;
            }

            if (!hwndNodeMap.ContainsKey(hwnd)) hwndNodeMap[hwnd] = node;

            return node;
        }