コード例 #1
0
        public static string GetWindowTitle(IntPtr hWnd)
        {
            StringBuilder strbTitle = new StringBuilder(255);
            int           nLength   = WinUtils.GetWindowText(hWnd, strbTitle, strbTitle.Capacity + 1);
            string        strTitle  = strbTitle.ToString();

            return(strTitle);
        }
コード例 #2
0
 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);
 }
コード例 #3
0
        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);
        }
コード例 #4
0
 public ImageSource GetWindowImage(IntPtr hWnd, FormsDraw.Rectangle bounds)
 {
     using (FormsDraw.Bitmap result = new FormsDraw.Bitmap(bounds.Width, bounds.Height))
     {                                  //creates a new Bitmap which will contain the window's image
         using (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
             try
             {
                 WinUtils.PrintWindow(hWnd, dc, 0);//Writes the window's image to the HDC created above
             }
             finally
             {
                 MemG.ReleaseHdc(dc);
             }
             return(System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(result.GetHbitmap(), IntPtr.Zero, Int32Rect.Empty, BitmapSizeOptions.FromEmptyOptions()));
         }
     }
 }
コード例 #5
0
        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
        }
コード例 #6
0
        void newWindow_MouseUp(object sender, MouseButtonEventArgs e)
        {
            WinCtl win = sender as WinCtl;

            if (dragMode)
            {
                win.ReleaseMouseCapture();
                dragMode = false;
            }
            Point ex = Mouse.GetPosition(win);

            if (ex.Y <= 32)
            {
                if (ex.Y >= 6 && ex.Y <= 23)
                {
                    if (ex.X >= (win.Width - 103) && ex.X <= (win.Width - 73))
                    {
                        if (win.Width > 160 && win.Height > 26)
                        {
                            WinUtils.ShowWindow((IntPtr)win.Tag, 6);
                        }
                        else
                        {
                            WinUtils.ShowWindow((IntPtr)win.Tag, 9);
                        }
                    }
                    else if (ex.X >= (win.Width - 70) && ex.X <= (win.Width - 40))
                    {
                    }
                    else if (ex.X >= (win.Width - 37) && ex.X <= (win.Width - 7))
                    {
                        cv.Children.Remove(win);
                    }
                }
            }
        }