Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Print PicBox at Co-ords on page???

Posted on 2000-04-20
9
Medium Priority
?
241 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 3
9 Comments
 
LVL 28

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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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
 
LVL 28

Accepted Solution

by:
Ark earned 400 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 28

Expert Comment

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

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Suggested Courses

721 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