示例#1
0
 public static Bitmap CaptureWindowImage(IntPtr hWnd)
 {
     if (hWnd != IntPtr.Zero)
     {
         IntPtr hImg = WinUtil.CaptureWindow(hWnd);
         if (hImg != IntPtr.Zero)
         {
             Bitmap bmp = Image.FromHbitmap(hImg);
             WinUtil.DeleteObject(hImg);
             return(bmp);
         }
     }
     return(null);
 }
 protected override void OnClosing(System.ComponentModel.CancelEventArgs e)
 {
     base.OnClosing(e);
     if (!e.Cancel)
     {
         _rcEnd = this.Bounds;
         try
         {
             if (_closeBitmap != IntPtr.Zero)
             {
                 WinUtil.DeleteObject(_closeBitmap);
             }
             _closeBitmap = WinUtil.CaptureWindow(this.Handle);
         }
         catch
         {
         }
     }
 }