Click to See Complete Forum and Search --> : Printer.HDC, PictureBox.HDC and using BitBlt
kb244
Aug 14th, 2000, 02:13 PM
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)
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)
gwdash
Aug 14th, 2000, 02:29 PM
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]
Sam Finch
Aug 14th, 2000, 02:57 PM
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
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
kb244
Aug 15th, 2000, 08:16 AM
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.
Picture2 is the *inside* picture box;
i use this to print my graphics centered
height and width on the paper.
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]
vbforums.com
Copyright Internet.com Inc., All Rights Reserved.