1 2 3 4 5 6 7 8 9 10 11 12 13 14
| Private Function Capturectrl(ByVal ctrl As Control) As Bitmap
Dim memoryImage As Bitmap
Dim mygraphics As Graphics = ctrl.CreateGraphics()
Dim s As Size = ctrl.Size
memoryImage = New Bitmap(s.Width - 3, s.Height - (SystemInformation.FrameBorderSize.Width + 3 + SystemInformation.CaptionHeight), mygraphics)
Dim memoryGraphics As Graphics = Graphics.FromImage(memoryImage)
Dim dc1 As IntPtr = mygraphics.GetHdc
Dim dc2 As IntPtr = memoryGraphics.GetHdc
StretchBlt(dc2, 0, 0, ctrl.ClientRectangle.Width, _
ctrl.ClientRectangle.Height, dc1, 0, 0, 13369376)
mygraphics.ReleaseHdc(dc1)
memoryGraphics.ReleaseHdc(dc2)
Return memoryImage
End Function |
Partager