Club Delphi  
    FTP   CCD     Buscar   Trucos   Trabajo   Foros

Retroceder   Foros Club Delphi > Principal > Impresión
Registrarse FAQ Miembros Calendario Guía de estilo Buscar Temas de Hoy Marcar Foros Como Leídos

Respuesta
 
Herramientas Buscar en Tema Desplegado
  #1  
Antiguo 11-04-2006
jun2008 jun2008 is offline
Registrado
 
Registrado: abr 2006
Posts: 1
Poder: 0
jun2008 Va por buen camino
control de la cola de impresión

Hola a todos. Estoy intentando controlar la impresión que hace una aplicación de terceros, cuyo código, lógicamente, no puedo editar. Mi intención es poder imprimir, en una impresora matricial EPSON LQ 2180, página a página, haciendo una pausa en cada una de las páginas y mostrando una ventana en que se pueda elegir si continuar la impresión o cancelarla (antiguamente con los controladores para win98 de dicha impresora no había ningún problema en lograr tal cosa, pero con windows xp la cosa cambia). Hasta ahora lo que logro es hacer una pausa en la impresión, con el siguiente código:

Código Delphi [-]
procedure TMonitorImpresion.Timer1Timer(Sender: TObject);
var
  hPrinter: THandle;
  bytesNeeded, numJobs, i: Cardinal;
  //pJ: PJobs;
  pJ: array [0..1000] of JOB_INFO_2;
  cbBuf: DWORD;
  EstadoImpresora: DWORD;
begin
  cbBuf := 1000;
  hPrinter := GetCurrentPrinterHandle;

  EnumJobs(hPrinter, 0, 1000, 2, nil, 0, bytesNeeded, numJobs);

  if not EnumJobs(hPrinter, 0, Length(pJ), 1, @pJ, cbBuf, bytesNeeded, numJobs) then
    RaiseLastWin32Error;

  //EstadoImpresora := GetCurrentPrinterStatus;

  if numJobs = 0 then
  begin
    StringGrid1.Cells[1,1] := 'No hay trabajos en cola';
    StringGrid1.Refresh;
  end
  else
  //creamos más filas
  begin
    StringGrid1.RowCount := Pred(numJobs) + 2;
    for i := 0 to Pred(numJobs) do
    begin
      StringGrid1.Cells[0,i+1] := SavePChar(pJ[i].pPrinterName);
      StringGrid1.Cells[1,i+1] := SavePChar(pJ[i].pDocument);
      StringGrid1.Cells[2,i+1] := IntToStr(pJ[i].PagesPrinted);
      StringGrid1.Cells[3,i+1] := IntToStr(pJ[i].TotalPages);
      Case GetCurrentPrinterStatus of
        PRINTER_STATUS_PAUSED: Estado.Caption := 'Paused';
        PRINTER_STATUS_ERROR: Estado.Caption := 'Error';
        PRINTER_STATUS_PENDING_DELETION: Estado.Caption := 'Deleting...';
        PRINTER_STATUS_PAPER_JAM: Estado.Caption := 'Paper Jam';
        PRINTER_STATUS_PAPER_OUT: Estado.Caption := 'Paper Out';
        PRINTER_STATUS_MANUAL_FEED: Estado.Caption := 'Manual Feed Required';
        PRINTER_STATUS_PAPER_PROBLEM: Estado.Caption := 'Paper Problem';
        PRINTER_STATUS_OFFLINE: Estado.Caption := 'Offline';
        PRINTER_STATUS_IO_ACTIVE: Estado.Caption := 'Downloading Job';
        PRINTER_STATUS_BUSY: Estado.Caption := 'Busy';
        PRINTER_STATUS_PRINTING: Estado.Caption := 'Printing';
        PRINTER_STATUS_OUTPUT_BIN_FULL: Estado.Caption := 'Output Bill Full';
        PRINTER_STATUS_NOT_AVAILABLE: Estado.Caption := 'Not Available';
        PRINTER_STATUS_WAITING: Estado.Caption := 'Waiting';
        PRINTER_STATUS_PROCESSING: Estado.Caption := 'Processing Job';
        PRINTER_STATUS_INITIALIZING: Estado.Caption := 'Initializing';
        PRINTER_STATUS_WARMING_UP: Estado.Caption := 'Warming Up';
        PRINTER_STATUS_TONER_LOW: Estado.Caption := 'Toner Low';
        PRINTER_STATUS_NO_TONER: Estado.Caption := 'Toner Out';
        PRINTER_STATUS_PAGE_PUNT: Estado.Caption := 'Page too Complex';
        PRINTER_STATUS_USER_INTERVENTION: Estado.Caption := 'User Intervention Required';
        PRINTER_STATUS_OUT_OF_MEMORY: Estado.Caption := 'Out of Memory';
        PRINTER_STATUS_DOOR_OPEN: Estado.Caption := 'Door Open';
        PRINTER_STATUS_SERVER_UNKNOWN: Estado.Caption := 'Unable to connect';
        PRINTER_STATUS_POWER_SAVE: Estado.Caption := 'Power Save Mode';
      Else
        Estado.Caption := 'Estado de la Impresora Inespecífico';
      End
    end;

    If Ord(winspool.StartPagePrinter(hPrinter)) <> 0 then
      If EntrarMensage then
      begin
        EntrarMensage := False;
        EntrarMensage := MostrarMensage(hPrinter);
      end;
  end;
