Page 1 of 5

FWH 13:09 Default Printer

PostPosted: Thu Oct 03, 2013 12:23 pm
by ORibeiro
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?

Re: FWH 13:08 Default Printer

PostPosted: Thu Oct 03, 2013 7:48 pm
by kok joek hoa
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

Re: FWH 13:08 Default Printer

PostPosted: Sat Oct 05, 2013 1:53 am
by ORibeiro
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?

Re: FWH 13:08 Default Printer

PostPosted: Mon Oct 07, 2013 9:27 am
by Antonio Linares
Oscar,

> Does anyone know what is that line?

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

Re: FWH 13:08 Default Printer

PostPosted: Mon Oct 07, 2013 10:19 am
by ORibeiro
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.

Re: FWH 13:08 Default Printer

PostPosted: Mon Oct 07, 2013 10:39 am
by Antonio Linares
Please try to use the proposed change by Kok, thanks:

Code: Select all  Expand view
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

   ...
 

Re: FWH 13:08 Default Printer

PostPosted: Mon Oct 07, 2013 11:00 am
by ORibeiro
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.

Re: FWH 13:08 Default Printer

PostPosted: Mon Oct 07, 2013 11:10 am
by Enrico Maria Giordano
Oscar,

this is what I'm using:

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

   ...
 


EMG

Re: FWH 13:08 Default Printer

PostPosted: Mon Oct 07, 2013 11:13 am
by Antonio Linares
Enrico,

Do you mean that you have replaced:
Code: Select all  Expand view
  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: Select all  Expand view
  else
      ::hDC = PRINTERDCFROMNAME( STRTOKEN( GETPROFSTRING( "Devices", cModel, "" ), 1, "," ), cModel, STRTOKEN( GETPROFSTRING( "Devices", cModel, "" ), 2, "," ) )
   endif


thanks

Re: FWH 13:08 Default Printer

PostPosted: Mon Oct 07, 2013 11:24 am
by Enrico Maria Giordano
Antonio,

Antonio Linares wrote:Enrico,

Do you mean that you have replaced:
Code: Select all  Expand view
  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: Select all  Expand view
  else
      ::hDC = PRINTERDCFROMNAME( STRTOKEN( GETPROFSTRING( "Devices", cModel, "" ), 1, "," ), cModel, STRTOKEN( GETPROFSTRING( "Devices", cModel, "" ), 2, "," ) )
   endif


thanks


Yes, my friend. :-)

EMG

Re: FWH 13:08 Default Printer

PostPosted: Mon Oct 07, 2013 11:33 am
by ORibeiro
Eurico / Linares,

My program is processing this elseif...
Code: Select all  Expand view

   elseif cModel == nil
      ::hDC := GetPrintDefault( GetActiveWindow() )
      if ::hDC != 0
         cModel = ::GetModel() + "," + ::GetDriver() + "," + ::GetPort()
      endif
 


So I changed this:
Code: Select all  Expand view

   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?

Re: FWH 13:08 Default Printer

PostPosted: Mon Oct 07, 2013 8:50 pm
by Antonio Linares
Oscar,

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

Re: FWH 13:08 Default Printer

PostPosted: Tue Oct 08, 2013 10:49 am
by ORibeiro
Linares,

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

Another idea?

Re: FWH 13:08 Default Printer

PostPosted: Tue Oct 08, 2013 12:06 pm
by Antonio Linares
Oscar,

Please check whats the value for cModel:

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

Re: FWH 13:08 Default Printer

PostPosted: Tue Oct 08, 2013 1:40 pm
by ORibeiro
With PDF Printer:
PDF reDirect v2,winspool,PDF_REDIRECT_PORT:

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

Thanks.