Outputting graphics to the printer is identical to outputting graphics to a
PictureBox. We will cover a few basic commands here, but first lets take a quick
look at the CurrentX
and CurrentY
properties. These
were used in the last example, and show where the current coordinates are. Visual
Basic automatically change these when it has finished the outputting. For example,
imagine you draw a line on a piece of paper - when you have finished drawing,
the pen is at the end of the line, not the start. This is the same with the
CurrentX and CurrentY properties. If you call the Line method, the line is drawn,
and then CurrentX and CurrentY are changed to point to the end of the line.
You can then change these if necessary to control where the next text or line
is printed.
Note
VB uses the same functions for drawing in picture boxes and outputting to the printer. If you don't want to have to visit the printer and waste paper whilst following this tutorial, simply create a new project, set the forms backcolor to white, autoredraw property to true, and remove change any Printer.Function
to Function . You will also need to comment out the Printer.EndDoc
lines. The data that was going to be printed on paper will now be 'printed'
to the form instead. |
Comments