Solved

Print PicBox at Co-ords on page???

Posted on 2000-04-20
9
235 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
Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

 

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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

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…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
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…

785 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