1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
| Dim memoryImage1 As Bitmap
Private Declare Function BitBlt Lib "gdi32.dll" Alias "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 System.Int32) As Long
Private Sub CaptureScreen1()
Dim mygraphics1 As Graphics = TabPage1.CreateGraphics()
Dim s As Size = New Size(992, 600)
memoryImage1 = New Bitmap(s.Width, s.Height, mygraphics1)
Dim memoryGraphics As Graphics = Graphics.FromImage(memoryImage1)
Dim dc1 As IntPtr = mygraphics1.GetHdc
Dim dc2 As IntPtr = memoryGraphics.GetHdc
BitBlt(dc2, 0, 0, Me.ClientRectangle.Width, _
Me.ClientRectangle.Height, dc1, 0, 0, 13369376)
mygraphics1.ReleaseHdc(dc1)
memoryGraphics.ReleaseHdc(dc2)
End Sub
Private Sub btn_Impr_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btn_Impr.Click
CaptureScreen1()
PrintDocument1.Print()
End Sub
Private Sub PrintDocument1_PrintPage_1(ByVal sender As System.Object, ByVal e As System.Drawing.Printing.PrintPageEventArgs) Handles PrintDocument1.PrintPage
e.Graphics.DrawImage(memoryImage1, 15, 40, 992, 600)
End Sub |
Partager