title: ScreenCapture program taking screenshot
body: <p>I'm developing a windows application in which i want to take screenshot of the whole window.
  For that i have written the following code:</p>
  
  <pre><code>Imports System.IO
  
  
  Public Class ScreenCapture
  
      Public Sub GetJPG()
          Dim dt As DateTime = DateTime.Now
          Dim cdt As String = ""
          cdt = dt.ToString("dd MM yyyy HH:mm:ss")
          cdt = cdt.Replace(":", "_")
          cdt = cdt.Replace(" ", "_")
  
          Dim ScreenSize = SystemInformation.PrimaryMonitorSize
  
          Dim width As Integer = ScreenSize.Width
          Dim height As Integer = ScreenSize.Height
  
          Dim dir As DirectoryInfo = New DirectoryInfo("Screenshots")
          If Not dir.Exists Then dir = Directory.CreateDirectory(dir.FullName)
          Dim path As String = AppDomain.CurrentDomain.BaseDirectory
  
          Dim bitmap = New System.Drawing.Bitmap(ScreenSize.Width, ScreenSize.Height)
          Dim g = Graphics.FromImage(bitmap)
          g.CopyFromScreen(New Point(0, 0), New Point(0, 0), ScreenSize)
          g.Flush()
  
          Dim newbitmap = New System.Drawing.Bitmap(bitmap, width, height)
  
          Dim gr As Graphics = Graphics.FromImage(bitmap)
          gr.DrawImage(newbitmap, New Rectangle(0, 0, width, height), New Rectangle(0, 0, bitmap.Width, bitmap.Height), GraphicsUnit.Pixel)
  
          newbitmap.Save(path &amp; "Screenshots\" &amp; cdt &amp; ".jpg", System.Drawing.Imaging.ImageFormat.Png)
  
      End Sub
  End Class
  </code></pre>
  
  <p>When i run a wpf application and in background keep this screencapture app running. It takes screenshot of the window in the background of the wpf application. I want the screenshot of the current view which is there on the monitor.</p>
  
  <p>Please help me.</p>