FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour FWH 13:09 Default Printer
Posts: 187
Joined: Mon Oct 20, 2008 06:33 PM
FWH 13:09 Default Printer
Posted: Thu Oct 03, 2013 12:23 PM

Linares,

I'm having a lot of complaints from my clients because in the version I was using the FWH the user selected a printer and it kept while he was inside the system, but now the printer selected is valid just for the next printing. Is necessary to select again each print.

Is there anything I can do to make the FWH back to work as before?

Oscar Ribeiro

OASyS Informática

Fwh18.02 + xHarbour 1.2.3 + Bcc72
Posts: 117
Joined: Tue Jan 03, 2006 06:18 PM
Re: FWH 13:08 Default Printer
Posted: Thu Oct 03, 2013 07:48 PM

HI ORibeiro,

Yes, I confirm this problem.

So I change my code like this :

coldprinter := prnGetName()  // default printer


WriteProfString( "windows", "device",cnewprinter) // change to new printer
SetPrintDefault(cnewprinter)
PrinterInit()
SysRefresh()

....
.....

// change to default printer

WriteProfString( "windows", "device",coldprinter) // default printer
SetPrintDefault(coldprinter)
PrinterInit()
SysRefresh()

regards,

Kok

Posts: 187
Joined: Mon Oct 20, 2008 06:33 PM
Re: FWH 13:08 Default Printer
Posted: Sat Oct 05, 2013 01:53 AM

Kok,

Thanks for your reply.

The problem with SetDefaultPrinter() function "for my use" is that my clients use my programs within Windows Server and Terminal Server with the same user, for example, the user "SALES" is used by 10 vendors and in this case, when a change the default printer in Windows, switches to all others.

I need to let the default printer only within the program (such as FWH worked before) and not on Windows printers.

If I find out what the command line of the new FiveWin that returns to the system's default printer windows when closing the report I disable this line and problem solved!

Does anyone know what is that line?

Oscar Ribeiro

OASyS Informática

Fwh18.02 + xHarbour 1.2.3 + Bcc72
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: FWH 13:08 Default Printer
Posted: Mon Oct 07, 2013 09:27 AM

Oscar,

> Does anyone know what is that line?

What line do you mean ? Please copy it here, thanks

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 187
Joined: Mon Oct 20, 2008 06:33 PM
Re: FWH 13:08 Default Printer
Posted: Mon Oct 07, 2013 10:19 AM

Linares,

Thank you for your interest in helping me.

I need to know when the Fivewin causes the printer system is equal to the windows after the printing. It is this function (lines) that I need to cancel in my system, so that the printer selected by the user to keep active while the system is open.

Oscar Ribeiro

OASyS Informática

Fwh18.02 + xHarbour 1.2.3 + Bcc72
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: FWH 13:08 Default Printer
Posted: Mon Oct 07, 2013 10:39 AM
Please try to use the proposed change by Kok, thanks:

Code (fw): Select all Collapse
METHOD New( cDocument, lUser, lPreview, cModel, lModal, lSelection, cFile ) CLASS TPrinter

   local aOffset
   local cPrinter

   DEFAULT cDocument  := "FiveWin Report" ,;
       lUser := .f., lPreview := .f., lModal := .f., lSelection := .f.

   if lUser
      ::hDC := GetPrintDC( GetActiveWindow(), lSelection, PrnGetPagNums() )
      if ::hDC != 0
         cModel = ::GetModel() + "," + ::GetDriver() + "," + ::GetPort()
      endif
   elseif cModel == nil
      ::hDC  := GetPrintDefault( GetActiveWindow() )
      if ::hDC != 0
         cModel = ::GetModel() + "," + ::GetDriver() + "," + ::GetPort()
      endif
   else
      cPrinter := GetProfString( "windows", "device" , "" )
      WriteProfString( "windows", "device", cModel )
      SysRefresh()
      PrinterInit()
      ::hDC := GetPrintDefault( GetActiveWindow() )
      SysRefresh()
      WriteProfString( "windows", "device", cPrinter  )
      SetPrintDefault( cPrinter ) // NEW !!!
   endif

   ...
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 187
Joined: Mon Oct 20, 2008 06:33 PM
Re: FWH 13:08 Default Printer
Posted: Mon Oct 07, 2013 11:00 AM

Linares,

I did it.

However, I use Windows Server with Terminal Server with the same user TS is connected simultaneously by multiple people. By using command "SetPrintDefault( cPrinter )" the person changes the default printer in windows for all others who are using the same user.

So I can not use the "SetPrintDefault( cPrinter )".

I need to keep the selected printer only within the program open, without changing the Windows default printer.

Oscar Ribeiro

OASyS Informática

Fwh18.02 + xHarbour 1.2.3 + Bcc72
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: FWH 13:08 Default Printer
Posted: Mon Oct 07, 2013 11:10 AM
Oscar,

this is what I'm using:

