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 Command2_Click() Dim rv As Long Picture1.SetFocus ' So that the button doesn't look pressed Picture1.AutoRedraw = True rv = SendMessage(Picture1.hwnd, WM_PAINT, Picture1.hDC, 0) rv = SendMessage(Picture1.hwnd, WM_PRINT, Picture1.hDC, _ PRF_CHILDREN + PRF_CLIENT + PRF_OWNED) Picture1.Picture = Picture1.Image Picture1.AutoRedraw = False Printer.Orientation = 1 ' 2 Printer.Print "" Printer.PaintPicture Picture1.Picture, 0, 0 Printer.EndDoc End Sub |