FWH 13:09 Default Printer

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

Re: FWH 13:09 Default Printer

Post by ORibeiro »

Problem 1:
- Sorry, but I did not understand what I do to preserve the printer that was selected.

Problem 2:
- Another problem is that the view factor is not working and the magnifying glass distorts the image on a widescreen monitor.

Problem 3:
- If I change the printer button that makes it into the viewer, it does not print after.
_ Ribeiro
OASyS Informática
Fwh18.02 + xHarbour 1.2.3 + Bcc72
User avatar
James Bott
Posts: 4654
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA
Contact:

Re: FWH 13:09 Default Printer

Post by James Bott »

Just to clarify standard Windows printer behavior.

I have not read this entire thread, so some of this may have already been mentioned. It took me some time to figure this all out by trial and error.

The "windows default printer" is selected automatically by any app when it opens and also remains the selected printer unless it it is changed within the app.

If an app selects a printer, it is then used within that app until the app is closed. This selection does not affect any other apps. And it does not affect the windows default printer. Of course, an app could override this behavior by saving and restoring it's own printer selections. This may or may not be advisable. I have used this occasionally when different reports needed to be sent to different printers (within the same app).

It is possible to change the windows default printer from within an app, but I would suggest never doing it. Doing so would mess up all other apps that are relying on the windows default printer (that was set via the Windows printer-setup routine).

You could provide the user the option to save the selected printer for use only within that app. Just save the printer model in a config file, then restore it whenever the program is run.

So, _, if your app is loosing the selected printer, it would seem that FWH/(x)Harbour is doing it and it is not the Windows standard.

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

Re: FWH 13:09 Default Printer

Post by ORibeiro »

James,

Thanks for your reply.

Before migrating to FWH13.08, I used the fwh12.07 and once selected a printer that is different from the standard Windows ward stood just inside the selected application and while it was open.

Now my system does not do that anymore and each report the user needs to select the printer again. This has caused me numerous complaints from my clients.

It seems to me that the Linares FWH13.09 resolved it in but I did not understand what should I change in my programs.

I await.
_ Ribeiro
OASyS Informática
Fwh18.02 + xHarbour 1.2.3 + Bcc72
User avatar
James Bott
Posts: 4654
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA
Contact:

Re: FWH 13:08 Default Printer

Post by James Bott »

_,

As was mentioned earlier in this message thread, in the FWH source program PRINTER.PRG find the METHOD NEW() and in this method replace the code as shown below. Then compile the changed program and link it into your program.

Regards,
James

Enrico Maria Giordano wrote: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
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Re: FWH 13:09 Default Printer

Post by Antonio Linares »

This is the current source code once fixed:

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
      ::hDC = PrinterDcFromName( , cModel, )
   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:09 Default Printer

Post by ORibeiro »

Unfortunately, neither of the two alternatives work.

The "MsgInfo(CModel)" shows the printer selected by the user but prints to another printer that is default in Windows.

Change 1:

Code: Select all

   else
msginfo( cModel )
      ::hDC = PrinterDcFromName( , cModel, )
   endif
 
Change 2:

Code: Select all

   else
msginfo( cModel )
    ::hDC = PRINTERDCFROMNAME( STRTOKEN( GETPROFSTRING( "Devices", cModel, "" ), 1, "," ), cModel, STRTOKEN( GETPROFSTRING( "Devices", cModel, "" ), 2, "," ) )
   endif
 
_ Ribeiro
OASyS Informática
Fwh18.02 + xHarbour 1.2.3 + Bcc72
User avatar
ORibeiro
Posts: 174
Joined: Mon Oct 20, 2008 6:33 pm
Location: Itu, Sao Paulo, Brazil

Re: FWH 13:09 Default Printer

Post by ORibeiro »

The function for the user to select a new printer and change cModel is:

Code: Select all

Static Function oaPrinterSetup()     // Sem essa função, o FWH respeita a seleção apenas para o próximo relatório, voltando depois para o padrão do Windows.
   GetPrintDC( GetActiveWindow() )   // Abre a tela para a seleção da impressora
   cModel := PrnGetName()          // Grava a última impressora selecionada pelo usuário
Return nil
 
Then I inform cModel to print with:

PRINT ... TO cModel
_ 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:09 Default Printer

Post by Enrico Maria Giordano »

ORibeiro wrote:Unfortunately, neither of the two alternatives work.

The "MsgInfo(CModel)" shows the printer selected by the user but prints to another printer that is default in Windows.
I fixed PrinterDcFromName() function last year (if I remember correctly). Maybe your FWH version doesn't contain the fix.

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

Re: FWH 13:09 Default Printer

Post by ORibeiro »

Mu Fwh is the last one.

Fwh13.09 rev2 don't have this fix?
_ 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:09 Default Printer

Post by Enrico Maria Giordano »

ORibeiro wrote:Mu Fwh is the last one.

Fwh13.09 rev2 don't have this fix?
Yes, it has, of course.

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

Re: FWH 13:09 Default Printer

Post by Antonio Linares »

_,

Here it is working fine using ::hDC = PrinterDcFromName( , cModel, )

Have you checked the valur of ::hDC after such line ?
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:09 Default Printer

Post by ORibeiro »

The :hDC show me a number and prints to the "default printer on the windows" and not in the selected by the user.
_ 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:09 Default Printer

Post by Antonio Linares »

What value has cModel ?

And what do you get for GetProfString( "Devices" ) ?
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:09 Default Printer

Post by ORibeiro »

Default Printer in Windows = PDF reDirect V2
Selected Printer by User = \\OASYS4\Samsung SCX-4200 Series

After ::hDC = PrinterDcFromName( , cModel, )

MsgInfo( cModel ) = \\OASYS4\Samsung SCX-4200 Series
MsgInfo( GetProfString("Device") ) = CutePDF Writer

Only the first time after the user selects the printer is that the report is printed in \\OASYS4\Samsung SCX-4200 Series, the next reports are printed on PDF reDirect V2.
_ Ribeiro
OASyS Informática
Fwh18.02 + xHarbour 1.2.3 + Bcc72
User avatar
James Bott
Posts: 4654
Joined: Fri Nov 18, 2005 4:52 pm
Location: San Diego, California, USA
Contact:

Re: FWH 13:09 Default Printer

Post by James Bott »

_,

May I suggest a simple test program. First call printerSetup() so the user can select a printer. Then print a report (without passing a printer name). Then print the same report again (also without passing a printer name). Both reports should go to the same printer--the one the user selected. Make the test program as small as possible.

Let us know the results. And post the sample program code.

Regards,
James
Post Reply