PA_TryToOpenPrinterSession

4D - Documentation   Français   English   German   4D Plugin API, Command Theme List   4D Plugin API, Command Alphabetical List   Back   Previous   Next

version 2003


PA_TryToOpenPrinterSession char

ParameterTypeDescription
This command does not require any parameters
Function resultchar1:Take printer, 0:Printer already in use

Description

The routine PA_TryToOpenPrinterSession allows the 4D Extension to have exclusive access to the printer.

If the printer (or hardware/software printing device) is not currently used by any of the processes running within the 4D work session, the routine returns 1, and gives your plug-in exclusive access to the printer. If a process within the 4th Dimension work session is currently printing, the routine returns 0.

NOTE

A Plug-in cannot perform any print operation until it has exclusive access to the printer.

The plug-in developer MUST "take" the printer before printing.

Another routine of this API, PA_OpenPrinterSession, waits until the printer is not used by any other process; PA_TryToOpenPrinterSession returns immediately, even if the printer is in use.

If the 4D Plug-in directly performs print operations, it must:

Tell 4D to give it the printer by using PA_TryToOpenPrinterSession or PA_OpenPrinterSession,
Perform the actual print operations once the 4D plug-in has exclusive access to the Print Manager,
Release the printer using the PA_ClosePrinterSession once printing is finished. This cancels the 4D plug-in's exclusive access to the PrintManager.

IMPORTANT NOTE:

A successful (routine returns 0) call to PA_TryToOpenPrinterSession must be counter-balanced by a call to PA_ClosePrinterSession. If this is not done, the PrintManager will be unavailable to all the other processes for the duration of the active 4th Dimension session.

On Macintosh, this routine will call internally PrOpen, so you won't have to call it yourself.

Example

Do not print if the printer is already in use.


   void PrintIfFree()
   {
      if ( PA_TryToOpenPrinterSession() )
      {
         /* . . . printing operations . . . */

         PA_ClosePrinterSession();
      }
      else
         PA_Alert("PrinterIn use, try later.");
   }

See Also

PA_ClosePrinterSession, PA_OpenPrinterSession.

Error Handling

PA_GetLastError always return eER_NoErr


4D - Documentation   Français   English   German   4D Plugin API, Command Theme List   4D Plugin API, Command Alphabetical List   Back   Previous   Next