FWH 13.12 printer SetCopies problem

FWH 13.12 printer SetCopies problem

Postby betoncu » 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: Select all  Expand view
#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
User avatar
betoncu
 
Posts: 126
Joined: Sat Oct 08, 2005 9:38 pm
Location: Cyprus (North)

Re: FWH 13.12 printer SetCopies problem

Postby Antonio Linares » Sun Jan 19, 2014 2: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
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 betoncu » Sun Jan 19, 2014 4:32 pm

Antonio,
Thanks for your help. It is working now. :D
Birol Betoncu
birol.betoncu@gmail.com
Using Harbour, FWH 19.05, BCC7
User avatar
betoncu
 
Posts: 126
Joined: Sat Oct 08, 2005 9:38 pm
Location: Cyprus (North)

Re: FWH 13.12 printer SetCopies problem

Postby James Bott » Wed Jan 22, 2014 4:31 pm

Antonio,

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

Code: Select all  Expand view
     ::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
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: FWH 13.12 printer SetCopies problem

Postby Greg Gammon » Wed Jan 22, 2014 7: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?
User avatar
Greg Gammon
 
Posts: 105
Joined: Fri Jun 09, 2006 3:27 pm
Location: Bryan, Texas

Re: FWH 13.12 printer SetCopies problem

Postby James Bott » 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
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: FWH 13.12 printer SetCopies problem

Postby Greg Gammon » Thu Jan 23, 2014 2: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
User avatar
Greg Gammon
 
Posts: 105
Joined: Fri Jun 09, 2006 3:27 pm
Location: Bryan, Texas

Re: FWH 13.12 printer SetCopies problem

Postby StefanHaupt » Fri Jan 24, 2014 7: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
StefanHaupt
 
Posts: 824
Joined: Thu Oct 13, 2005 7:39 am
Location: Germany

Re: FWH 13.12 printer SetCopies problem

Postby StefanHaupt » Fri Jan 24, 2014 7:50 am

Inside the method Rebuild() I don´t undersatnd that line

Code: Select all  Expand view
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: Select all  Expand view
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
StefanHaupt
 
Posts: 824
Joined: Thu Oct 13, 2005 7:39 am
Location: Germany

Re: FWH 13.12 printer SetCopies problem

Postby Antonio Linares » Fri Jan 24, 2014 8:55 am

Stefan,

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

Code: Select all  Expand view
  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
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 » Sat Jan 25, 2014 11:33 am

Antonio,

I made this small test-function

Code: Select all  Expand view
#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
StefanHaupt
 
Posts: 824
Joined: Thu Oct 13, 2005 7:39 am
Location: Germany

Re: FWH 13.12 printer SetCopies problem

Postby James Bott » Sat Jan 25, 2014 4:47 pm

Stefan,

Are you using the fixed Rebuild() method?

James
User avatar
James Bott
 
Posts: 4840
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA

Re: FWH 13.12 printer SetCopies problem

Postby StefanHaupt » Sat Jan 25, 2014 7:39 pm

Yes
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 » Sun Jan 26, 2014 8: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
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 » Wed Jan 29, 2014 9: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
StefanHaupt
 
Posts: 824
Joined: Thu Oct 13, 2005 7:39 am
Location: Germany

Next

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 19 guests