Vcl.Printers.SetPrinter

From RAD Studio API Documentation
Jump to: navigation, search

Delphi

function SetPrinter(NewPrinter: TPrinter): TPrinter;

C++

extern DELPHI_PACKAGE TPrinter* __fastcall SetPrinter(TPrinter* NewPrinter);

Properties

Type Visibility Source Unit Parent
function public
Vcl.Printers.pas
Vcl.Printers.hpp
Vcl.Printers Vcl.Printers

Description

Replaces the global instance of TPrinter that manages interaction with the printer.

SetPrinter replaces the global TPrinter object with another TPrinter object. This allows applications to change the way they handle printing by substituting a TPrinter descendant for the default TPrinter object.

NewPrinter is the new TPrinter object that replaces the current global TPrinter object.

SetPrinter returns the previous global TPrinter object.

Note: The global TPrinter object is freed automatically when the application shuts down. After a call to SetPrinter, the printer that is returned is not automatically freed. It is the caller's responsibility to either free the return value, or replace it using another call to SetPrinter and to free the substitute printer that the second SetPrinter call returns.

SetPrinter is declared in the Printers unit. To use the SetPrinter function, add Printers to the uses clause of your unit (Delphi) or include Printers.hpp in the source file (C++) .

See Also