Solved

Print PicBox at Co-ords on page???

Posted on 2000-04-20
9
234 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Access 2003, my txt file export is running backwards 4 46
Excel object stays open 19 70
Best way to parse out a json string in VB6? 10 109
Child Form in front 4 35
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
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…
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…

932 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

13 Experts available now in Live!

Get 1:1 Help Now