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
Re: FWH 13:09 Default Printer
Posted: Wed Nov 13, 2013 03: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
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Re: FWH 13:09 Default Printer
Posted: 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

FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 187
Joined: Mon Oct 20, 2008 06:33 PM
Re: FWH 13:09 Default Printer
Posted: 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
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Re: FWH 13:08 Default Printer
Posted: Thu Nov 14, 2013 03: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 (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
FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: FWH 13:09 Default Printer
Posted: Thu Nov 14, 2013 05:16 PM
This is the current source code once fixed:

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
      ::hDC = PrinterDcFromName( , cModel, )
   endif
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 187
Joined: Mon Oct 20, 2008 06:33 PM
Re: FWH 13:09 Default Printer
Posted: Thu Nov 14, 2013 06: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 (fw): Select all Collapse
   else
msginfo( cModel )
      ::hDC = PrinterDcFromName( , cModel, )
   endif


Change 2:
Code (fw): Select all Collapse
   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
Posts: 187
Joined: Mon Oct 20, 2008 06:33 PM
Re: FWH 13:09 Default Printer
Posted: Thu Nov 14, 2013 06:31 PM
The function for the user to select a new printer and change cModel is:

Code (fw): Select all Collapse
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
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: FWH 13:09 Default Printer
Posted: Thu Nov 14, 2013 08: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
Posts: 187
Joined: Mon Oct 20, 2008 06:33 PM
Re: FWH 13:09 Default Printer
Posted: Thu Nov 14, 2013 09: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
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: FWH 13:09 Default Printer
Posted: 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
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: FWH 13:09 Default Printer
Posted: 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
Posts: 187
Joined: Mon Oct 20, 2008 06:33 PM
Re: FWH 13:09 Default Printer
Posted: Fri Nov 15, 2013 02: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
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Re: FWH 13:09 Default Printer
Posted: Fri Nov 15, 2013 04:15 PM

What value has cModel ?

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

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 187
Joined: Mon Oct 20, 2008 06:33 PM
Re: FWH 13:09 Default Printer
Posted: Fri Nov 15, 2013 06: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
Posts: 4840
Joined: Fri Nov 18, 2005 04:52 PM
Re: FWH 13:09 Default Printer
Posted: Fri Nov 15, 2013 07: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

FWH 18.05/xHarbour 1.2.3/BCC7/Windows 10