Hasta el momento, todo compila con normalidad con BCC77 y XHBBCC77. Ampliaremos las pruebas con otros modelos de uso.
// C:\FWH\SAMPLES\ATIVAPRN.PRG - FWH2603 - BCC77 - XHBBCC77
// 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
REQUEST HB_LANG_PT
REQUEST HB_CODEPAGE_PT850
STATIC oWnd, oPrn
FUNCTION Main()
LOCAL oSkinB, oBtn, oBtn2, oFont, cTitle
SET CENTURY ON
SET DATE BRITISH
SET TIME FORMAT TO "HH:MM:SS"
SET EPOCH TO YEAR( DATE() ) - 30
SET SOFTSEEK OFF
SET WRAP ON
SETCANCEL( .F. )
SET CONFIRM OFF
SET DELETED ON
SET _3DLOOK ON
SET UNIQUE OFF
SET ESCAPE OFF
SET EXACT ON
SET EXCLUSIVE OFF
SET MULTIPLE OFF
SET OPTIMIZE ON
HB_GCALL( .F. )
HB_LANGSELECT( 'PT' ) // Default language is now Portuguese
HB_SETCODEPAGE( "PT850" )
HB_CDPSELECT( "PTISO" )
SetBalloon( .T. ) // Balloon shape required for tooltips
oSkinB = TSkinButton():New()
oSkinB:nClrBorder0_N := RGB( 249, 194, 179 )
oSkinB:nClrBorder1_N := RGB( 181, 61, 29 )
oSkinB:aClrNormal := { { .50, nRGB( 210, 235, 216 ), nRGB( 210, 235, 216 ) } }
SkinButtons( oSkinB )
cTitle := "ATIVAPRN.PRG: Printing a Test - Imprimindo um Teste."
DEFINE FONT oFont NAME "Ms Sans Serif" SIZE 0, -12
DEFINE WINDOW oWnd FROM 1, 1 TO 20, 60 TITLE cTitle
@ 3, 3 BUTTON oBtn PROMPT "&Print me" OF oWnd SIZE 80, 20 ;
ACTION( IMPR_MODELO() )
oBtn:cTooltip := "Imprimir um teste - Print me"
@ 3, 25 BUTTON oBtn2 PROMPT "&Exit" OF oWnd SIZE 80, 20 ACTION( oWnd:End() )
oBtn2:cTooltip := "Salida - Exit"
SET MESSAGE OF oWnd TO "©Kapiaba - www.fivewin.com.br" FONT oFont ;
NOINSET CLOCK DATE KEYBOARD COLOR CLR_HBLUE, CLR_WHITE 2007
ACTIVATE WINDOW oWnd CENTERED
HB_GCALL( .T. )
oFont:End()
RETURN NIL
FUNCTION IMPR_MODELO()
LOCAL oFont, nRowStep, nColStep, nRow := 0, nCol := 0, n, m, oPrn, aPrn
aPrn := GetPrinters()
IF Empty( aPrn )
MsgStop( "Nenhuma Impressora Encontrada", "Nenhuma Impressora Encontrada" )
RETURN NIL
ENDIF
PRINTER oPrn PREVIEW MODAL
IF EMPTY( oPrn:hDC )
MsgInfo( "ALGUMA COISA OCORREU DE ERRADO COM A IMPRESSORA.", "LIGUE A IMPRESSORA." )
oPrn:End()
RETURN NIL
ENDIF
oPrn:End()
// PARA TODOS OS RELATORIOS DO SISETMA.
IF( .NOT. IMPR_ATIVA() ) // PROBLEMAS NA IMPRESSORA?
RETURN NIL
ENDIF
// Impressora OK, imprimir
PRINT oPrn NAME "Testing the printer object from FiveWin" PREVIEW MODAL
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
// Verificar estado da impressora antes de imprimir
FUNCTION IMPR_ATIVA() // FUNCAO PARA TODOS OS RELATORIOS.
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( .F. )
ENDIF
RETURN( .T. )
// FIN / END - kapiabafwh@gmail.comRegards, saludos.
