public void adjustHandleSizeToTargetWindow()
 {
     if (AutoResize.@checked())
     {
         HijackedHandle.window_Move(0, 0, HijackedWindow.width(), HijackedWindow.height());
     }
 }
 public Win32_Handle_Hijack screenShot()
 {
     restore();
     try
     {
         var handle = TargetHandle.get_Text().toInt().intPtr();
         var bitmap = handle.window_ScreenShot();
         HijackedWindow.clear().add_PictureBox().layout_Zoom().show(bitmap);
     }
     catch (Exception ex)
     {
         ex.log();
     }
     return(this);
 }
        public Win32_Handle_Hijack hijack()
        {
            restore();
            var handle    = TargetHandle.get_Text().toInt().intPtr();
            var newParent = HijackedWindow.clear().handle();

            "Hijacking {0} into window {1}".info(handle, newParent);
            HijackedHandle = handle;

            WinAPI.GetWindowRect(handle, ref HijackedHandleRECT);
            HijackedParent = ParentHandle.get_Text().toInt().intPtr();
            handle.setParent(newParent);

            adjustHandleSizeToTargetWindow();
            return(this);
        }
        public Win32_Handle_Hijack toolStrip_HideShow()
        {
            var groupBox       = HijackedWindow.parent();;
            var splitcontainer = groupBox.splitContainer();

            var collapsed = splitcontainer.Panel1Collapsed;

            if (collapsed)
            {
                splitcontainer.panel1Collapsed(false);
                groupBox.set_Text(GroupBoxText);
            }
            else
            {
                splitcontainer.panel1Collapsed(true);
                groupBox.set_Text(".");
            }
            return(this);
        }
        public Win32_Handle_Hijack buildGui()
        {
            TopPanel = this.add_Panel();
            createToolStrip();

            HijackedWindow = TopPanel.add_GroupBox(GroupBoxText).add_Panel();

            var groupBox = HijackedWindow.parent();;

            GroupBoxText = groupBox.get_Text();

            groupBox.DoubleClick += (sender, e) => toolStrip_HideShow();

            //do this on a seprate thread because the parentForm will be null at this stage (since this is a Control)
            O2Thread.mtaThread(
                () => {
                1000.sleep();
                this.parentForm().onClosed(
                    () => {
                    restore();
                });
            });
            return(this);
        }