Go Back  Xtreme Visual Basic Talk > Legacy Visual Basic (VB 4/5/6) > General > How to print images that fit to the page size specified in Print Common Dialog?


Reply
 
Thread Tools Display Modes
  #1  
Old 06-04-2003, 10:52 PM
DaveMustaine DaveMustaine is offline
Regular
 
Join Date: Apr 2003
Location: Singapore
Posts: 61
Default How to print images that fit to the page size specified in Print Common Dialog?


i need some help in printing the whole image tat fit onto the paper size i specified in Print Common Dialog. I hav a PictureBox array & each PictureBox contains a smaller Picturebox inside. For example : Picture1(index) has a smaller Picture2(index) inside. There are vertical & horizontal scrollbars next to each Picture1(index).

i already hav the basic Print Common Dialog code below. Here's the problem -> I can print out the pictures displayed inside Picture2(index) but the printout will turn out truncated or just part of the whole picture when im printing to a 4R photo size for example and the image displayed in Picture2(index) is larger then the bounding Picture1(index) & i need to use the scrollbars to scroll and view the other portions of the image.

So how to modify the code below to print out the whole image tat fit nicely to the paper size i specified. Thanxs.


'---------------------------------------------------------------------
'CODE
'---------------------------------------------------------------------

CommonDialog1.CancelError = True
On Error Resume Next

CommonDialog1.Action = 5 ' Start the Print Common Dialog

If (Err.Number = cdlCancel) Then Exit Sub
'when Cancel is pressed, exit subroutine

'Code to print the array here

For Pics = Picture2.LBound To Picture2.UBound
If Picture2(Pics).Picture > 0 Then ' If the PictureBox is not empty
Printer.PaintPicture Picture2(Pics).Picture, 0, 0
Printer.EndDoc
End If
Next

'---------------------------------------------------------------------
Reply With Quote
  #2  
Old 06-05-2003, 12:05 AM
sjp's Avatar
sjp sjp is offline
Junior Contributor
 
Join Date: Jan 2003
Posts: 257
Default

the paintpicture method has these parameters. so u can specify them to have ur pic printed int he size u want. so if u specify teh destination width and height too, which is ur paper size, it might give u the desired result.

Printer.PaintPicture Picture2(Pics).Picture, DestX, DestY, DestWidth, DestHeight, SourceX, SourceY, SourceWidth, SourceHeight

Last edited by sjp; 06-05-2003 at 01:30 AM.
Reply With Quote
  #3  
Old 06-05-2003, 12:21 AM
DaveMustaine DaveMustaine is offline
Regular
 
Join Date: Apr 2003
Location: Singapore
Posts: 61
Default

Quote:
Originally Posted by sjp
the paintpicture method has these parameters. so u can specify them to have ur pic printed int he size u want. so if u specify teh destination width and height too, which is ur paper size, it might give u the desired result.

Printer.PaintPicture Picture2(Pics).Picture, DestX, DestY, DestWidth, DestHeight, SourceX, SourceY, SourceWidth, SourceHeight, RasterOp




Hey....thanxs SJP. i will try adding the DestWidth & DestHeight.

Btw, regarding the printing multiple pages of the same image thread which u helped me the other time, i thik i manage to solve the bug which always send a new page to print even though i added a "IF" statement to stop it if the condition fails. i modified yur code alittle & now the "IF" statement works correctly together wif the "Printer.NewPage". Thanxs for yur advice.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Common Dialog Tutorial MikeJ Tutors' Corner 0 06-04-2003 09:12 PM
DB Navigation!!! adruta Database and Reporting 3 10-16-2002 09:12 AM
3D cube adruta Word, PowerPoint, Outlook, and Other Office Products 1 10-08-2002 08:21 AM
VB6 to VBA adruta General 0 10-08-2002 04:17 AM
How to Get Paper Size in Common Print Dialog? gausse General 0 11-30-2001 03:56 PM

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
 
 
-->