How to change the printer device without calling PRINTERDIALOG

Top  Previous  Next

You can change the windows default printer without calling the PRINTERDIALOG function. You may want to do this when a report is designed for pre-printed forms, and therefore must always be routed to a printer loaded with the forms.

This can be done by using Clarion's property syntax. The property to use is PROPPRINT:Device. This property definition can be found in the ..\LIBSRC\PRNPROP.CLW. This must be included in your application before making use of any of the properties defined therein.

 

To include PRNPROP.CLW:

1.

Click on the Global Embeds tab on the Application Tree.

2.

Select the After Global INCLUDEs embed point and add the following embedded source code:

include('prnprop.clw')

 

To change the printer device:

1.

From the Application Tree, select your report procedure and press the Embeds button.

2.

Select the ProcessManager Method Executable Code--Open (Priority:2500) embed point and add the following embedded source code:

 

 

sav::printer = PRINTER{PROPPRINT:Device}               ! save windows default printer

PRINTER{PROPPRINT:Device} = 'HP Laserjet Series II'    ! set new default printer

 

 

The device property takes the name of the printer device. This can be found by looking in windows print manager. The device is the actual printer name. The device property string is case insensitive.

At the end of the report, restore the original default printer:

1.

From the Application Tree, select your report procedure and press the Embeds button.

2.

Select the ProcessManager Method Executable Code--Close (Priority:7500) embed point and add the following embedded source code:

 

PRINTER{PROPPRINT:Device} = sav::printer