FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour enhancement for RPreview
Posts: 417
Joined: Tue Feb 23, 2010 03:09 PM
enhancement for RPreview
Posted: Sun May 29, 2011 07:30 PM
To let user change printer:


Code (fw): Select all Collapse
In RPreview()

[...]

     local aImpre := ListadeImpresoras(), oCbx, cCbx:= GetProfString( "windows", "device" , "" ), cImpre := cCbx // mcn


[...]



     // Let user change printer
     @ 7, 540 SAY oSay2 PROMPT "Printer:" ;
          SIZE 180, 15 PIXEL OF oBar FONT oFont


     @ 3, 610 COMBOBOX oCbx VAR cCbx ;
            PROMPTS aImpre ;
            OF oBar FONT oFont PIXEL SIZE 150,350 ;
            ON CHANGE F_CamImpre(oDevice,cCbx)



New functions.

Thank you to Mcn


Code (fw): Select all Collapse
//------------------------------------------------------------------------
// Change printer
// By Mcn
//
//
//------------------------------------------------------------------------
FUNCTION f_CamImpre (oDevice, cCbx )

   local cPrinter


    // Default printer
    cPrinter := GetProfString( "windows", "device" , "" )

    // Change printer selected
    WriteProfString( "windows", "device", cCbx )
    SysRefresh()
    PrinterInit()

    // Trick
    DeleteDC( oDevice:hDC ) // Sugestion by Enrico M. Giordano
    // Load
    oDevice:hDC := GetPrintDefault( GetActiveWindow() )
    SysRefresh()

    // Restore original printer
    WriteProfString( "windows", "device", cPrinter  )


RETURN nil
//------------------------------------------------------------------------


// ------------------------------------------------------------------------
// Printer´s List
// By Mcn
//
// ------------------------------------------------------------------------
FUNCTION ListadeImpresoras()

   local cEntries := StrTran( GetProfString( "Devices" ), Chr( 0 ), CRLF )
   local n
   local ctext
   local aPrinters := {}

   for n = 1 to MlCount( cEntries )

      cText :=  AllTrim(  MemoLine( cEntries,, n )  )+","+GetProfString( "Devices", MemoLine( cEntries,, n ) )
      aadd(aprinters, cText )

   next



return aPrinters
// ------------------------------------------------------------------------
FWH 11.11, Harbour 3.1 and Borland C++ 5.82
Posts: 581
Joined: Tue Oct 11, 2005 11:28 AM
Re: enhancement for RPreview
Posted: Mon May 30, 2011 03:02 PM

Very interesting tip. If you accept a challenge, it works but does not show the new preview according to the new printer chosen. if the preview could show again the page, but according to the new printer, it would be nice.

Regards,

Kleyber Derick



FWH / xHb / xDevStudio / SQLLIB
Posts: 422
Joined: Mon Aug 17, 2009 12:18 PM
Re: enhancement for RPreview
Posted: Sun Jun 19, 2011 04:39 PM

Mr. Linares,

Will be included in next FWH?.

Thank you.

Saludos,



Eduardo
Posts: 632
Joined: Thu Jan 19, 2006 10:45 AM
Re: enhancement for RPreview
Posted: Thu Jun 23, 2011 09:05 AM

Mr. Ukservice, we don't need Listadeimpresoras function because FIVEWIN has aGetPrinters() function that do de same.

Saludos



Andrés González desde Mallorca
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: enhancement for RPreview
Posted: Thu Jun 23, 2011 09:39 AM

FiveWin's function PrinterSetup() provides the standard user interface for selection of printers by the user. This is the same interface that every Windows user is familiar with while using any standard windows software, be it MS Office Excel, Word, etc. Any alternative interface we may provide by way of comboboxes, etc., looks not only inferior but also non-standard and unfamiliar interface to a common windows user.

A preview is generated for a specific printer and a specific printer setup. It is not a good or practical idea to provide choice of printer after a preview is generated. Better way is to provide for selection of printer at the time of executing a print command in the application software. Please also see Mr. Klyber's posting above.

Regards



G. N. Rao.

Hyderabad, India
Posts: 417
Joined: Tue Feb 23, 2010 03:09 PM
Re: enhancement for RPreview
Posted: Thu Jun 23, 2011 10:29 AM
It is quite annoying for users selecting a Printer each time they want to print.

For example, the user sees a document in the Preview and decides to export to PDF via PDF Creator´s printer because it is acceptable. With this combobox it is very easy to do that.

Or maybe he decides to print in a colour printer, but the default printer is a B&W.

So that is why I consider this feature very interesting.

But in the Preview, when we choose Print, the user can´t select printer, as in Word for example is possible.

Either when we click on Print or with the Combobox, the user should be able to change printer in the preview itself.
FWH 11.11, Harbour 3.1 and Borland C++ 5.82
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: enhancement for RPreview
Posted: Thu Jun 23, 2011 12:33 PM
RPreview has already given enough facility for us to customize or extend RPreview. There is no need for changing rpreview.prg at all.

