Hello Mark,
With my patcher, I can simplify the code.
I know that Harbour can patch the code that is spread over several lines.
But I don't remember the syntax.
Text start / text end or something like that.
Best regards,
Otto
#include "fivewin.ch"
function main
local aComboPrn := GetAllEntrys()
local I := 0
local hPRN_STATUS := {=>}
local cStatus := ""
local aPRNCheck := {}
local oPrn
local lshowPrinters := .t.
*----------------------------------------------------------
hPRN_STATUS["0" ] := "PRINTER_STATUS_OK"
hPRN_STATUS["1" ] := "PRINTER_STATUS_PAUSED"
hPRN_STATUS["2" ] := "PRINTER_STATUS_ERROR"
hPRN_STATUS["4" ] := "PRINTER_STATUS_PENDING_DELETION"
hPRN_STATUS["8" ] := "PRINTER_STATUS_PAPER_JAM"
hPRN_STATUS["16" ] := "PRINTER_STATUS_PAPER_OUT"
hPRN_STATUS["32" ] := "PRINTER_STATUS_MANUAL_FEED"
hPRN_STATUS["64" ] := "PRINTER_STATUS_PAPER_PROBLEM"
hPRN_STATUS["128" ] := "PRINTER_STATUS_OFFLINE"
hPRN_STATUS["256" ] := "PRINTER_STATUS_IO_ACTIVE"
hPRN_STATUS["512" ] := "PRINTER_STATUS_BUSY"
hPRN_STATUS["1024" ] := "PRINTER_STATUS_PRINTING"
hPRN_STATUS["2048" ] := "PRINTER_STATUS_OUTPUT_BIN_FULL"
hPRN_STATUS["4096" ] := "PRINTER_STATUS_NOT_AVAILABLE"
hPRN_STATUS["8192" ] := "PRINTER_STATUS_WAITING"
hPRN_STATUS["16384" ] := "PRINTER_STATUS_PROCESSING"
hPRN_STATUS["32768" ] := "PRINTER_STATUS_INITIALIZING"
hPRN_STATUS["65536" ] := "PRINTER_STATUS_WARMING_UP"
hPRN_STATUS["131072" ] := "PRINTER_STATUS_TONER_LOW"
hPRN_STATUS["262144" ] := "PRINTER_STATUS_NO_TONER"
hPRN_STATUS["524288" ] := "PRINTER_STATUS_PAGE_PUNT"
hPRN_STATUS["1048576" ] := "PRINTER_STATUS_USER_INTERVENTION"
hPRN_STATUS["2097152" ] := "PRINTER_STATUS_OUT_OF_MEMORY"
hPRN_STATUS["4194304" ] := "PRINTER_STATUS_DOOR_OPEN"
hPRN_STATUS["8388608" ] := "PRINTER_STATUS_SERVER_UNKNOWN"
hPRN_STATUS["16777216" ] := "PRINTER_STATUS_POWER_SAVE"
if lshowPrinters = .t.
For I:= 1 to len( aComboPrn )
if PrnStatus( aComboPrn[ I ] ) <> 0
AADD( aPRNCheck, { aComboPrn[ I ], "Printer error " + cStatus } )
endif
cStatus := ALLTRIM ( STR( PrnStatus( aComboPrn[ I ] ) ) )
TRY
AADD( aPRNCheck, { aComboPrn[ I ], hPRN_STATUS[ cStatus] } )
CATCH
AADD( aPRNCheck, { aComboPrn[ I ], "Status nicht definiert " + cStatus } )
END
/*
? GetPrintDefault()
ChangeStandardPrinter( aComboPrn[ I ] )
? ud_prngetname()
Printersetup()
*/
NEXT
xbrowse( aPRNCheck, "Printers installed - Status" )
endif
if msgYesNo('Change to printer "notexists"','Select printer' ) = .t.
ChangeStandardPrinter( "notexists" )
endif
If GetPrintDefault() = 0
//? "no default printer"
MetroMsgInfo( "Programmabbruch", "WINDOWS: There is no default printer currently selected" + CRLF +;
"Go into your Windows Control Panel and choose the Printer settings." + CRLF + CRLF +;
"Right-click the printer that you want to use, and then click Set as Default Printer."+ CRLF+;
"A check mark on the printer icon indicates that the printer is now the default printer." + CRLF + CRLF +;
"If the customer requires help with this they should refer to their IT administrator." )
else
? "Default printer " + ud_prngetname()
endif
return nil
//----------------------------------------------------------------------------//
FUNCTION GetAllEntrys() //show all printers
*----------------------------------------
local aDevices:={}, cAllEntries, cEntry, I, cName, cPrn, cPort, J
cAllEntries := STRTRAN( GetProfString( "Devices" ), Chr( 0 ), CRLF )
FOR I:= 1 TO MlCount( cAllEntries )
cName := MemoLine( cAllEntries,,I)
cEntry := GetProfString( "Devices",cName,"")
J := 2
DO WHILE ! EMPTY(cPort := StrToken(cEntry,J++,","))
*msginfo( TRIM(cName) ) +" , "+TRIM(cPort)
AADD(aDevices, TRIM( cName ))
ENDDO
NEXT
RETURN aDevices
//----------------------------------------------------------------------------//
function ChangeStandardPrinter( cPrintername )
local coldprinter := prnGetName() // default printer
*----------------------------------------------------------
if len( ALLTRIM( cPrintername ) ) > 0
WriteProfString( "windows", "device", cPrintername ) // change to new printer
SetPrintDefault( cPrintername )
PrinterInit()
SysRefresh()
endif
return( coldprinter )
//------------------------------------------------------------------------------------------//
function ud_PrnGetName()
local cret, oprn
PRINTER oPrn
cRet := oPrn:getmodel()
endprint
return cret
//------------------------------------------------------------------------------------------//
FUNCTION MetroMsgInfo( cTitel, cAnzeige1 )
local lVar := .f.
local oDlg, oGet, oBTNNaviWeiter, oBTNNaviInfo, obtnAbbruch, oCbx
local cPassword := Space( 10 )
local nWidth := GetSysMetrics( 0 )
local nHeight := GetSysMetrics( 1 )
local nLine := 0
local nRowSpace := 20
local nRowOffset := 20
local cInfo := ( procname(1) + " " + str( procline(1) ) )
local oFntMetroNormal2, oFntMetroMedium2,oFntMetroFLATBTN
local nRibbonTopClr := rgb(227, 162, 26)
*----------------------------------------------------------
DEFAULT cTitel := "Infobox"
*----------------------------------------------------------
DEFINE FONT oFntMetroNormal2 NAME "TAHOMA" SIZE 0,-22
DEFINE FONT oFntMetroMedium2 NAME "TAHOMA" SIZE 0,-32
DEFINE FONT oFntMetroFLATBTN NAME "TAHOMA" SIZE 0,-18
oFntMetroSay := TFont():New( "Calibri", 0, -13, .F.,.F.,0,0,,.F.,.F.,.F.,0,3,2,1,,34 )
//cAnzeige1 := ansiToOem(cAnzeige1)
nLine := 16
DEFINE DIALOG oDlg ;
TITLE "Auswahl" ;
FROM 0, 5 ;
TO nHeight*1/2, nWidth + 6 ;
PIXEL ;
STYLE nOr( DS_MODALFRAME, WS_POPUP ) ;
COLOR CLR_WHITE, nRibbonTopClr ;
FONT oFntMetroFLATBTN
oDlg:SetFont( oFntMetroNormal2 )
nLine := 0.5
@ nRowOffset * nLine , nWidth/5/2.05 ;
SAY cTitel ;
OF oDlg ;
PIXEL ;
FONT oFntMetroMedium2 ;
COLOR CLR_WHITE, nRibbonTopClr
nLine := 2
@ nRowOffset + nRowSpace * nLine,nWidth/5/2.05 ;
SAY cAnzeige1 ;
OF oDlg ;
PIXEL ;
FONT oFntMetroMedium2 ;
COLOR CLR_WHITE, nRibbonTopClr ;
SIZE 600, 600
*----------------------------------------------------------
@ ( nHeight*1/2 - 45 ) / 2.05,nWidth/5/2.05 ;
FLATBTN oBTNNaviWeiter ;
PROMPT "OK" ;
FONT oFntMetroFLATBTN ;
SIZE 2, ( 32 ) /2.05 ;
OF oDlg ;
ACTION ( lVar := .T., oDlg:End() ) ;
COLOR nRibbonTopClr, RGB( 210, 210, 210 ) ;
DEFAULT
@ 0,0 ;
FLATBTN oBTNNaviInfo ;
PROMPT "+" ;
FONT oFntMetroSay ;
SIZE ( 32) /2.05 , ( 32) /2.05 ;
OF oDlg ;
ACTION ( msginfo( cInfo ) ) ;
COLOR nRibbonTopClr, RGB( 210, 210, 210 )
oBTNNaviInfo:cTooltip := {"Info"}
ACTIVATE DIALOG oDlg CENTERED
RETURN NIL
//----------------------------------------------------------------------------//
Otto wrote:Hello Silvio,
/i zi pi zi/ is for FIVEWIN. And yes, you are right, I do no longer use ER.
To create HTML reports is much easier and faster.
You do not need WORD. You can use any editor to create HTML.
BTW, what WORD processor do you use?
Glad you take part in the discussion.
Best regards,
Otto
Return to FiveWin for Harbour/xHarbour
Users browsing this forum: No registered users and 55 guests