/// <summary> /// Makes a transparent window which adjust it's size and position to fit the parent window /// </summary> /// <param name="parent">HWND/Handle of a window</param> public OverlayWindow(IntPtr parent, bool limitFPS = true) { if (parent == IntPtr.Zero) { throw new Exception("The handle of the parent window isn't valid"); } RECT bounds; NativeMethods.GetWindowRect(parent, out bounds); IsDisposing = false; IsVisible = true; IsTopMost = true; ParentWindowExists = true; X = bounds.Left; Y = bounds.Top; Width = bounds.Right - bounds.Left; Height = bounds.Bottom - bounds.Top; ParentWindow = parent; if (!CreateWindow()) { throw new Exception("Could not create OverlayWindow"); } Graphics = new Direct2DRenderer(Handle, limitFPS); SetBounds(X, Y, Width, Height); new Task(new Action(ParentServiceThread)).Start(); }
/// <summary> /// Makes a transparent Fullscreen window /// </summary> public OverlayWindow(bool limitFPS = true) { IsDisposing = false; IsVisible = true; IsTopMost = true; ParentWindowExists = false; X = 0; Y = 0; Width = NativeMethods.GetSystemMetrics(WindowConstants.SM_CX_SCREEN); Height = NativeMethods.GetSystemMetrics(WindowConstants.SM_CY_SCREEN); ParentWindow = IntPtr.Zero; if (!CreateWindow()) { throw new Exception("Could not create OverlayWindow"); } Graphics = new Direct2DRenderer(Handle, limitFPS); SetBounds(X, Y, Width, Height); }