Here is a sample approach.
When the user clicks on print button, the same kind of printer selection box as in MSWord appears and he can select a new printer.

At the beginning of the program:
Code (fw): Select all Collapse
   RPrevUserBtns( { |oPreview| MyPreview( oPreview ) } )


Add these functions to our program:
Code (fw): Select all Collapse
func mypreview( oPreview )

   oPreview:oBar:aControls[ 7 ]:bAction := { || MyPrint( oPreview ) }

return nil

func MyPrint( oPreview )

   PrinterSetUp()
   if Upper( PrnGetName() ) != Upper( TOKEN( oPreview:oDevice:cModel, ",", 1 ) )
      oPreview:oDevice:Rebuild()
   endif
   oPreview:PrintPage()

return nil

Now, the behavior is like MSWord or MSExcel
Regards



G. N. Rao.

Hyderabad, India
Posts: 417
Joined: Tue Feb 23, 2010 03:09 PM
Re: enhancement for RPreview
Posted: Thu Jun 23, 2011 12:57 PM

Thank you for your attention and quick support.

I click on File -> Print and it is the same.

I think it will be useful to work by default as Word, Excel or the rest of programs.

FWH 11.11, Harbour 3.1 and Borland C++ 5.82
Posts: 422
Joined: Mon Aug 17, 2009 12:18 PM
Re: enhancement for RPreview
Posted: Thu Jun 23, 2011 04:23 PM

Hi,

Will export to PDF and Word in prior versions to 2007?. There are many users running Word 2003 or 2000.

Will include Ribbon Bar instead present look?.

Thank you.

Saludos,



Eduardo
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: enhancement for RPreview
Posted: Thu Jun 23, 2011 05:47 PM
Will export to PDF and Word in prior versions to 2007?. There are many users running Word 2003 or 2000.

Export to Word works for prior versions too. But at present SaveAs PDF works only with 2007, because it uses the feature of Word 2007. True this feature is not useful for many users who are still using earlier versions. May be soon FW provides its native export to PDF, without depending on 3rd party libs.


Will include Ribbon Bar instead present look?.

Probably we can expect this soon.
Regards



G. N. Rao.

Hyderabad, India
Posts: 422
Joined: Mon Aug 17, 2009 12:18 PM
Re: enhancement for RPreview
Posted: Thu Jun 23, 2011 06:59 PM
Hello,

When I save to Word, it gives me the following error:

[IMG=http://img52.imageshack.us/img52/1425/errorvm.png][/IMG]

Uploaded with ImageShack.us


Thank you.
Saludos,



Eduardo
Posts: 9020
Joined: Thu Oct 06, 2005 08:17 PM
Re: enhancement for RPreview
Posted: Thu Jun 23, 2011 09:10 PM
nageswaragunupudi wrote:
Code (fw): Select all Collapse
func mypreview( oPreview )

   oPreview:oBar:aControls[ 7 ]:bAction := { || MyPrint( oPreview ) }

return nil

func MyPrint( oPreview )

   PrinterSetUp()
   if Upper( PrnGetName() ) != Upper( TOKEN( oPreview:oDevice:cModel, ",", 1 ) )
      oPreview:oDevice:Rebuild()
   endif
   oPreview:PrintPage()

return nil


Dear NageswaraRao, please correct me if I'm wrong: with the above code we simply print the EMFs to a new hDC. But the EMFs themselves are not rebuild for the new hDC so the result is not optimal.

EMG
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: enhancement for RPreview
Posted: Wed Jun 29, 2011 03:44 AM
Will export to PDF and Word in prior versions to 2007?. There are many users running Word 2003 or 2000.

FWH 11.06 provides a native way to save as PDF, without using any 3rd party libraries or MS Office. This functionality is optional.

To use the builtin functionality, at the outset of the program:
Code (fw): Select all Collapse
RPreview():bSaveAsPDF := { |oPreview| FWSavePreviewToPDF( oPreview, [cDestPDF] ) }
Regards



G. N. Rao.

Hyderabad, India
Posts: 1096
Joined: Fri Oct 28, 2005 02:27 AM
Re: enhancement for RPreview
Posted: Wed Jun 29, 2011 06:00 AM
nageswaragunupudi wrote:FWH 10.06 provides a native way to save as PDF, without using any 3rd party libraries or MS Office.


Rao,
Did you really mean 10.06 or did you made a typo and actually meant 11.06?
FWH 11.08/FWH 19.12

BCC5.82/BCC7.3

xHarbour/Harbour
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM
Re: enhancement for RPreview
Posted: Wed Jun 29, 2011 08:14 AM

Sorry, it was a typo.
I meant 11.06
Let me edit and correct my previous post.

Regards



G. N. Rao.

Hyderabad, India

Continue the discussion