Solved

Print PicBox at Co-ords on page???

Posted on 2000-04-20
9
240 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
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 

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

Expert Comment

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

Featured Post

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
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.
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 Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Suggested Courses
Course of the Month8 days, 13 hours left to enroll

615 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