public void TimerTick(object sender, EventArgs e) { WinUtils.Rect rect = new WinUtils.Rect(); WinUtils.GetWindowRect((IntPtr)this.Tag, ref rect); WinBounds = new FormsDraw.Rectangle(rect.Left, rect.Top, rect.Right - rect.Left, rect.Bottom - rect.Top); this.Width = WinBounds.Width; this.Height = WinBounds.Height; this.Source = GetWindowImage((IntPtr)this.Tag, WinBounds); }
public void AddWindow(IntPtr hWnd) { WinUtils.Rect rect = new WinUtils.Rect(); WinUtils.GetWindowRect(hWnd, ref rect); WinCtl newWindow = new WinCtl(hWnd, rect); newWindow.MouseDown += newWindow_MouseDown; newWindow.MouseUp += newWindow_MouseUp; newWindow.MouseMove += newWindow_MouseMove; cv.Children.Add(newWindow); }
public WinCtl(IntPtr hwin, WinUtils.Rect rect) { //InitializeComponent(); this.Tag = hwin; WinBounds = new FormsDraw.Rectangle(rect.Left, rect.Top, rect.Right - rect.Left, rect.Bottom - rect.Top); Title = GetWindowTitle(hwin); this.Width = WinBounds.Width; this.Height = WinBounds.Height; this.Source = GetWindowImage(hwin, WinBounds); DispatcherTimer dt = new DispatcherTimer(TimeSpan.FromMilliseconds(200), DispatcherPriority.Render, new EventHandler(TimerTick), this.Dispatcher); dt.Start(); }
public void MakeWindow(IntPtr hWnd) { Image window = new Image(); window.Width = 240; window.Height = 240; window.Stretch = Stretch.Fill; WinUtils.Rect rect = new WinUtils.Rect(); //makes a new Rect which will hold the target window size WinUtils.GetWindowRect(hWnd, ref rect); //gets the target window size FormsDraw.Rectangle bounds = new FormsDraw.Rectangle(rect.Left, rect.Top, rect.Right - rect.Left, rect.Bottom - rect.Top); //converts the rect into something usable FormsDraw.Bitmap result = new FormsDraw.Bitmap(bounds.Width, bounds.Height); //creates a new Bitmap which will contain the window's image FormsDraw.Graphics MemG = FormsDraw.Graphics.FromImage(result); //makes a Graphics from the Bitmap whose HDC will hold the window's RAW image IntPtr dc = MemG.GetHdc(); //gets the Bitmap's HDC WinUtils.PrintWindow(hWnd, dc, 0); //Writes the window's image to the HDC created above MemG.ReleaseHdc(dc); window.Source = WinUtils.ImageSourceFromBitmap(result); WinMgr.Children.Add(window);//adds the PB to the FlowLayoutPanel }