FWH 13:09 Default Printer

User avatar
ORibeiro
Posts: 174
Joined: Mon Oct 20, 2008 6:33 pm
Location: Itu, Sao Paulo, Brazil

FWH 13:09 Default Printer

Post 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?
Last edited by ORibeiro on Wed Nov 13, 2013 11:46 am, edited 1 time in total.
_ Ribeiro
OASyS Informática
Fwh18.02 + xHarbour 1.2.3 + Bcc72
kok joek hoa
Posts: 117
Joined: Tue Jan 03, 2006 6:18 pm

Re: FWH 13:08 Default Printer

Post 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
User avatar
ORibeiro
Posts: 174
Joined: Mon Oct 20, 2008 6:33 pm
Location: Itu, Sao Paulo, Brazil

Re: FWH 13:08 Default Printer

Post 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?
_ Ribeiro
OASyS Informática
Fwh18.02 + xHarbour 1.2.3 + Bcc72
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: FWH 13:08 Default Printer

Post by Antonio Linares »

_,

> Does anyone know what is that line?

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

Antonio Linares
www.fivetechsoft.com
User avatar
ORibeiro
Posts: 174
Joined: Mon Oct 20, 2008 6:33 pm
Location: Itu, Sao Paulo, Brazil

Re: FWH 13:08 Default Printer

Post 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.
_ Ribeiro
OASyS Informática
Fwh18.02 + xHarbour 1.2.3 + Bcc72
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: FWH 13:08 Default Printer

Post by Antonio Linares »

Please try to use the proposed change by Kok, thanks:

Code: Select all

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
User avatar
ORibeiro
Posts: 174
Joined: Mon Oct 20, 2008 6:33 pm
Location: Itu, Sao Paulo, Brazil

Re: FWH 13:08 Default Printer

Post 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.
_ Ribeiro
OASyS Informática
Fwh18.02 + xHarbour 1.2.3 + Bcc72
User avatar
Enrico Maria Giordano
Posts: 7355
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Contact:

Re: FWH 13:08 Default Printer

Post by Enrico Maria Giordano »

_,

this is what I'm using:

Code: Select all

   else
      ::hDC = PRINTERDCFROMNAME( STRTOKEN( GETPROFSTRING( "Devices", cModel, "" ), 1, "," ), cModel, STRTOKEN( GETPROFSTRING( "Devices", cModel, "" ), 2, "," ) )
   endif

   ...
 
EMG
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: FWH 13:08 Default Printer

Post by Antonio Linares »

Enrico,

Do you mean that you have replaced:

Code: Select all

   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

   else
      ::hDC = PRINTERDCFROMNAME( STRTOKEN( GETPROFSTRING( "Devices", cModel, "" ), 1, "," ), cModel, STRTOKEN( GETPROFSTRING( "Devices", cModel, "" ), 2, "," ) )
   endif
thanks
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Enrico Maria Giordano
Posts: 7355
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Contact:

Re: FWH 13:08 Default Printer

Post by Enrico Maria Giordano »

Antonio,
Antonio Linares wrote:Enrico,

Do you mean that you have replaced:

Code: Select all

   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

   else
      ::hDC = PRINTERDCFROMNAME( STRTOKEN( GETPROFSTRING( "Devices", cModel, "" ), 1, "," ), cModel, STRTOKEN( GETPROFSTRING( "Devices", cModel, "" ), 2, "," ) )
   endif
thanks
Yes, my friend. :-)

EMG
User avatar
ORibeiro
Posts: 174
Joined: Mon Oct 20, 2008 6:33 pm
Location: Itu, Sao Paulo, Brazil

Re: FWH 13:08 Default Printer

Post by ORibeiro »

Eurico / Linares,

My program is processing this elseif...

Code: Select all

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

Code: Select all

   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?
_ Ribeiro
OASyS Informática
Fwh18.02 + xHarbour 1.2.3 + Bcc72
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: FWH 13:08 Default Printer

Post by Antonio Linares »

_,

Try it this way:

Code: Select all

   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
User avatar
ORibeiro
Posts: 174
Joined: Mon Oct 20, 2008 6:33 pm
Location: Itu, Sao Paulo, Brazil

Re: FWH 13:08 Default Printer

Post by ORibeiro »

Linares,

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

Another idea?
_ Ribeiro
OASyS Informática
Fwh18.02 + xHarbour 1.2.3 + Bcc72
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: FWH 13:08 Default Printer

Post by Antonio Linares »

_,

Please check whats the value for cModel:

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

Antonio Linares
www.fivetechsoft.com
User avatar
ORibeiro
Posts: 174
Joined: Mon Oct 20, 2008 6:33 pm
Location: Itu, Sao Paulo, Brazil

Re: FWH 13:08 Default Printer

Post by ORibeiro »

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

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

Thanks.
_ Ribeiro
OASyS Informática
Fwh18.02 + xHarbour 1.2.3 + Bcc72
Post Reply