Home
Search
 
What's New
Index
Books
Links
Q & A
Newsletter
Banners
 
Feedback
Tip Jar
 
C# Helper...
 
XML RSS Feed
Follow VBHelper on Twitter
 
 
MSDN Visual Basic Community
 
 
 
 
 
 
TitlePrint a picture
KeywordsPictureBox, picture, print
CategoriesGraphics
 
Use the Printer object's PaintPicture method to copy the picture to the Printer.
 
' Print the PictureBox's picture with upper left
' corner at (1440, 1440). Then draw a box around
' the picture.
Private Sub cmdPrint_Click()
Dim wid As Single
Dim hgt As Single

    ' Set the PictureBox's ScaleMode to pixels to
    ' make things interesting.
    picCanvas.ScaleMode = vbPixels

    ' Print the picture.
    Printer.PaintPicture picCanvas.Picture, _
        1440, 1440

    ' Get the picture's dimensions in the printer's scale
    ' mode.
    wid = ScaleX(picCanvas.ScaleWidth, picCanvas.ScaleMode, _
        Printer.ScaleMode)
    hgt = ScaleY(picCanvas.ScaleHeight, _
        picCanvas.ScaleMode, Printer.ScaleMode)

    ' Draw the box.
    Printer.Line (1440, 1440)-Step(wid, hgt), , B

    ' Finish printing.
    Printer.EndDoc

    MsgBox "Done"
End Sub
 
For more information on printing and graphics in Visual Basic, see my book Visual Basic Graphics Programming.
 
 
Copyright © 1997-2010 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated