' Print the PictureBox's picture centered and
' draw a box around it.
Private Sub cmdPrint_Click()
Dim wid As Single
Dim hgt As Single
Dim X As Single
Dim Y As Single
' Set the PictureBox's ScaleMode to pixels to
' make things interesting.
picCanvas.ScaleMode = vbPixels
' Get the picture's dimensions in the printer's
' scale mode.
wid = ScaleX(picCanvas.ScaleWidth, picCanvas.ScaleMode, _
hgt = ScaleY(picCanvas.ScaleHeight, _
' See where we need to print to center the picture.
X = Printer.ScaleLeft + (Printer.ScaleWidth - wid) / 2
Y = Printer.ScaleTop + (Printer.ScaleHeight - hgt) / 2
' Print the picture.
Printer.PaintPicture picCanvas.Picture, X, Y
' Draw the box.
Printer.Line (X, Y)-Step(wid, hgt), , B
' Finish printing.