I am printing the report created & displayed in picturebox. Picturebox contents few labels & listview. The form & picturebox is more in height than my screen resolution. Whenever i am printing using following code, it print the report perfectly but print system taskbar too.

Any solution.


VB Code:
  1. Option Explicit
  2.  
  3. Private Declare Function BitBlt Lib "gdi32" (ByVal hDestDC As Long, _
  4.                 ByVal X As Long, ByVal Y As Long, ByVal nWidth As Long, _
  5.                 ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, _
  6.                 ByVal ySrc As Long, ByVal dwRop As Long) As Long
  7. Private Const SRCCOPY = &HCC0020
  8.  
  9.  
  10. Private Sub PrintPictureBox(Pic As PictureBox)
  11. Dim picTemp As PictureBox
  12.  
  13.     Set picTemp = Controls.Add("VB.PictureBox", "picTemp")
  14.    
  15.     With picTemp
  16.         .AutoRedraw = True
  17.         .BorderStyle = vbBSNone
  18.         .Width = Pic.ScaleWidth
  19.         .Height = Pic.ScaleHeight
  20.         .Left = Me.Width
  21.         .Visible = True
  22.     End With
  23.  
  24.     BitBlt picTemp.hDC, 0, 0, Pic.Width, Pic.Height, Pic.hDC, 0, 0, SRCCOPY
  25.    
  26.     picTemp.Picture = picTemp.Image
  27.    
  28.     Printer.Print
  29.     Printer.PaintPicture picTemp.Image, 0, 0
  30.     Printer.EndDoc
  31.    
  32.     Set picTemp = Nothing
  33. End Sub
  34.  
  35.  
  36.  
  37.  
  38. Private Sub Picture1_Click()
  39. PrintPictureBox Picture1
  40. End Sub
  41.  
  42. Private Sub Picture1_DblClick()
  43. Unload Me
  44. End Sub


Thanking in anticipation.


Regards.