/// <summary> Event handler. Called by RenderForm for load events.</summary> /// <remarks> Nesox, 2013-12-27.</remarks> /// <param name="sender"> Source of the event. </param> /// <param name="e"> Event information. </param> private void RenderForm_Load(object sender, EventArgs e) { if (_thSetWindowTarget == null) { _thSetWindowTarget = new Thread(SetWindowToTarget) { IsBackground = true, Name = "SetWindowTargetThread" }; _thSetWindowTarget.Start(new Tuple <IntPtr, IntPtr>(Handle, _hwndTrackedWindow)); } //Make the window's border completely transparant Imports.SetWindowLong(Handle, Constants.GWL_EXSTYLE, (IntPtr)(Imports.GetWindowLong(Handle, Constants.GWL_EXSTYLE) ^ Constants.WS_EX_LAYERED ^ Constants.WS_EX_TRANSPARENT)); Imports.SetLayeredWindowAttributes(Handle, 0, 0, Constants.LWA_ALPHA); Imports.SetLayeredWindowAttributes(Handle, 0, 0, Constants.LWA_COLORKEY); // Make sure we set the Height/Width of the window before initialize the present parameters for the device. Rect targetWindowRect; Imports.GetWindowRect(_hwndTrackedWindow, out targetWindowRect); Width = targetWindowRect.Right - targetWindowRect.Left; Height = targetWindowRect.Bottom - targetWindowRect.Top; // Expand the Aero Glass Effect Border to the WHOLE form. // since we have already had the border invisible we now // have a completely invisible window - apart from the DirectX // renders NOT in black. Margins marg = new Margins { Left = 0, Top = 0, Right = Width, Bottom = Height }; Imports.DwmExtendFrameIntoClientArea(Handle, ref marg); OverlayManager.InitializeD3D(this); OverlayManager.InitializeRenderThread(); }