Solved

Print PicBox at Co-ords on page???

Posted on 2000-04-20
9
232 Views
Last Modified: 2010-05-02
I am trying to print a PictureBox control (Container with image controls and labels) to a printer...  The difficulty I'm having is when I try to place the PictureBox at certain co-ordinates on the page.  I am currently trying various methods - none successfully.  I'd appreciate ANY help!!
0
Comment
Question by:jwindsor
  • 5
  • 3
9 Comments
 
LVL 27

Expert Comment

by:Ark
ID: 2733887
Private Sub Command1_Click()
Dim PrintingX as Long, PrintingY As Long
Dim PrintingWidth as Long, PrintingHeight as Long
' Set these values as you need

PrintingX = Printer.CurrentX
PrintingY = Printer.CurrentY
PrintingWidth = Picture1.Width
PrintingHeight = Picture1.Height
Printer.PaintPicture Myform.Picture1.Image, PrintingX, PrintingY, PrintingWidth, PrintingHeight
End Sub

Cheers
0
 

Author Comment

by:jwindsor
ID: 2733953
Thanks for the speedy reply there Arc... Unfortunatley, when I entered the code and ran the application, I received the error msg >> 'valid Picture' (which is an improvement on the msgs I was getting earlier, I can say).  Would you have any advice on this matter??

PS:  The AutoRedraw property of the PictureBox control IS set to TRUE.
0
 

Author Comment

by:jwindsor
ID: 2733967
That Error Message should have said 'Invalid Picture' - Ooops!!
0
 

Author Comment

by:jwindsor
ID: 2733985
I am beginning to find that the problem is the fact that the PictureBox is containing other controls...  Can anybody help???
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 27

Accepted Solution

by:
Ark earned 100 total points
ID: 2734061
Hi
Sorry, now I understand, what you mean. I thought you want to print image, but you want to print controls from  picturebox container. Invalid picture error is because you have no picture in your picture box. Try to use API BitBlt function:
Private Declare Function BitBlt Lib "gdi32" (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

Private Sub Command1_Click()
   Picture1.ScaleMode = vbPixels
   Printer.Print ""
   BitBlt Printer.hDc, 100,100, 200,200, Picture1.hDc, 0, 0, Picture1.ScaleWidth, Picture1.ScalleHeight, vbSrcCopy
End Sub

Cheers
0
 
LVL 1

Expert Comment

by:sac666
ID: 2734266
Hi
I tried the above code.
Its the perfect solution except that

Bitblt will not accept picture1.scalewith and picture1.scaleheight

I just wanted to bring this to notice..
bye
0
 

Author Comment

by:jwindsor
ID: 2734359
Arc...
I have the Problem sorted out, but I will definately try your API call as it looks a lot more exact...

I have decided to just remove the PictureBox control and give exact co-ordinates for the printer object of each individual controls contents...

Thanks for the help... I accept both your answers with gratitude...
0
 

Author Comment

by:jwindsor
ID: 2734370
What a morning!!!!@@@***#####!!!!
0
 
LVL 27

Expert Comment

by:Ark
ID: 2736360
Thanks for points, glad to help you.
Cheers
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Suggested Solutions

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

747 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now