Foros Club Delphi

Foros Club Delphi (https://www.clubdelphi.com/foros/index.php)
-   API de Windows (https://www.clubdelphi.com/foros/forumdisplay.php?f=7)
-   -   Como detecto cuando mandan imprimir desde Windows (https://www.clubdelphi.com/foros/showthread.php?t=43268)

SISCOYMAS 07-05-2007 01:05:04

Como detecto cuando mandan imprimir desde Windows
 
Hola !!!

:confused: Como puedo detectar cuando el usuario manda imprimir cualquier cosa en windows. ?

Gracias !!!


Saludos..
Alberto Fregoso
albertofregoso@gmail.com
alebeto19@hotmail.com

cHackAll 09-05-2007 18:07:08

Solucion
 
La siguiente propiedad es la que el Delphi nos da, SOLO funciona cuando TU aplicacion imprime algo mediante la unidad "Printers"

Código Delphi [-]
uses Printers;
begin
 if Printer.Printing then ...
end.

Para saber si el S.O. está imprimiendo algo independientemente de tu aplicación pues te dejo el siguiente codigo:

Código Delphi [-]
uses WinSpool;
 
var Buffer: array [0..1024*1024-1] of Char;
 
function IsPrinting(lpPrinterName: PChar): LongBool;
var hPrinter, Count, Dummy: Cardinal; lpBuffer: PChar;
begin
 Result := False;
 if not OpenPrinter(lpPrinterName, hPrinter, nil) then Exit;
 lpBuffer := @Buffer;
 EnumJobs(hPrinter, 0, $FFFFFFFF, 1, lpBuffer, SizeOf(Buffer), Dummy, Count);
 ClosePrinter(hPrinter);
 while (Count <> 0) and not Result do
  begin
   Result := (PJobInfo1(lpBuffer).Status and JOB_STATUS_PRINTING) <> 0;
   Inc(lpBuffer, SizeOf(TJobInfo1));
   Dec(Count);
  end;
end;
procedure TForm1.Timer1Timer(Sender: TObject);
begin
 if IsPrinting('Microsoft Office Document Image Writer') then
  Caption := 'Imprimiendo...'
 else
  Caption := 'Impresora inactiva.';
end;

SISCOYMAS 10-05-2007 08:21:04

Muchas Gracias !!!!
 
Muchas Gracias por la ayuda !!!!
:D

!!!!!!!!
saludos..
Alberto Fregoso
albertofregoso@gmail.com


La franja horaria es GMT +2. Ahora son las 15:11:36.

Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Traducción al castellano por el equipo de moderadores del Club Delphi