此示例预览当前窗体的打印副本。
示例
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 Dim memoryImage As Bitmap Private Sub CaptureScreen() Dim mygraphics As Graphics = Me.CreateGraphics() Dim s As Size = Me.Size memoryImage = New Bitmap(s.Width, s.Height, mygraphics) Dim memoryGraphics As Graphics = Graphics.FromImage(memoryImage) Dim dc1 As IntPtr = mygraphics.GetHdc Dim dc2 As IntPtr = memoryGraphics.GetHdc BitBlt(dc2, 0, 0, Me.ClientRectangle.Width, _ Me.ClientRectangle.Height, dc1, 0, 0, 13369376) mygraphics.ReleaseHdc(dc1) memoryGraphics.ReleaseHdc(dc2) End Sub