Printing a Virtual BufferFastgraph includes three functions, fg_printdc(), fg_printer(), and fg_vbprint(), that work together for printing rectangular regions from the active virtual buffer on the selected Windows printer. The fg_printdc() function establishes the printer device context, which directs subsequent printing to the associated printer. Its only parameter is a handle to the printer device context; this is often obtained through the Print common dialog box. If you do not call fg_printdc(), or if you pass it a zero device context, printing will be directed to the default Windows printer. The fg_printer() function provides necessary print job control. It accepts a single integer parameter whose value is one of the identifiers or numeric values shown here:
For STARTDOC requests, the fg_printer() return value will be one of the following:
For ABORTDOC, ENDDOC, and NEWFRAME requests, the fg_printer() return value will be zero. C++Builder and Delphi programs that select a printer through the Print dialog box should use the TPrinter methods Abort(), BeginDoc(), EndDoc(), and NewPage() in place of the functionality provided by fg_printer(). The fg_vbprint() function prints a rectangular region from the active virtual buffer on the selected printer, scaling the printed image as requested. Its parameters are similar to those of fg_vbscale(), but fg_vbprint() takes one additional parameter that specifies the units of the destination (printer) coordinates. Acceptable values for the units parameter are:
A typical one-page print sequence looks something like this:
C/C++:
Delphi:
Visual Basic:
We'll now present some sample fg_vbprint() calls that print the entire contents of a 640x480 virtual buffer. Our first example creates a 64x48-millimeter printed image in the upper left corner of the page:
C/C++ and Delphi:
Visual Basic:
If we wanted to print the same image 30 millimeters from the left edge of the page and 20 millimeters from the top edge, we would add these offsets to the destination coordinates:
C/C++ and Delphi:
Visual Basic:
If we instead wanted to express the printer coordinates in inches, here is how to print a 5x3-inch printed image in the upper left corner of the page:
C/C++ and Delphi:
Visual Basic:
It's often useful to express printer coordinates as percentages of the available printing area. This call would scale the image to print the entire printing area:
C/C++ and Delphi:
Visual Basic:
Finally, here's how we would print an image one-half the size of the printing area, centered in the middle of the page:
C/C++ and Delphi:
Visual Basic:
|
 
copyright 2001 Ted Gruber Software, Inc.