• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 185
  • Last Modified:

print the contents of the picture control

i have one form, i put on this form a picture control and use some code to draw some things on this picture control.
now i want to print the contents of this picture control. how can i do that? and also i want to the drawing to fit the paper i print on
0
aft
Asked:
aft
1 Solution
 
sanjaykattimaniCommented:
SavePicture  Picture1.Picture "filename.bmp"
0
 
sanjaykattimaniCommented:
oops... here is something to print it.
in it simplest form (withought adjustments)
Printer.PaintPicture pBox.Picture
Private Sub PrintPictureBox(pBox As PictureBox, _
                           Optional ScaleToFit As Boolean = True, _
                           Optional MaintainRatio As Boolean = True)
 
 Dim xmin As Single
 Dim ymin As Single
 Dim wid As Single
 Dim Hgt As Single
 Dim aspect As Single
 
    Screen.MousePointer = vbHourglass
   
    If Not ScaleToFit Then
        wid = Printer.ScaleX(pBox.ScaleWidth, pBox.ScaleMode, Printer.ScaleMode)
        Hgt = Printer.ScaleY(pBox.ScaleHeight, pBox.ScaleMode, Printer.ScaleMode)
        xmin = (Printer.ScaleWidth - wid) / 2
        ymin = (Printer.ScaleHeight - Hgt) / 2
    Else
        aspect = pBox.ScaleHeight / pBox.ScaleWidth
        wid = Printer.ScaleWidth
        Hgt = Printer.ScaleHeight
       
        If MaintainRatio Then
            If Hgt / wid > aspect Then
                Hgt = aspect * wid
                xmin = Printer.ScaleLeft
                ymin = (Printer.ScaleHeight - Hgt) / 2
            Else
                wid = Hgt / aspect
                xmin = (Printer.ScaleWidth - wid) / 2
                ymin = Printer.ScaleTop
            End If
        End If
    End If
   
    Printer.PaintPicture pBox.Picture, xmin, ymin, wid, Hgt
    Printer.EndDoc

    Screen.MousePointer = vbDefault

End Sub

complete application is available in http://www.Planet-Source-Code.com/vb 
at

http://www.Planet-Source-Code.com/vb/scripts/ShowCode.asp?txtCodeId=37488&lngWId=1
0
 
aftAuthor Commented:
but this will print on the default printer. how can i change the printer? i know how to display the printing common dialog but how can get the value of the printer and pass it to ur code?
0
Technology Partners: 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!

 
aftAuthor Commented:
and also the problem is in the paintpicture because the first argument must be a photo but what i have in my picture box is not a photo. it is just some lines and shapes. so how can i print them? should i convert them first to a picture? how?
0
 
CleanupPingCommented:
aft:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
Experts: Post your closing recommendations!  Who deserves points here?
0
 
DanRollinsCommented:
aft, an EE Moderator will handle this for you.
Moderator, my recommended disposition is:

    Refund points and save as a 0-pt PAQ.

DanRollins -- EE database cleanup volunteer
0
 
Computer101Commented:
PAQed - no points refunded (of 25)

Computer101
E-E Admin
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now