cToPrinterTicket := LeeIniFile("CONFIG", "PRINTER_TICKET", "C:\CONFIG\PRINTERS.INI" )
cToPrinterLaser := LeeIniFile("CONFIG", "PRINTER_LAER", "C:\CONFIG\PRINTERS.INI" )
cToPinterCodeBar := LeeIniFile("CONFIG", "PRINTER_ZEBRA", "C:\CONFIG\PRINTERS.INI" )
SetPrintDefault( cToPrinterLaser )
PRINTER oPrn to cToPrinterLaser
FUNCTION LeeIniFile(cSection, cVal, cFile )
local oIni
LOCAL cStr := ''
INI oIni FILE cFile
GET cStr SECTION cSection ENTRY cVal OF oIni DEFAULT ""
ENDINI
RETURN ( cStr )
FUNCTION IMPRIMIR(cFilImp,cNroImp)
LOCAL cNomRem := ""
IF cNroImp == "3" // REMOTA X RESTAURANTES .. COMO TERCERA IMPRESORA
cNomRem := M->cImpRemNr3
ENDIF
IF cNroImp == "2" // REMOTA X RESTAURANTES .. COMO SEGUNDA IMPRESORA
cNomRem := M->cImpRemNr2
ENDIF
IF EMPTY(cNomRem)
cNomRem := M->cImpRemNr1
ENDIF
IF EMPTY(cNomRem)
cNomRem := "DEFAULT"
ENDIF
IF cNomRem <> "DEFAULT"
setprintdefault()
ENDIF
shellexecute(0,"print",cFilImp,,,.f.)
RETURN
/*
Purpose : Save and restore the current printer.
Notes : When an application is run, the current printer always defaults to the
Windows default printer. Here is how default to the last used printer in
the application. Each user can have a different default printer. The printer
name is saved in a user.ini file under the user's section.
Author : James Bott, jbott@compuserve.com
Date : 04/09/04 10:53:04
Language: Fivewin Harbour 2.4. Harbour 43 Alpha.
*/
#include "fivewin.ch"
// --- Test
FUNCTION Main()
LOCAL oIni, cPrinter := "", oUser
INI oIni FILE ".\user.ini"
oUser := TUser():new()
oUser:name := "James"
// Get application default printer for oUser
GET cPrinter section oUser:name entry "DefaultPrinter" DEFAULT prnGetName() of oIni
msgInfo( prnGetName(), "Windows default printer is:" )
msgInfo( cPrinter, "Application default printer from INI file is:" )
// Set the current printer to cPrinter
setPrinter( cPrinter )
msgInfo( prnGetName(), "Application Current printer as set via code is:" )
printerSetup()
// Save current printer as default
SET section oUser:name entry "DefaultPrinter" TO prnGetName() of oIni
RETURN NIL
// --- Set application's current printer. Returns .T. if successful.
// cPrinter must be the name of an existing print device.
FUNCTION setPrinter( cPrinter )
LOCAL cOldPrinter := "", hDC := 0, aPrn, cText := "", lSuccess := .F.
IF cPrinter <> prnGetName()
cText := StrTran( GetProfString( "Devices" ), Chr( 0 ), Chr( 13 ) + Chr( 10 ) )
aPrn := Array( MLCount( cText, 250 ) )
AEval( aPrn, {| v, e | aPrn[ e ] := Trim( MemoLine( cText, 250, e ) ) } )
IF AScan( aPrn, cPrinter ) > 0
cOldPrinter := GetProfString( "windows", "device", "" )
WriteProfString( "windows", "device", cPrinter )
SysRefresh()
PrinterInit()
hDC := GetPrintDefault( GetActiveWindow() )
IF hDC > 0
lSuccess := resetDC( hDC )
ENDIF
SysRefresh()
WriteProfString( "windows", "device", cOldPrinter )
ENDIF
ENDIF
RETURN lSuccess
// --- User class
CLASS TUser
DATA name
METHOD NEW
METHOD END virtual
ENDCLASS
METHOD new()
::name := ""
RETURN self
// eof
Return to FiveWin para Harbour/xHarbour
Users browsing this forum: Antonio Linares, Enrico Maria Giordano, richard-service and 13 guests