Super many thanks querido Maestro. Versión completa, Creo no haber olvidado nada. Implementaré los cambios según me los comuniquen los usuarios.
// C:\FWH\SAMPLES\PRNATIVA.PRG
// Exemplo: Verificar estado da impressora antes de imprimir
#include "FiveWin.ch"
#define PRINTER_STATUS_OK 0
#define PRINTER_STATUS_PAUSED 1
#define PRINTER_STATUS_ERROR 2
#define PRINTER_STATUS_PENDING_DELETION 4
#define PRINTER_STATUS_PAPER_JAM 8
#define PRINTER_STATUS_PAPER_OUT 16
#define PRINTER_STATUS_MANUAL_FEED 32
#define PRINTER_STATUS_PAPER_PROBLEM 64
#define PRINTER_STATUS_OFFLINE 128
#define PRINTER_STATUS_IO_ACTIVE 256
#define PRINTER_STATUS_BUSY 512
#define PRINTER_STATUS_PRINTING 1024
#define PRINTER_STATUS_OUTPUT_BIN_FULL 2048
#define PRINTER_STATUS_NOT_AVAILABLE 4096
#define PRINTER_STATUS_WAITING 8192
#define PRINTER_STATUS_PROCESSING 16384
#define PRINTER_STATUS_INITIALIZING 32768
#define PRINTER_STATUS_WARMING_UP 65536
#define PRINTER_STATUS_TONER_LOW 131072
#define PRINTER_STATUS_NO_TONER 262144
#define PRINTER_STATUS_PAGE_PUNT 524288
#define PRINTER_STATUS_USER_INTERVENTION 1048576
#define PRINTER_STATUS_OUT_OF_MEMORY 2097152
#define PRINTER_STATUS_DOOR_OPEN 4194304
#define PRINTER_STATUS_SERVER_UNKNOWN 8388608
#define PRINTER_STATUS_POWER_SAVE 16777216
STATIC oWnd, oPrn
FUNCTION Main()
DEFINE WINDOW oWnd FROM 1, 1 TO 20, 60 TITLE "Printing a Test"
@ 3, 3 BUTTON "&Print me" OF oWnd SIZE 80, 20 ;
ACTION IMPR_ATIVA()
@ 3, 25 BUTTON "&Exit" OF oWnd SIZE 80, 20 ;
ACTION( oWnd:End() )
ACTIVATE WINDOW oWnd CENTERED
RETURN NIL
FUNCTION IMPR_ATIVA()
LOCAL oFont, nRowStep, nColStep, nRow := 0, nCol := 0, n, m
LOCAL cPrinter := GetDefaultPrinter()
LOCAL nStatus := PrnStatus( cPrinter )
// Verificar estado da impressora (status sao flags de bits)
IF nStatus != PRINTER_STATUS_OK // tem problemas na impressora.
DO CASE
CASE lAnd( nStatus, PRINTER_STATUS_NOT_AVAILABLE )
MsgRun( cPrinter + " nao disponivel. Iniciando Spooler...", ;
"Status da Impressora", ;
{|| WinExec( "NET START SPOOLER", 7 ) } )
CASE lAnd( nStatus, PRINTER_STATUS_OFFLINE )
MsgStop( "Impressora offline!", , "Atenção" )
CASE lAnd( nStatus, PRINTER_STATUS_PAPER_OUT )
MsgStop( "Impressora: Sem papel!", "Atenção" )
CASE lAnd( nStatus, PRINTER_STATUS_PAPER_JAM )
MsgStop( "Impressora: Papel atolado(Modo Bandeja)", "Atenção" )
CASE lAnd( nStatus, PRINTER_STATUS_ERROR )
MsgStop( "Erro na impressora!", "Atenção" )
CASE lAnd( nStatus, PRINTER_STATUS_PAUSED )
MsgStop( "Impressora pausada!", "Atenção" )
CASE lAnd( nStatus, PRINTER_STATUS_NO_TONER )
MsgStop( "Impressora: Sem toner!", "Atenção" )
CASE lAnd( nStatus, PRINTER_STATUS_TONER_LOW )
MsgStop( "Impressora: Toner baixo!", "Atenção" )
CASE lAnd( nStatus, PRINTER_STATUS_DOOR_OPEN )
MsgStop( "Porta(ou tampa) da impressora aberta!", "Atenção" )
CASE lAnd( nStatus, PRINTER_STATUS_USER_INTERVENTION )
MsgStop( "Impressora requer Intervenção do usuário!", "Atenção" )
CASE lAnd( nStatus, PRINTER_STATUS_OUTPUT_BIN_FULL )
MsgStop( "Impressora: O compartimento de saÃda está cheio!", "Atenção" )
CASE lAnd( nStatus, PRINTER_STATUS_MANUAL_FEED )
MsgStop( "Impressora: em Modo Manual!", "Atenção" )
CASE lAnd( nStatus, PRINTER_STATUS_OUT_OF_MEMORY )
MsgStop( "Impressora: Sem Memória suficiente!", "Atenção" )
CASE lAnd( nStatus, PRINTER_STATUS_IO_ACTIVE )
MsgStop( "Impressora: com input/output(I/O) Ativo!", "Atenção" )
CASE lAnd( nStatus, PRINTER_STATUS_BUSY )
MsgStop( "Impressora: Ocupada(Lotada)!", "Atenção" )
CASE lAnd( nStatus, PRINTER_STATUS_WARMING_UP )
MsgStop( "Impressora: em Atenção(Cuidado)!", "Atenção" )
CASE lAnd( nStatus, PRINTER_STATUS_SERVER_UNKNOWN )
MsgStop( "Impressora: Servidor Desconhecido!", "Atenção" )
CASE lAnd( nStatus, PRINTER_STATUS_POWER_SAVE )
MsgStop( "Impressora: em Modo POWER_SAVE(Economia de Energia)!", "Atenção" )
OTHERWISE // outros problemas:
MsgStop( "Problema na impressora! Status: " + LTrim( Str( nStatus ) ), "Reporte ao Técnico" )
ENDCASE
RETURN NIL
ENDIF
// Impressora OK, imprimir
PRINT oPrn NAME "Testing the printer object from FiveWin" PREVIEW MODAL
IF Empty( oPrn:hDC )
RETURN NIL
ENDIF
DEFINE FONT oFont NAME "Ms Sans Serif" SIZE 0, -12 OF oPrn
nRowStep := oPrn:nVertRes() / 20
nColStep := oPrn:nHorzRes() / 15
PAGE
oPrn:SayBitmap( 1, 1, "..\bitmaps\fivewin.bmp" )
FOR n := 1 TO 20
nCol := 0
oPrn:Say( nRow, nCol, Str( n, 2 ), oFont )
nCol += nColStep
FOR m := 1 TO 15
oPrn:Say( nRow, nCol, "+", oFont )
nCol += nColStep
NEXT
nRow += nRowStep
NEXT
oPrn:Line( 0, 0, nRow, nCol )
ENDPAGE
ENDPRINT
oFont:End()
RETURN NIL
// FIN / END - kapiabafwh@gmail.com
Gracias, tks.
Regards, saludos.