Private Function GetFormImage(Optional ByVal _
with_decorations As Boolean = True) As Image
Dim bm As New Bitmap(Me.Width, Me.Height)
Me.DrawToBitmap(bm, New Rectangle(0, 0, Me.Width, _
Me.Height))
If Not with_decorations Then
' Trim off the decorations.
Dim client_origin As Point = Me.PointToScreen(New _
Point(0, 0))
Dim deco_left As Integer = client_origin.X - Me.Left
Dim deco_top As Integer = client_origin.Y - Me.Top
Dim wid As Integer = Me.ClientRectangle.Width
Dim hgt As Integer = Me.ClientRectangle.Height
Dim new_bm As New Bitmap(wid, hgt)
Dim gr As Graphics = Graphics.FromImage(new_bm)
gr.DrawImage(bm, New Rectangle(0, 0, wid, hgt), New _
Rectangle(deco_left, deco_top, wid, hgt), _
GraphicsUnit.Pixel)
bm = new_bm
End If
Return bm
End Function
|