Results 1 to 6 of 6

Thread: [RESOLVED] printing to printer using PaintPicture

Hybrid View

  1. #1
    PowerPoster jcis's Avatar
    Join Date
    Jan 2003
    Location
    Argentina
    Posts
    4,430

    Re: printing to printer using PaintPicture

    Add another PcitrueBox named PicAux, it will be invisible. Then assuming the PictureBox that contains all the drawing and controls is named Picture1..
    Code:
    Private Declare Function BitBlt Lib "gdi32" _
                (ByVal hDCDest As Long, ByVal XDest As Long, ByVal YDest As Long, _
                ByVal nWidth As Long, ByVal nHeight As Long, ByVal hDCSrc As Long, _
                ByVal xSrc As Long, ByVal ySrc As Long, ByVal dwRop As Long) As Long
    
    Private Sub Command1_Click()
        BitBlt PicAux.hDC, 0, 0, Picture1.ScaleWidth, Picture1.ScaleWidth, _
               Picture1.hDC, 0, 0, vbSrcCopy
        Printer.PaintPicture PicAux.Image, 300, 300 'print at x=300 and y=300
        Printer.EndDoc
    End Sub
    Private Sub Form_Load()
        Picture1.AutoRedraw = False
        Picture1.ScaleMode = vbPixels
        PicAux.AutoRedraw = True
        PicAux.ScaleMode = vbPixels
        PicAux.Width = Picture1.Width
        PicAux.Height = Picture1.Height
        PicAux.Visible = False
    End Sub
    This will work as far as your main Picture (Picture1) is totally visible on screen when you call this, if there are hidden/overlapped parts then BitBlt won't be able to see it.
    Last edited by jcis; Jun 15th, 2008 at 07:12 PM.

  2. #2

    Thread Starter
    Addicted Member
    Join Date
    Jul 2002
    Location
    new zealand (kiwi)!
    Posts
    202

    Re: printing to printer using PaintPicture

    Thanks that works Ok
    I have one strange problem still (not printing related)
    Even though I am doing a .CLS on the form and all pictureboxes
    the previous graph does not clear!
    The pictureboxes & form are all set to Autoredraw = true.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width