FWH 13.12 printer SetCopies problem

Re: FWH 13.12 printer SetCopies problem

Postby StefanHaupt » Wed Jan 29, 2014 10:53 am

Antonio,

for another test I enhanced my example. I intergrated a second function for printing, but only with (x)Harbour functions, using the Win32Prn object. Please see function Test2 (..). This sample is now working with xHarbour and Harbour.

Code: Select all  Expand view
#include "FiveWin.ch"
#include "Objects.ch"

Procedure Main ()

LOCAL oPrn, oPrint,oFnt, cPrinter := ""
LOCAL oWnd, oBrw
LOCAL aPrn := {}
LOCAL cDef, i := 1

#ifdef __HARBOUR__          // GetPrinters() and GetDefaultPrinter() do not work in Harbour
  aPrn := aGetPrinters ()
  cDef := ""
#else
  aPrn := GetPrinters ()
  cDef := GetDefaultPrinter()
#endif

IF Empty (aPrn)
  MsgAlert ("No Printers found" )//+ CRLF +;
  RETURN
ENDIF

DEFINE DIALOG oWnd FROM 2, 2 TO 21, 50 TITLE "Available Printers"

@ 1, 2 LISTBOX oBrw FIELDS aPrn[ i ] ;
      HEADERS "Printer Array" ;
      FIELDSIZES 200 ;
      OF oWnd ;
      SIZE 100, 100

   oBrw:bGoTop    = { || i := 1 }
   oBrw:bGoBottom = { || i := Eval( oBrw:bLogicLen )}
   oBrw:bSkip     = { | nWant, nOld | nOld := i, i += nWant, ;
                        i := Max( 1, Min( i, Eval( oBrw:bLogicLen ) ) ),;
                        i - nOld }
   oBrw:bLogicLen = { || Len( aPrn ) }
   oBrw:cAlias    = "Array"                // Just put something

   @ 7.8,2 SAY "Default printer: " + cDef

   @ 1,20 BUTTON "&Print (FW)" OF oWnd ACTION Testprint (aPrn[i])
   @ 2,20 BUTTON "&Print (xH)" OF oWnd ACTION Test2 (aPrn[i])
   @ 3,20 BUTTON "&End       " OF oWnd ACTION oWnd:End()

ACTIVATE DIALOG oWnd CENTERED

RETURN


//-----------------------------------------------------------------------
PROCEDURE TestPrint(cPrn)

LOCAL oFnt, oPrint
LOCAL cText := "Dies ist ein Testtext zum drucken"

IF MsgYesNo ("Print to " + cPrn)

   PRINT oPrint NAME "Formular" TO (cPrn)

  DEFINE FONT oFnt NAME "ARIAL" SIZE 0,12 OF oPrint

  oPrint:SetCopies (2)
  oPrint:SetLandscape()

  oPrint:Setup ()   // check the settings

  PAGE
    oPrint:CmSay (1,1, cText,oFnt)
  ENDPAGE

  ENDPRINT

  oFnt:End()
ENDIF


RETURN


#define  RGB_BLACK       RGB(   0,  0,  0 )
#define  RGB_RED         RGB( 255,  0,  0 )
#define  RGB_GREEN       RGB(   0,255,  0 )
#define  RGB_BLUE        RGB(   0,  0,255 )
#define  RGB_CYAN        RGB(   0,255,255 )
#define  RGB_YELLOW      RGB( 255,255,  0 )
#define  RGB_MAGENTA     RGB( 255,  0,255 )
#define  RGB_WHITE       RGB( 255,255,255 )

#define FW_DONTCARE    0
#define FW_THIN        100
#define FW_EXTRALIGHT  200
#define FW_LIGHT       300
#define FW_NORMAL      400
#define FW_MEDIUM      500
#define FW_SEMIBOLD    600
#define FW_BOLD        700
#define FW_EXTRABOLD   800
#define FW_HEAVY       900
#define DMPAPER_A4                             9

