FWH 13:09 Default Printer

Re: FWH 13:09 Default Printer

Postby ORibeiro » Wed Nov 13, 2013 3:57 pm

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.
Oscar Ribeiro
OASyS Informática
Fwh18.02 + xHarbour 1.2.3 + Bcc72
User avatar
ORibeiro
 
Posts: 187
Joined: Mon Oct 20, 2008 6:33 pm
Location: Itu, Sao Paulo, Brazil

Re: FWH 13:09 Default Printer

Postby James Bott » Wed Nov 13, 2013 11:46 pm

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

Re: FWH 13:09 Default Printer

Postby ORibeiro » Thu Nov 14, 2013 10:11 am

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.
Oscar Ribeiro
OASyS Informática
Fwh18.02 + xHarbour 1.2.3 + Bcc72
User avatar
ORibeiro
 
Posts: 187
Joined: Mon Oct 20, 2008 6:33 pm
Location: Itu, Sao Paulo, Brazil

Re: FWH 13:08 Default Printer

Postby James Bott » Thu Nov 14, 2013 3:07 pm

Oscar,

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  Expand view  RUN
  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  RUN
  else
      ::hDC = PRINTERDCFROMNAME( STRTOKEN( GETPROFSTRING( "Devices", cModel, "" ), 1, "," ), cModel, STRTOKEN( GETPROFSTRING( "Devices", cModel, "" ), 2, "," ) )
   endif


thanks


Yes, my friend. :-)

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

Re: FWH 13:09 Default Printer

Postby Antonio Linares » Thu Nov 14, 2013 5:16 pm

This is the current source code once fixed:

Code: Select all  Expand view  RUN
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
Antonio Linares
Site Admin
 
Posts: 42122
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: FWH 13:09 Default Printer

Postby ORibeiro » Thu Nov 14, 2013 6:21 pm

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  Expand view  RUN

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


Change 2:
Code: Select all  Expand view  RUN

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

Re: FWH 13:09 Default Printer

Postby ORibeiro » Thu Nov 14, 2013 6:31 pm

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

Code: Select all  Expand view  RUN

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
Oscar Ribeiro
OASyS Informática
Fwh18.02 + xHarbour 1.2.3 + Bcc72
User avatar
ORibeiro
 
Posts: 187
Joined: Mon Oct 20, 2008 6:33 pm
Location: Itu, Sao Paulo, Brazil

Re: FWH 13:09 Default Printer

Postby Enrico Maria Giordano » Thu Nov 14, 2013 8:28 pm

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
Enrico Maria Giordano
 
Posts: 8718
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: FWH 13:09 Default Printer

Postby ORibeiro » Thu Nov 14, 2013 9:09 pm

Mu Fwh is the last one.

Fwh13.09 rev2 don't have this fix?
Oscar Ribeiro
OASyS Informática
Fwh18.02 + xHarbour 1.2.3 + Bcc72
User avatar
ORibeiro
 
Posts: 187
Joined: Mon Oct 20, 2008 6:33 pm
Location: Itu, Sao Paulo, Brazil

Re: FWH 13:09 Default Printer

Postby Enrico Maria Giordano » Thu Nov 14, 2013 10:37 pm

ORibeiro wrote:Mu Fwh is the last one.

Fwh13.09 rev2 don't have this fix?


Yes, it has, of course.

EMG
User avatar
Enrico Maria Giordano
 
Posts: 8718
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: FWH 13:09 Default Printer

Postby Antonio Linares » Fri Nov 15, 2013 12:38 pm

Oscar,

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
Antonio Linares
Site Admin
 
Posts: 42122
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: FWH 13:09 Default Printer

Postby ORibeiro » Fri Nov 15, 2013 2:59 pm

The :hDC show me a number and prints to the "default printer on the windows" and not in the selected by the user.
Oscar Ribeiro
OASyS Informática
Fwh18.02 + xHarbour 1.2.3 + Bcc72
User avatar
ORibeiro
 
Posts: 187
Joined: Mon Oct 20, 2008 6:33 pm
Location: Itu, Sao Paulo, Brazil

Re: FWH 13:09 Default Printer

Postby Antonio Linares » Fri Nov 15, 2013 4:15 pm

What value has cModel ?

And what do you get for GetProfString( "Devices" ) ?
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 42122
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: FWH 13:09 Default Printer

Postby ORibeiro » Fri Nov 15, 2013 6:02 pm

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.
Oscar Ribeiro
OASyS Informática
Fwh18.02 + xHarbour 1.2.3 + Bcc72
User avatar
ORibeiro
 
Posts: 187
Joined: Mon Oct 20, 2008 6:33 pm
Location: Itu, Sao Paulo, Brazil

Re: FWH 13:09 Default Printer

Postby James Bott » Fri Nov 15, 2013 7:08 pm

Oscar,

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

PreviousNext

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 41 guests