Click here to copy the following block | Public Sub PrintPictureBox(Box As PictureBox, _ Optional X As Single = 0, _ Optional Y As Single = 0) Dim rv As Long Dim ar As Boolean On Error GoTo Exit_Sub With Box ar = .AutoRedraw .AutoRedraw = True Printer.Print rv = SendMessage(.hwnd, WM_PAINT, .hDC, 0) rv = SendMessage(.hwnd, WM_PRINT, .hDC, _ PRF_CHILDREN Or PRF_CLIENT Or PRF_OWNED) .Picture = .Image Printer.PaintPicture .Picture, X, Y Printer.EndDoc Box.Line (0, 0)-(.ScaleWidth, .ScaleHeight), .BackColor, BF .AutoRedraw = ar End With Exit_Sub: If Err.Number Then MsgBox Err.Description, vbOKOnly, "Printer Error!" End Sub |
|