FUNCTION Test2 (cPrn)

      LOCAL oPrinter
      LOCAL aFonts, cFont, nFont

      oPrinter           := Win32Prn():new( cPrn)      // Create printer object and configure print job
      oPrinter:landscape := .F.
      oPrinter:formType  := DMPAPER_A4
      oPrinter:copies    := 2                                      // <--- 2 copies !!

      IF .NOT. oPrinter:create()                       // Create device context
         Alert( "Cannot create device context" )
         QUIT
      ENDIF

      IF .NOT. oPrinter:startDoc( "xHarbour test page" )   // Create print job
         Alert( "Cannot create document" )
         QUIT
      ENDIF

      oPrinter:textOut( "Text in default font" )       // Text in fixed font
      oPrinter:bold( FW_EXTRABOLD )
      oPrinter:textOut( oPrinter:fontName )
      oPrinter:bold( FW_NORMAL )
      oPrinter:newLine()

      aFonts := oPrinter:getFonts()
      nFont  := AScan( aFonts, ;
                       {|a| "ARIAL" $ Upper(a[1]) } )
      cFont  := aFonts[nFont,1]

      oPrinter:setFont( cFont )                       // Text in proportional font
      oPrinter:textOut( "Text in Arial font" )
      oPrinter:bold( FW_EXTRABOLD )
      oPrinter:textOut( oPrinter:fontName )
      oPrinter:bold( FW_NORMAL )
      oPrinter:newLine()

      oPrinter:setColor( RGB_YELLOW, RGB_BLUE )    // Colored text
      oPrinter:textOut( "Yellow on Blue" )
      oPrinter:newLine()

      oPrinter:setPen( PS_DASH, 5, RGB_GREEN )    // Draw colored line across page
      oPrinter:line( oPrinter:posX, ;
                     oPrinter:posY, ;
                     oPrinter:rightMargin, ;
                     oPrinter:posY  )

      oPrinter:endDoc()       // Send output to printer
      oPrinter:destroy()      // Release GDI device context

RETURN (nil)


Printing with the Win32Prn object is working as exspected, 2 copies are printed.

So it seems to be a bug in the print engine of fivewin. The settings are correct, but they seem not to be regnognized by the printer object and they are not sent to the printer.

Please, Antonio, could you check this ?
kind regards
Stefan
StefanHaupt
 
Posts: 824
Joined: Thu Oct 13, 2005 7:39 am
Location: Germany

Re: FWH 13.12 printer SetCopies problem

Postby Antonio Linares » Wed Jan 29, 2014 10:29 pm

Stefan,

Please modify this code in your example and let me know your results, thanks

Code: Select all  Expand view
IF MsgYesNo ("Print to " + cPrn)

   PRINT oPrint NAME "Formular" TO (cPrn)

  DEFINE FONT oFnt NAME "ARIAL" SIZE 0,12 OF oPrint

  oPrint:SetCopies (2)
  oPrint:SetLandscape()

  oPrint:Setup ()   // check the settings

  PAGE
    oPrint:CmSay (1,1, cText,oFnt)
  ENDPAGE

  MsgInfo( PrnGetCopies() )

  ENDPRINT

  MsgInfo( PrnGetCopies() )

  oFnt:End()
ENDIF
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41321
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: FWH 13.12 printer SetCopies problem

Postby StefanHaupt » Thu Jan 30, 2014 7:22 am

Antonio,

very curious, both times I get 2 copies, but the printer only prints 1 copy. oPrint:SetLandscape() is ignored, too.
kind regards
Stefan
StefanHaupt
 
Posts: 824
Joined: Thu Oct 13, 2005 7:39 am
Location: Germany

Re: FWH 13.12 printer SetCopies problem

Postby StefanHaupt » Thu Jan 30, 2014 12:46 pm

more curious, if I change the sample this way

Code: Select all  Expand view
PROCEDURE TestPrint(cPrn)

LOCAL oFnt, oPrint
LOCAL cText := "Dies ist ein Testtext zum drucken"

IF MsgYesNo ("Print to " + cPrn)

  PRINT oPrint NAME "Formular" FROM USER  // choose the printer

  DEFINE FONT oFnt NAME "ARIAL" SIZE 0,12 OF oPrint

//  oPrint:SetCopies (2)
//  oPrint:SetLandscape()
//  oPrint:Setup ()

  PAGE
    oPrint:CmSay (1,1, cText,oFnt)
  ENDPAGE

  MsgInfo( PrnGetCopies() )

  ENDPRINT

  MsgInfo( PrnGetCopies() )

  oFnt:End()
ENDIF

RETURN


and change the copies in the printer properties dialog to 2, it prints 2 copies, but PrnGetCopies() returns always 1.

So PrnGetCopies () reads values that does not reflect the real printer settings. PrnSetcopies() sets values that are not recognized by the OS or by the printer. Maybe thes functions are not compatible with 32/64 bit ??
kind regards
Stefan
StefanHaupt
 
Posts: 824
Joined: Thu Oct 13, 2005 7:39 am
Location: Germany

Re: FWH 13.12 printer SetCopies problem

Postby Antonio Linares » Thu Jan 30, 2014 1:23 pm

Stefan,

They are fully 32/64 bits compatible, its a different problem.

We need to sych their datas. Working on it, thanks
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41321
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: FWH 13.12 printer SetCopies problem

Postby StefanHaupt » Thu Jan 30, 2014 1:47 pm

Antonio,

ok, many thanks.

(just to explain, I suspected an incompatibility, because oPrinter:Setup() calls an old dialog, not that one I get from windows)
kind regards
Stefan
StefanHaupt
 
Posts: 824
Joined: Thu Oct 13, 2005 7:39 am
Location: Germany

Previous

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Silvio.Falconi and 12 guests