end;

Después la función mostrar mensaje:

Código Delphi [-]
function MostrarMensage(hPrinter: THandle): Boolean;
var
  n: word;
begin
  //winspool.setPrinter(hPrinter, 0, nil, PRINTER_CONTROL_PAUSE);
  winspool.setPrinter(hPrinter, 0, nil, JOB_CONTROL_PAUSE);
  If MessageDlg('Continuar con la impresión',
    mtInformation, [mbYes, mbNo], 0)= mrYes then
  begin
    winspool.setPrinter(hPrinter, 0, nil, JOB_CONTROL_RESUME);
    result := True;
  end
  else
  begin
    MonitorImpresion.PurgeJobsOnCurrentPrinter; {Purgar los trabajos de impresión}
    winspool.setPrinter(hPrinter, 0, nil, PRINTER_CONTROL_RESUME);
    result := True;
  end;

Pero no consigo más.

He mirado todas las funciones del API de windows para manejar la cola de impresión y la verdad, no se como lograrlo.

Muchas gracias a todos.

Última edición por dec fecha: 11-04-2006 a las 00:53:03.
Responder Con Cita
Respuesta


Herramientas Buscar en Tema
Buscar en Tema:

Búsqueda Avanzada
Desplegado

Normas de Publicación
no Puedes crear nuevos temas
no Puedes responder a temas
no Puedes adjuntar archivos
no Puedes editar tus mensajes

El código vB está habilitado
Las caritas están habilitado
Código [IMG] está habilitado
Código HTML está deshabilitado
Saltar a Foro

Temas Similares
Tema Autor Foro Respuestas Último mensaje
Forzar impresión de la cola del administrador Casimiro Notevi Impresión 3 05-03-2010 21:13:19
Como Saber si Hay Trabajos en la Cola de Impresión en Ensamblador? AGAG4 Varios 0 06-08-2005 00:20:42
La cola de la novia.... marcoszorrilla Humor 6 23-05-2004 19:30:13
falla getJobs() acceder a los jobs de la cola de impresion con getJobs() orfeo API de Windows 7 09-05-2004 04:32:43
Nombre de Archivo de Cola para Canvas MarcelRuz Impresión 2 04-05-2004 22:11:07


La franja horaria es GMT +2. Ahora son las 10:15:13.


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
Copyright 1996-2007 Club Delphi