ChangeDevmode event

The ChangeDevmode event represents the Real Time Printer Hook. The ChangeDevmode event is fired before every StartDocument and StartPage event and can be used to change the printer settings during printings.The event’s parameter is the printer’s DEVMODE structure (settings) which can be modified using the BlackIceDEVMODE.OCX  control.

 

The order in which the events will arrive is the following (example of a two page document):

1.    ChangeDevmode

2.    StartDoc

 

3.    ChangeDevmode

4.    StartPage

5.    EndPage

 

6.    ChangeDevmode

7.    StartPage

8.    EndPage

 

9.    EndDoc

 

Different members of the Devmode structure need to be set at different stages of the printing process, therefore it is best to set the parameters you want to change every time the ChangeDevmode event fires.

 

For more information about how to use the Messaging Interface and how to change values of the Devmode Structure, please see the Message Capture C++, C#, VB.NET or Delphi sample and the Sample for Changing the Output Directory C++, C#, VB.NET samples.

 

If the application is started by the Printer Driver’s “Start Application Before Printing” feature, the application is started at the StartDoc event and the printer driver will not wait for it. This means the application will not receive the first ChangeDevmode event, and depending on how fast it starts and how fast the printing progresses, it might not receive any messages at all.

 

This also means that if you want to change the Devmode structure, your application must run in the background and wait for the events continuously instead of being started by the Printer Driver, or use the plugin interface (BiPlugin.dll) instead of the Messaging Interface. (Especially when changing settings like file type and output directory or filename, which must be set at the first time the ChangeDevmode event fires)

 

If you want the Printer Driver to wait for your application or you want the ability to abort the printing process, you must use the plugin interface.

The Save As dialog pops up before your application gets the ChangeDevmode event, therefor the Save As dialog can’t be enabled or disabled in the handler of the ChangeDevmode events.

 

If you want to disable the Save As dialog when your application is running, the DisableSaveAsOption function of the BlackIceDEVMODE DLL or OCX control should be called when the application starts and the EnableSaveAsOption function should be called when the application closes. In this case, when the application is running the Save As dialog won’t pop up at printings. The Save As dialog cannot be disabled for individual print jobs.