vb.net taking screenshot of windows form

  • Thread starter Thread starter nigelsvision
  • Start date Start date
N

nigelsvision

Guest
Hi, Im taking a screenshot of a windows form that has a fixed size. I can take the screenshot and set the image size. The problem is if the user moves the window the screenshot will include some of the background I dont want. The code being used is.


Dim frmleft As System.Drawing.Point = Me.Bounds.Location
Dim screenx As Integer = frmleft.X
Dim screeny As Integer = frmleft.Y

Dim r As New RECT
GetWindowRect(GetActiveWindow, r)
Dim img As New Bitmap(1410, 787)
Dim gr As Graphics = Graphics.FromImage(img)
gr.CopyFromScreen(screenx, screeny, 0, 0, img.Size)

img.Save("test.png")
Process.Start("test.png")

Is there away to make sure when I take a screenshot I only get the windows form? so if I have other windows open in the background, none of that is included.


Thanks Nige

Continue reading...
 
Back
Top