by Richard Chidiak » Fri Apr 30, 2010 8:22 am
Hua
This is the function i use for printing
It works ok on windows 7 64 bits
HTH
Richard
[code][
#define DMPAPER_A4 9 // A4 210 x 297 mm
FUNCTION GETOPRN(OPRN)
LOCAL AIMPRI := {}, ;
LCRE := .F., ;
CMODEL
LOCAL cIniFile := INILOGI()
AIMPRI := GETIMPRI(@AIMPRI)
IF LEN(AIMPRI) = 1
OPRN := TPrinter():New(LOGINOM() + " Impression", .F. , .T. , AIMPRI[1] , .T. )
LCRE := .T.
ELSE
IF GetPvProfString("USER","PRINTDEF",,CINIFile ) = "O"
IF FILE("CAISSE.DBF")
cMODEL := GetProfString( "windows", "device" , "" ) // CHIDIAL
OPRN := TPrinter():New(LOGINOM() + " Impression", .F. , .T.,CMODEL, .T. )
ELSE
OPRN := TPrinter():New(LOGINOM() + " Impression", .F. , .T., , .T. )
ENDIF
LCRE := .T.
ENDIF
ENDIF
IF ! LCRE
MsgRun( "Sélection Imprimante en cours...", "Veuillez Patienter", ;
{ || SELIMPRI(@OPRN) } )
ENDIF
IF oPrn:hDC = 0
RETURN(.F.)
ENDIF
oPrn:SetPage(DMPAPER_A4)
RETURN .T.
STATIC FUNCTION SELIMPRI(OPRN)
OPRN := TPrinter():New(LOGINOM() + " Impression", .T., .T. , , .T. )
RETURN NIL
FUNCTION GETIMPRI(ADEVICES)
*----------------------------------------
LOCAl 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
WHILE ! EMPTY(cPort := StrToken(cEntry,J++,","))
// AADD(aDevices,TRIM(cName))
AADD(aDevices,TRIM(cName) + "," + CENTRY) // CHIDIAK
ENDDO
NEXT
RETURN aDevices
/code]