Article ID: 194580
Article Last Modified on 7/1/2004
Option Explicit
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
Private Const PRF_OWNED = &H20& ' Draw all owned windows
Private Sub Command1_Click()
' Use the .bmp of your choice and make sure to give the full path.
RichTextBox1.OLEObjects.Add , , "c:\windows\triangles.bmp"
End Sub
Private Sub Command2_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
Command1.SetFocus ' Return Focus
End Sub
Private Sub Command3_Click()
Printer.PaintPicture Picture2.Picture, 0, 0
Printer.EndDoc
End Sub
Additional query words: kbDSupport kbDSD kbVBp kbVBp500 kbVBp600 kbCtrl kbPrinting kbAPI kbUserGrp kbBitmap
Keywords: kbhowto KB194580