Esempio n. 1
0
        private void InitTopNodes()
        {
            tvHandles.BeginUpdate();
            tvHandles.Nodes.Clear();

            Task mainTask = new Task(() =>
            {
                List <IntPtr> topHandles;

                if (!chkUseShown.Checked)
                {
                    topHandles = WindowHandleManager.GetTopHandles();
                }
                else
                {
                    topHandles = WindowHandleManager.GetAllProcessHandles();
                }

                foreach (IntPtr handle in topHandles)
                {
                    TreeNode parentNode = null;
                    if (tvHandles.InvokeRequired)
                    {
                        tvHandles.Invoke(new Action(() => { parentNode = tvHandles.Nodes.Add(AssembleNodeText(handle)); }));
                    }

                    PopulateTreeRecursive(parentNode, handle);
                }
            });

            mainTask.Start();

            tvHandles.EndUpdate();
        }
Esempio n. 2
0
        private string AssembleNodeText(IntPtr handle)
        {
            string windowText  = WindowHandleManager.GetWindowTextWithHwnd(handle);
            string windowClass = WindowHandleManager.GetClassNameForHwnd(handle);
            string handleStr   = handle.ToString();

            windowText  = (string.IsNullOrEmpty(windowText) ? "NO TITLE" : windowText);
            windowClass = (string.IsNullOrEmpty(windowClass) ? "NO CLASSNAME" : windowClass);

            return("Handle: " + handleStr + ", Title: " + windowText + ", Class: " + windowClass);
        }
Esempio n. 3
0
        private void PopulateTreeRecursive(TreeNode parentNode, IntPtr parentHwnd)
        {
            List <IntPtr> children = WindowHandleManager.GetAllChildHandles(parentHwnd);

            foreach (IntPtr child in children)
            {
                TreeNode currentNode = null;
                if (tvHandles.InvokeRequired)
                {
                    tvHandles.Invoke(new Action(() => { currentNode = parentNode.Nodes.Add(AssembleNodeText(child)); }));
                }

                PopulateTreeRecursive(currentNode, child);
            }
        }