Using the printSet Control package
by Rick Miller     -     July, 2008

T he printSet object is a control for storing a "que" (printer setting).

A "que" can be created by displaying a Print Setup dialog and selecting OK.
or with a few lines of code.
Creating and using the "que" makes no changes to the windows printing system.

A developer can then use the "que" with printSet to:
    1) assign properties to a dBASE printer object.
    2) display a Properties dialog for a printer with information pre-selected.
    3) display a Print dialog with information pre-selected.
    4) display a Print Setup dialog with information pre-selected.

The printSet Control package comes with the compiled printSet control,
    2 dialog forms in source code format, and
    a test print program in source code format.
 
      1) Using the rmmPrintSetupForm dialog.
            a) properties.
            b) methods.

      2) Using the rmmPrintForm dialog.
            a) properties.
            b) methods.

      2) Working with the printSet object.
            a) properties.
            b) methods.

      How to questions.
            a) How is a printSet object created ?
            b) How is a stored que created ?
            c) How is it used with a dBASE Report object ?
            d) Where is the beef (real world) ?
 



W orking with the rmmPrintSetupForm dialog.
The easiest way to store a printer setting is with the rmmPrintSetupForm dialog.
After installation of the printSet Control package, start dBASE and change directories to the installation folder.
Run the file rmmPrintSetup.wfm.
Make choices as you wish.
Selecting OK will store settings for the "Default" que and
assign properties to the form.printer object.


Methods of rmmPrintSetupForm.
rmmPrintSetupForm Method
  readModal opens a dialog with settings that can be changed, saved, and applied to a printer.

Properties of rmmPrintSetupForm.
Property Default
  devModes assocArray associates a devMode with a printer name.
  ok false did user select OK ?
  oPrintSet printSet object object to read and store printer settings and to apply properties when OK is selected.
  printer _app.printer object to read properties from and to apply properties to when OK is selected.

Back to the Top

W orking with the rmmPrintForm dialog.
To easiest way to use a stored setting is with the rmmPrintForm dialog.
Run the file rmmPrint.wfm.
Make choices as you wish.
Selecting Print will assign properties to the form.printer object.
To use with a report,
    1) create the report object.
       Note: the Print range area will operate when a
       maxPages <int> property is assigned to the report.printer object.
    2) assign the report.printer to rmmPrintForm.printer.
    3) open the rmmPrintForm dialog.
    4) if rmmPrintForm.ok // continue with printing.
       new properties created in the report.printer are:
       endPage, left, que, startPage, and top.


Methods of rmmPrintForm.
rmmPrintForm Method
  readModal opens a dialog with a que that can be changed and applied to a printer.

Properties of rmmPrintForm.
Property Default
  devModes assocArray associates a devMode with a printer name.
  ok false did user select Print ?
  oPrintSet printSet object object to read stored printer settings and to apply properties when Print is selected.
  printer _app.printer object to read properties from and to apply properties to when Print is selected.

Back to the Top

W orking directly with the printSet object.
How is a printSet object created ?
 
oRef = new printSet()
example:     oRef = new printSet()
 

Methods of printSet.
printSet Method
  close() calls to release() and closes the printSet file.
  defaultPrinter() returns the default Window's Printer name.
  enumPrinters() returns a 1 column array of printer names.
  get(<char> property name) returns a property value.
  getDevmode() returns a string as a devMode structure.
  isOpen() determine whether this object has been initialized. returns true/false (yes/no).
  isValidPrinter(<char> printer name) determine whether the passed in printer name is valid. returns true/false (yes/no).
  open() assign properties to this using either this.device or the defaultPrinter. returns true/false (success/fail).
  openQue([<char> que name]) assign properties to this from a stored printer setting with the passed in que name or this.que. returns true/false (success/fail).
  release() release object from memory.
  save() store the current printer setting with this.que name. returns true/false (success/fail).
  saveQue([<char> que name]) store the current printer setting to the passed in que name or this.que. returns true/false (success/fail).
  set(<char> property, <pValu> value) set a property value, returns true/false (success/fail).
  setDevmode(<char> printer name, <string> devMode structure) set this.device and the current devMode, returns true/false (success/fail).
  setPrinter(<object> printer object) assign properties to a printer object, returns true/false (success/fail).
  showProps([<int> hwnd]) display the Properties dialog for this.device. returns true/false (OK/Cancel).

Let's go ahead and create a stored que.
Then we will apply the que to _app.printer.
 
