Exemplo n.º 1
0
 public Window(string title, string text, IntPtr hWnd, Process process, WinRect winPos, WinRect winVis)
 {
     Title          = title;
     Text           = text;
     HWnd           = hWnd;
     Process        = process;
     WindowPosition = winPos;
     WindowVisible  = winVis;
 }
Exemplo n.º 2
0
        private static WinRect[] GetWindowInfoByHwnd(IntPtr hwnd)
        {
            var  winPos = new WinRect();
            var  winVis = new WinRect();
            RECT pos;

            if (!GetWindowRect(hwnd, out pos))
            {
                throw new Exception("Error getting window rectangle");
            }
            winPos.CopyFrom(pos.ToRectangle());
            winVis.CopyFrom(pos.ToRectangle());

            var dwAttribute = 9; //DwmwaExtendedFrameBounds

            if (Environment.OSVersion.Version.Major >= 6 &&
                DwmGetWindowAttribute(hwnd, dwAttribute, out pos, Marshal.SizeOf(typeof(RECT))) == 0)
            {
                winVis.CopyFrom(pos.ToRectangle());
            }

            return(new[] { winPos, winVis });
        }