I found this code from google but did not know how to implement.

Private Shared Function BitBlt( _
ByVal hdcDest As IntPtr, _
ByVal nXDest As Integer, _
ByVal nYDest As Integer, _
ByVal nWidth As Integer, _
ByVal nHeight As Integer, _
ByVal hdcSrc As IntPtr, _
ByVal nXSrc As Integer, _
ByVal nYSrc As Integer, _
ByVal dwRop As Integer _
) As Boolean
End Function

Private Shared SRCCOPY As Integer = &HCC0020

formGraphics.Dispose()

buffer.Save(filename, System.Drawing.Imaging.ImageFormat.Jpeg)
buffer.Private Sub SaveFormToFile(ByVal sourceForm As Form, ByVal filename As String)
Dim formGraphics As Graphics = sourceForm.CreateGraphics()

Dim
bufferRect = sourceForm.ClientRectangle
Dim buffer As Image = New Bitmap(bufferRect.Width, bufferRect.Height, formGraphics)
Dim bufferGraphics As Graphics = Graphics.FromImage(buffer)

Dim formDC As IntPtr = formGraphics.GetHdc()
Dim bufferDC As IntPtr = bufferGraphics.GetHdc()

BitBlt(bufferDC, 0, 0, bufferRect.Width, bufferRect.Height, formDC, 0, 0, SRCCOPY)

bufferGraphics.ReleaseHdc(bufferDC)
formGraphics.ReleaseHdc(formDC)

bufferGraphics.Dispose()
Dispose()
End Sub

Edited 3 Years Ago by Reverend Jim: Fixed formatting

This article has been dead for over six months. Start a new discussion instead.