set procedure to printSet.co additive
// Note: we are using printSet.co instead of printSet.cc
// for compatibility with all 32 bit versions of dBASE.
inspect(_app.printer)
// notice a few of the property values.
oPrintset = new printSet()
if not oPrintset.openQue("Checks")
    oPrintset.que  := "Checks"
    oPrintset.open()
endif
if oPrintset.isOpen()
    oPrintset.save()
    oPrintset.setPrinter(_app.printer)
endif
oPrintset.close()

// notice a few of _app.printer properties may have changed.
// there are some additional properties as well.
// You may need to toggle the tabs to refresh the inspector.
// close the inspector.

 

Properties of printSet.
printSet Property Default
  debug false whether to show msgbox error for get or set methods.
  device "" printer name
  left 0.0000 can be used for positioning a pageTemplate or a streamFrame
  que "Default" stored setting name
  top 0.0000 can be used for positioning a pageTemplate or a streamFrame
  version "Release 1.xxxx" version of printSet control.

Back to the Top

How does printSet work with a dBASE printer object ?
The setPrinter method can be used to assign properties to a printer.

A dBASE printer object has several properties affecting output.
 
color <int> 0=Default, 1=Mono, 2=Color/Shades of gray.
copies <int> 1 Number of prints to make.
duplex <int> 0=Default, 1=None, 2=Duplex vertical, 3=Duplex horizontal.
orientation <int> 0=Default, 1=Portrait, 2=Landscape.
paperSize <int> Evaluates to a Width x Height paper size.
paperSource <int> Evaluates to a paper tray or bin.
printerName <char> Name displayed in the windows printer applet.
printerSource <int> 0=Windows default, 1=dBASE default, 2=Specific Printer.
resolution <int> 0=Default, 1=Draft, 2=Low, 3=Medium, 4=High.
trueTypeFonts <int> 0=Default, 1=Bitmap, 2=Download, 3=Substitute, 4=Outline
 

The printSet setPrinter method assigns a printer object's:
    printerSource a value of 2 (Specific printer),
    resolution a value of 0 (Default),
    and trueTypeFonts a value of 0 (Default).
The remaining printer properties are assigned values based upon the que that is in use.

Additional properties left , top and que are created in the printer object.
The left can be used to modify a pageTemplate.marginLeft property or a streamFrame.left property.
The top can be used to modify a pageTemplate.marginTop property or a streamFrame.top property.
The que can be used in conjunction with a Print dialog.

Back to the Top

Where is the beef (real world) ?

I have an application for Payroll.
This application prints Reports and Checks.
The Report print jobs are Landscape.
The Check print jobs are Portrait.

rmmPrintSetUp.wfm can be used to create 2 different ques.
One for Reports and one for Checks.

To establish a que for "Reports".
Link the following code to a Menu item for Printer Setup (Reports).
When OK is selected in the dialog, the que is created or updated.
 
set procedure to rmmPrintSetup.wfm additive
oForm = new rmmPrintSetupForm()
_app.printer.que = "Reports"
oForm.mdi := false
oForm.readModal()
close procedure rmmPrintSetup.wfm

 


To establish a que for "Checks".
Link the following code to a Menu item for Printer Setup (Checks).
When OK is selected in the dialog, the que is created or updated.
 
set procedure to rmmPrintSetup.wfm additive
oForm = new rmmPrintSetupForm()
_app.printer.que = "Checks"
oForm.mdi := false
oForm.readModal()
close procedure rmmPrintSetup.wfm

 

To use a que when printing.
Code below can be used from a Menu item.
 
// Notes:
// The que must be applied before issuing a report.render().
Local oPrintset, oReport
set procedure to my.rep additive
set procedure to printSet.co additive
// Create report object.
oReport = new myReport()
// Redirect report output to the Printer.
oReport.output := 1
// Either create a printSet object with the "Reports" que.
oPrintset = new printSet()
if oPrintset.openQue("Reports")
    oPrintset.setPrinter(oReport.printer)
endif
// or create a printSet object with the "Checks" que.
oPrintset = new printSet()
if oPrintset.openQue("Checks")
    oPrintset.setPrinter(oReport.printer)
endif
// Run the report.
oReport.render()
// Destroy objects.
oPrintset.release()
oPrintset  := null
oReport.release()
oReport  := null
close procedure printSet.co
close procedure my.rep

 

That's all there is !!
Best wishes to everyone when Printing dBASE Reports.

Back to the Top