Results 1 to 5 of 5

Thread: Printer.HDC, PictureBox.HDC and using BitBlt

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    May 2000
    Location
    Grand Rapids, MI
    Posts
    231

    Exclamation

    at the moment I am trying to get the content of the picture box into the Printer's Device Content and print it off.

    The problem is tho, is that the BitBlt isnt working , throwing in some debuging it always returns a zero (error)

    Code:
    Public Sub PrintMe()
    #Const De_bug = True
    
    Dim lres As Long
    
    lres = BitBlt(Printer.hDC, _
                  0, 0, _
                  InnerBox.ScaleWidth, _
                  InnerBox.ScaleHeight, _
                  InnerBox.hDC, _
                  0, _
                  0, _
                  &HCC0020 _
                 )
    Printer.EndDoc
    
    #If De_bug Then
    MsgBox lres
    #End If
    
    
    End Sub
    oh also scalemode for all the controls are set to 3(pixel)
    -Karl Blessing aka kb244{fastHACK}
    [email protected]

  2. #2
    Fanatic Member gwdash's Avatar
    Join Date
    Aug 2000
    Location
    Minnesota
    Posts
    666
    I've had the same problem, no one's code helped, so you must do it this way

    [code]
    Public Sub PrintMe()
    #Const De_bug = True

    Dim lres As Long

    Printer.PaintPicture(Innerbox.Picture) 'etc.

    Printer.EndDoc

    #If De_bug Then
    MsgBox lres
    #End If
    [code]
    GWDASH
    [b]VB6, Perl, ASP, HTML, JavaScript, VBScript, SQL, C, C++, Linux , Java, PHP, MySQL, XML[b]

  3. #3
    Frenzied Member
    Join Date
    Mar 2000
    Posts
    1,089
    for bitblt 0 is the code for success, but VB won't print a page unless it thinks that there's something on the printer, because you used bitblt and went around VB it doesn't thing there's anything on the printer so it won't print (I hope that made sense)

    Either use gwdash's code or this

    Code:
    Public Sub PrintMe()
    #Const De_bug = True
    
    Dim lres As Long
    
    Printer.Print " "  'I've added this line
    'We just put a space character on the printer 
    'to let vb know we're using it.
    lres = BitBlt(Printer.hDC, _
                  0, 0, _
                  InnerBox.ScaleWidth, _
                  InnerBox.ScaleHeight, _
                  InnerBox.hDC, _
                  0, _
                  0, _
                  &HCC0020 _
                 )
    Printer.EndDoc
    
    #If De_bug Then
    MsgBox lres
    #End If
    
    
    End Sub

  4. #4

    Thread Starter
    Addicted Member
    Join Date
    May 2000
    Location
    Grand Rapids, MI
    Posts
    231
    If paintpicture had worked, I wouldnt be trying to do BitBlt. I get an invalid image with PaintPicture, I want everything in the innerbox printed, the ActiveX control, scrolls, everything.
    -Karl Blessing aka kb244{fastHACK}
    [email protected]

  5. #5
    Guest
    Picture2 is the *inside* picture box;
    i use this to print my graphics centered
    height and width on the paper.


    Code:
    Printer.PaintPicture Picture2.Picture, (Printer.ScaleWidth - Picture2.ScaleWidth) / 2, _
    (Printer.ScaleHeight - Picture2.ScaleHeight) / 2
    hope this helps,
    larry

    [Edited by larryn on 09-27-2000 at 01:39 PM]

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