public void PutBackgroundWindowBehindSelectedWindow(SelectedWindow selWindow)
        {
            IntPtr selWindowHandle = selWindow.hWnd;

            if (!Window.IsWindow(selWindowHandle))
            {
                this.Hide();
                return;
            }

            IntPtr windowBelow            = Window.GetWindowBelowGivenWindow(selWindowHandle);
            IntPtr backgroundWindowHandle = this.Handle;

            if (windowBelow != backgroundWindowHandle)
            {
                bool success = Window.SetWindowBelowGivenWindow(backgroundWindowHandle, selWindowHandle);
            }
        }
        public void UpdateFormBackgroundColor(SelectedWindow selWindow)
        {
            if (selWindow == null || Globals.BackgroundColor == Color.Transparent || Globals.BackgroundColor.IsEmpty)
            {
                this.Visible = false;
                return;
            }

            PutBackgroundWindowBehindSelectedWindow(selWindow);

            if (this.BackColor != Globals.BackgroundColor)
            {
                this.BackColor = Globals.BackgroundColor;
            }

            SelectedWindow.RECT rect = new SelectedWindow.RECT();
            if (SelectedWindow.GetWindowRect(selWindow.hWnd, out rect))
            {
                Point correctLocation = new Point(rect.X, rect.Y);
                if (this.Location != correctLocation)
                {
                    this.Location = correctLocation;
                }

                Size correctSize = new Size(rect.Width - rect.X, rect.Height - rect.Y);
                if (this.Size != correctSize)
                {
                    this.Size = correctSize;
                }

                if (!this.Visible)
                {
                    this.Visible = true;
                }
            }
        }
示例#3
0
 public void SetSelWin(IntPtr hWnd)
 {
     MySelectedWindow = new SelectedWindow(hWnd);
 }