Article ID: 178076
Article Last Modified on 7/13/2004
Private Declare Function SendMessage Lib "user32" Alias _
"SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, _
ByVal wParam As Long, ByVal lParam As Long) As Long
Private Const WM_PAINT = &HF
Private Const WM_PRINT = &H317
Private Const PRF_CLIENT = &H4& ' Draw the window's client area
Private Const PRF_CHILDREN = &H10& ' Draw all visible child windows
Private Const PRF_OWNED = &H20& ' Draw all owned windows
Private Sub Command1_Click()
Dim rv As Long
Picture1.SetFocus ' So that the button doesn't look pressed
Picture2.AutoRedraw = True
rv = SendMessage(Picture1.hwnd, WM_PAINT, Picture2.hDC, 0)
rv = SendMessage(Picture1.hwnd, WM_PRINT, Picture2.hDC, _
PRF_CHILDREN + PRF_CLIENT + PRF_OWNED)
Picture2.Picture = Picture2.Image
Picture2.AutoRedraw = False
Printer.Orientation = vbPRORLandscape ' 2
Printer.Print ""
Printer.PaintPicture Picture2.Picture, 0, 0
Printer.CurrentY = Picture2.Height + 200 ' get below image
Printer.Print "Text on the same page as the image!"
Printer.EndDoc
Command1.SetFocus ' Return Focus
End Sub
Private Sub Form_Load()
Me.Show
Command1.Caption = "Print Form"
End Sub
161299 How To Capture and Print the Screen, a Form, or Any Window
230502 How To Print a Form That is Too Large for the Screen or Page
194580 How To Print a Composite Image From a RichTextBox
146022 How To Set Up the RichTextBox Control for WYSIWYG Printing
242483 BUG: Error 486 or 482 Occurs When Using PrintForm
198901 SAMPLE: PageSet.exe Programmatically Changes Default Printer Orientation
Additional query words: portrait KBPRINTING
Keywords: kbhowto KB178076