FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour FWH 13.12 printer SetCopies problem
Posts: 130
Joined: Sat Oct 08, 2005 09:38 PM
FWH 13.12 printer SetCopies problem
Posted: Sun Jan 19, 2014 11:21 AM
Hello,
After I switch to FWH 13.12, I faced with a strange problem with the function oPrn:SetCopies(n).
If I use this function, My program always prints to de default printer.

Code (fw): Select all Collapse
#INCLUDE "FiveWin.ch"
FUNCTION Main()
LOCAL oPrn, aPrinters:=aGetPrinters()

   PRINT oPrn TO aPrinters[5]
   
   oPrn:SetCopies(2)  // If I remove this line, everything is OK, It will print to aPrinters[5]
                      // otherwise it will always print to default printer (aPrinters[3] in my case)
   PAGE
      oPrn:Say( 1, 1, "Hello" )
   ENDPAGE
   
   ENDPRINT
RETURN NIL


Regards,
Birol Betoncu
Birol Betoncu
birol.betoncu@gmail.com
Using Harbour, FWH 19.05, BCC7
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: FWH 13.12 printer SetCopies problem
Posted: Sun Jan 19, 2014 02:00 PM

Birol,

Instead of calling oPrn:SetCopies( 2 ) please do PrnSetCopies( 2 ) and let me know your results, thanks

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 130
Joined: Sat Oct 08, 2005 09:38 PM
Re: FWH 13.12 printer SetCopies problem
Posted: Sun Jan 19, 2014 04:32 PM

Antonio,
Thanks for your help. It is working now. :D

Birol Betoncu
birol.betoncu@gmail.com
Using Harbour, FWH 19.05, BCC7
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Re: FWH 13.12 printer SetCopies problem
Posted: Wed Jan 22, 2014 04:31 PM
Antonio,

The problem seems to be in the Rebuild() method of TPrinter. It is calling the getPrnDefault():

Code (fw): Select all Collapse
      ::hDC := GetPrintDefault( GetActiveWindow() )


Which is changing the current printer to the default printer. Since the Rebuild() method is called from setCopies() and a lot of other methods, it seems this needs to be fixed.

James
FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 105
Joined: Fri Jun 09, 2006 03:27 PM
Re: FWH 13.12 printer SetCopies problem
Posted: Wed Jan 22, 2014 07:12 PM

I have a different question relating to number of copies to print. I would like my user to be able to simply select on the printer setup dialog the number of copies to print.

printersetup() dialog does not have a "Copies to Print" option...is there a fix for this?

Regards,

Greg Gammon
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Re: FWH 13.12 printer SetCopies problem
Posted: Thu Jan 23, 2014 12:10 AM
Greg,

printersetup() dialog does not have a "Copies to Print" option...is there a fix for this?


Why not just design your own printer-setup dialog with a number of copies field? Then you can set it by calling oPrn:setCopies().

Regards,
James
FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 105
Joined: Fri Jun 09, 2006 03:27 PM
Re: FWH 13.12 printer SetCopies problem
Posted: Thu Jan 23, 2014 02:46 PM

Thanks James....was just hoping there was something simple I wasn't aware of. I might do that...someday...but have 100 other more important things to implement first :x

Regards,

Greg Gammon
Posts: 824
Joined: Thu Oct 13, 2005 07:39 AM
Re: FWH 13.12 printer SetCopies problem
Posted: Fri Jan 24, 2014 07:30 AM
James,

Why not just design your own printer-setup dialog with a number of copies field? Then you can set it by calling oPrn:setCopies().


oPrn:SetCopies() is calling the method Rebuild(), which always sets the default printer. Maybe it´s the best solution is to remove the call of Rebuild() from the methods :SetCoppies(), :SetLandscape(), :SetPortrait(), :SetSize(), :SetPage() and :SetBin(). This avoids setting the device to the default printer.

I see no sense to change the setting of the choosen device first and then reset that device to another.
kind regards

Stefan
Posts: 824
Joined: Thu Oct 13, 2005 07:39 AM
Re: FWH 13.12 printer SetCopies problem
Posted: Fri Jan 24, 2014 07:50 AM
Inside the method Rebuild() I don´t undersatnd that line

Code (fw): Select all Collapse
if ::hDC != 0  // <--------
      DeleteDC( ::hDC )
      ::hDC := GetPrintDefault( GetActiveWindow() )
      ::lStarted   := .F.
      ::lModified  := .T.
   endif


That means the default printer is only set, if a device is already active, why ?

I think, it´s more logical only to set the default printer if no device is selected

Code (fw): Select all Collapse
if ::hDC = 0  // no device active, set the default printer
      //DeleteDC( ::hDC )
      ::hDC := GetPrintDefault( GetActiveWindow() )
      ::lStarted   := .F.
      ::lModified  := .T.
   endif


Please Antonio, could you check this change.

If I´m wrong, please could you explain that code snippet to me, thanks.
kind regards

Stefan
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: FWH 13.12 printer SetCopies problem
Posted: Fri Jan 24, 2014 08:55 AM
Stefan,

Yes, you are right, I agree with you that this seems to be the right fix (Method Rebuild()):

Code (fw): Select all Collapse
   if ::hDC == 0
      ::hDC       = GetPrintDefault( GetActiveWindow() )
      ::lStarted  = .F.
      ::lModified = .T.
   endif


I appreciate feedback to be sure that this way we don't break existing code, thanks
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 824
Joined: Thu Oct 13, 2005 07:39 AM
Re: FWH 13.12 printer SetCopies problem
Posted: Sat Jan 25, 2014 11:33 AM
Antonio,

I made this small test-function

Code (fw): Select all Collapse
#include "Fivewin.ch"

Procedure Main()

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

aPrn := GetPrinters ()

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

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,22 BUTTON "&Print" OF oWnd ACTION Testprint (aPrn[i])
   @ 2,22 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


Everything seems to be fine, the printer is correct, the settings are correct (2 copies, landscape), but the printer ignores these settings. It prints only 1 copy in portrait.
I tested it on 2 computers, with local printers an network printers, always just 1 copy.

Printing from Word works fine with 2 copies.

Is anyone able, to print more than 1 copy with this code ?
kind regards

Stefan
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Re: FWH 13.12 printer SetCopies problem
Posted: Sat Jan 25, 2014 04:47 PM

Stefan,

Are you using the fixed Rebuild() method?

James

FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 824
Joined: Thu Oct 13, 2005 07:39 AM
Re: FWH 13.12 printer SetCopies problem
Posted: Sat Jan 25, 2014 07:39 PM

Yes

kind regards

Stefan
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: FWH 13.12 printer SetCopies problem
Posted: Sun Jan 26, 2014 08:47 AM

Stefan,

Many thanks for your great example. I am testing it here but only have the XPS and the Fax drivers (I am not at the office right now) and they don't allow multiple copies.

I appreciate if some others test it with different installed printers, thanks

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 824
Joined: Thu Oct 13, 2005 07:39 AM
Re: FWH 13.12 printer SetCopies problem
Posted: Wed Jan 29, 2014 09:05 AM

Hmm, really nobody who wants to help to solve this problem ? :(

Please, can anyone run the small test and report the results, many thanks.

kind regards

Stefan