Example #1
0
        public void SetWindowHandle(IntPtr hWnd)
        {
            this.hWnd = hWnd;

            WinApi.RECT rect = WinApi.GetWindowRect(hWnd).Value;

            this.x.Value = rect.left;
            this.y.Value = rect.top;
            this.w.Value = rect.right - rect.left;
            this.h.Value = rect.bottom - rect.top;
        }
Example #2
0
        private bool WindowEnum(IntPtr hWnd, IntPtr data)
        {
            if (WinApi.GetParent(hWnd) != IntPtr.Zero)
            {
                return(true);
            }

            WinApi.RECT  rect = WinApi.GetWindowRect(hWnd).Value;
            bool         hung = WinApi.IsHungAppWindow(hWnd);
            ListViewItem item = new ListViewItem(WinApi.GetWindowText(hWnd));

            if (!hung)
            {
                IntPtr hIcon;
                if (((hIcon = WinApi.SendMessage(hWnd, WinApi.WM_GETICON, WinApi.ICON_SMALL, IntPtr.Zero)) != IntPtr.Zero) ||
                    ((hIcon = WinApi.SendMessage(hWnd, WinApi.WM_GETICON, WinApi.ICON_BIG, IntPtr.Zero)) != IntPtr.Zero) ||
                    ((hIcon = WinApi.SendMessage(hWnd, WinApi.WM_GETICON, WinApi.ICON_SMALL2, IntPtr.Zero)) != IntPtr.Zero) ||
                    ((hIcon = WinApi.GetClassLongPtr(hWnd, WinApi.GCLP_HICONSM)) != IntPtr.Zero) ||
                    ((hIcon = WinApi.GetClassLongPtr(hWnd, WinApi.GCLP_HICON)) != IntPtr.Zero))
                {
                    item.ImageIndex = this.imgList.Images.Count;
                    this.imgList.Images.Add(System.Drawing.Icon.FromHandle(hIcon));
                }
            }

            item.Tag = hWnd;

            item.SubItems.Add(hung.ToString());
            item.SubItems.Add(WinApi.IsWindowVisible(hWnd).ToString());
            item.SubItems.Add(WinApi.GetClassName(hWnd));
            item.SubItems.Add(WinApi.GetModuleFileName(hWnd));
            item.SubItems.Add("(" + rect.left + ", " + rect.top + ")");
            item.SubItems.Add("[" + (rect.right - rect.left) + " x " + (rect.bottom - rect.top) + "]");

            list.Items.Add(item);
            if (list.Items.Count % 50 == 0)
            {
                list.Update();
            }

            return(true);
        }