Problem Printing Usercontrols in PictureBox
I have a PictureBox that is the container of several UserControls and Frame controls. I am trying to print the PictureBox using the following code.
Code:
Option Explicit
Public Const twipFactor = 1440
Public Const WM_PAINT = &HF
Public Const WM_PRINT = &H317
Public Const PRF_CLIENT = &H4& ' Draw the window's client area.
Public Const PRF_CHILDREN = &H10& ' Draw all visible child windows.
Public Const PRF_OWNED = &H20& ' Draw all owned windows.
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
Public Sub Print_PrintBox(frmTemp As Form)
Dim rv As Long
With frmTemp
.picMain.SetFocus
.picPrintBox.AutoRedraw = True
rv = SendMessage(.picMain.hWnd, WM_PAINT, .picPrintBox.hDC, 0)
rv = SendMessage(.picMain.hWnd, WM_PRINT, .picPrintBox.hDC, PRF_CLIENT + PRF_CHILDREN + PRF_OWNED)
.picPrintBox.Picture = .picPrintBox.Image
.picPrintBox.AutoRedraw = False
Printer.Print ""
Printer.PaintPicture .picPrintBox.Picture, 0, 0
Printer.EndDoc
End With
End Sub
The PictureBox prints however the Frames only print as outlines and the UserControls do not print at all. The Frames contain only Label Controls.
Does anyone have any ideas or solutions to this problem. Any help would be greatly appreciated.
Thanks