Code (fw): Select all Collapse
   else
      ::hDC = PRINTERDCFROMNAME( STRTOKEN( GETPROFSTRING( "Devices", cModel, "" ), 1, "," ), cModel, STRTOKEN( GETPROFSTRING( "Devices", cModel, "" ), 2, "," ) )
   endif

   ...


EMG
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: FWH 13:08 Default Printer
Posted: Mon Oct 07, 2013 11:13 AM
Enrico,

Do you mean that you have replaced:
Code (fw): Select all Collapse
   else
      cPrinter := GetProfString( "windows", "device" , "" )
      WriteProfString( "windows", "device", cModel )
      SysRefresh()
      PrinterInit()
      ::hDC := GetPrintDefault( GetActiveWindow() )
      SysRefresh()
      WriteProfString( "windows", "device", cPrinter  )
      SetPrintDefault( cPrinter ) // NEW !!!
   endif


with:
Code (fw): Select all Collapse
   else
      ::hDC = PRINTERDCFROMNAME( STRTOKEN( GETPROFSTRING( "Devices", cModel, "" ), 1, "," ), cModel, STRTOKEN( GETPROFSTRING( "Devices", cModel, "" ), 2, "," ) )
   endif


thanks
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: FWH 13:08 Default Printer
Posted: Mon Oct 07, 2013 11:24 AM
Antonio,

Antonio Linares wrote:Enrico,

Do you mean that you have replaced:
Code (fw): Select all Collapse
   else
      cPrinter := GetProfString( "windows", "device" , "" )
      WriteProfString( "windows", "device", cModel )
      SysRefresh()
      PrinterInit()
      ::hDC := GetPrintDefault( GetActiveWindow() )
      SysRefresh()
      WriteProfString( "windows", "device", cPrinter  )
      SetPrintDefault( cPrinter ) // NEW !!!
   endif


with:
Code (fw): Select all Collapse
   else
      ::hDC = PRINTERDCFROMNAME( STRTOKEN( GETPROFSTRING( "Devices", cModel, "" ), 1, "," ), cModel, STRTOKEN( GETPROFSTRING( "Devices", cModel, "" ), 2, "," ) )
   endif


thanks


Yes, my friend. :-)

EMG
Posts: 187
Joined: Mon Oct 20, 2008 06:33 PM
Re: FWH 13:08 Default Printer
Posted: Mon Oct 07, 2013 11:33 AM
Eurico / Linares,

My program is processing this elseif...
Code (fw): Select all Collapse
   elseif cModel == nil
      ::hDC := GetPrintDefault( GetActiveWindow() )
      if ::hDC != 0
         cModel = ::GetModel() + "," + ::GetDriver() + "," + ::GetPort()
      endif


So I changed this:
Code (fw): Select all Collapse
   elseif cModel == nil
//    ::hDC := GetPrintDefault( GetActiveWindow() )
      ::hDC := PRINTERDCFROMNAME( STRTOKEN( GETPROFSTRING( "Devices", cModel, "" ), 1, "," ), cModel, STRTOKEN( GETPROFSTRING( "Devices", cModel, "" ), 2, "," ) )
      if ::hDC != 0
         cModel = ::GetModel() + "," + ::GetDriver() + "," + ::GetPort()
      endif


The result was that he keeps the printer selected, as I will, but no longer opens a preview of the report.

We're almost there! Any ideas?
Oscar Ribeiro

OASyS Informática

Fwh18.02 + xHarbour 1.2.3 + Bcc72
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: FWH 13:08 Default Printer
Posted: Mon Oct 07, 2013 08:50 PM
Oscar,

Try it this way:
Code (fw): Select all Collapse
   elseif cModel == nil
      cModel = ::GetModel() + "," + ::GetDriver() + "," + ::GetPort()
      ::hDC := PRINTERDCFROMNAME( STRTOKEN( GETPROFSTRING( "Devices", cModel, "" ), 1, "," ), cModel, STRTOKEN( GETPROFSTRING( "Devices", cModel, "" ), 2, "," ) )
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 187
Joined: Mon Oct 20, 2008 06:33 PM
Re: FWH 13:08 Default Printer
Posted: Tue Oct 08, 2013 10:49 AM

Linares,

I tried, but always returns zero in ::hdc and not print.

Another idea?

Oscar Ribeiro

OASyS Informática

Fwh18.02 + xHarbour 1.2.3 + Bcc72
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: FWH 13:08 Default Printer
Posted: Tue Oct 08, 2013 12:06 PM

Oscar,

Please check whats the value for cModel:

...
cModel = ::GetModel() + "," + ::GetDriver() + "," + ::GetPort()
MsgInfo( cModel )
...

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 187
Joined: Mon Oct 20, 2008 06:33 PM
Re: FWH 13:08 Default Printer
Posted: Tue Oct 08, 2013 01:40 PM

With PDF Printer:
PDF reDirect v2,winspool,PDF_REDIRECT_PORT:

With SAMSUNG Printer:
\OASYS4\Samsung SCX-4200 Series,winspool,USB001

Thanks.

Oscar Ribeiro

OASyS Informática

Fwh18.02 + xHarbour 1.2.3 + Bcc72