Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Printing Controls on a Picturebox

Status
Not open for further replies.

Karl Blessing

Programmer
Feb 25, 2000
2,936
0
0
US
I have an ActiveX control that is ran on IE, which uses two picture boxes for scrolling methods, then inside of the inner picture box , are a bunch of other ActiveX controls I created, how can I print everything on the innerpicture box, I keep getting an error of &quot;Invalid Picture&quot; when doing<br><br>Printer.PainPicture InnerBox.Picture, 0, 0<br>Printer.EndDoc<br> <p>Karl<br><a href=mailto:kb244@kb244.com>kb244@kb244.com</a><br><a href= </a><br>Experienced in : C++(both VC++ and Borland),VB1(dos) thru VB6, Delphi 3 pro, HTML, Visual InterDev 6(ASP(WebProgramming/Vbscript)<br>
 
The problem is the usage of the .picture property. This property is used only for loading bitmaps into the background of a picture box or a form. When you haven't loaded any pictures in the control, the .picture - property is null/empty and not useful for image capturing. You can try using the .image - property instead but that will probably fail as well. I suggest you use the BitBlt - command from API32 instead.<br><br>Declare:<br>Declare Function BitBlt Lib &quot;gdi32&quot; Alias &quot;BitBlt&quot; (ByVal hDestDC As Long, ByVal x As Long, ByVal y As Long, ByVal nWidth As Long, ByVal nHeight As Long, ByVal hSrcDC As Long, ByVal xSrc As Long, ByVal ySrc As Long, ByVal dwRop As Long) As Long<br><br>Then specify in order:<br>- Printer.hDC<br>- 0<br>- 0<br>- [Width]<br>- [Height]<br>- InnerBox.hDC<br>- 0<br>- 0<br>- &HCC0020<br><br>Hope that will solve the problem.
 
I would be doing something like this right?<br>BitBlt Printer.hDC, 0, 0, OuterBox.Width, InnerBox.Height, InnerBox.hDC, 0, 0, &HCC0020<br>Printer.EndDoc <p>Karl<br><a href=mailto:kb244@kb244.com>kb244@kb244.com</a><br><a href= </a><br>Experienced in : C++(both VC++ and Borland),VB1(dos) thru VB6, Delphi 3 pro, HTML, Visual InterDev 6(ASP(WebProgramming/Vbscript)<br>
 
Yeah, that seems to be ok. Don't forget to change the scalemode-properties of the form (or the activeX window) !and! the outerbox to vbpixels. (Because bitblt is measuring everything in pixels).<br>Tell me if it works ...
 
since the scalemode is crucial to the way I have it set up, I have this<br><br><FONT FACE=monospace><br>Public Sub PrintMe()<br>&nbsp;&nbsp;&nbsp;InnerBox.ScaleMode = 3<br>&nbsp;&nbsp;&nbsp;OuterBox.ScaleMode = 3<br>&nbsp;&nbsp;&nbsp;BitBlt Printer.hDC, 0, 0, OuterBox.Width, InnerBox.Height, InnerBox.hDC, 0, 0, &HCC0020<br>&nbsp;&nbsp;&nbsp;Printer.EndDoc<br>&nbsp;&nbsp;&nbsp;InnerBox.ScaleMode = 1<br>&nbsp;&nbsp;&nbsp;OuterBox.ScaleMode = 1<br>End Sub<br></font><br><br>This doesnt generate an error, but it doesnt print anything either. <p>Karl<br><a href=mailto:kb244@kb244.com>kb244@kb244.com</a><br><a href= </a><br>Experienced in : C++(both VC++ and Borland),VB1(dos) thru VB6, Delphi 3 pro, HTML, Visual InterDev 6(ASP(WebProgramming/Vbscript)<br>
 
Try using:<br><br>#Const De_bug = True<br><br>InnerBox.ScaleMode = 3<br>Dim lres As Long<br>lres = BitBlt(Printer.hDC, _<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;0, 0, _<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;InnerBox.ScaleWidth, _<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;InnerBox.ScaleHeight, _<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;InnerBox.hDC, _ <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;0, _ <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;0, _ <br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&HCC0020 _<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;)<br>InnerBox.ScaleMode = 1<br>Printer.EndDoc<br><br>#If de_bug Then<br>MsgBox lres<br>#End If<br><br>If there is no error, the message box should show a nonzero value.<br>
 
still nothing, and I get a zero from the message box, so something is happening. <p>Karl<br><a href=mailto:kb244@kb244.com>kb244@kb244.com</a><br><a href= </a><br>Experienced in : C++(both VC++ and Borland),VB1(dos) thru VB6, Delphi 3 pro, HTML, Visual InterDev 6(ASP(WebProgramming/Vbscript)<br>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top