enhancement for RPreview

enhancement for RPreview

Postby ukservice » Sun May 29, 2011 7:30 pm

To let user change printer:


Code: Select all  Expand view
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: Select all  Expand view
//------------------------------------------------------------------------
// 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
User avatar
ukservice
 
Posts: 417
Joined: Tue Feb 23, 2010 3:09 pm
Location: John

Re: enhancement for RPreview

Postby Kleyber » Mon May 30, 2011 3: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
User avatar
Kleyber
 
Posts: 581
Joined: Tue Oct 11, 2005 11:28 am
Location: São Luiz, Brasil

Re: enhancement for RPreview

Postby mgsoft » Sun Jun 19, 2011 4:39 pm

Mr. Linares,

Will be included in next FWH?.

Thank you.
Saludos,

Eduardo
User avatar
mgsoft
 
Posts: 422
Joined: Mon Aug 17, 2009 12:18 pm
Location: España

Re: enhancement for RPreview

Postby Andrés González » Thu Jun 23, 2011 9: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
User avatar
Andrés González
 
Posts: 628
Joined: Thu Jan 19, 2006 10:45 am
Location: Mallorca

Re: enhancement for RPreview

Postby nageswaragunupudi » Thu Jun 23, 2011 9: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
User avatar
nageswaragunupudi
 
Posts: 10631
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: enhancement for RPreview

Postby ukservice » 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
User avatar
ukservice
 
Posts: 417
Joined: Tue Feb 23, 2010 3:09 pm
Location: John

Re: enhancement for RPreview

Postby nageswaragunupudi » 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: Select all  Expand view
  RPrevUserBtns( { |oPreview| MyPreview( oPreview ) } )
 


Add these functions to our program:
Code: Select all  Expand view
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
User avatar
nageswaragunupudi
 
Posts: 10631
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: enhancement for RPreview

Postby ukservice » 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
User avatar
ukservice
 
Posts: 417
Joined: Tue Feb 23, 2010 3:09 pm
Location: John

Re: enhancement for RPreview

Postby mgsoft » Thu Jun 23, 2011 4: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
User avatar
mgsoft
 
Posts: 422
Joined: Mon Aug 17, 2009 12:18 pm
Location: España

Re: enhancement for RPreview

Postby nageswaragunupudi » Thu Jun 23, 2011 5: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
User avatar
nageswaragunupudi
 
Posts: 10631
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: enhancement for RPreview

Postby mgsoft » Thu Jun 23, 2011 6: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
User avatar
mgsoft
 
Posts: 422
Joined: Mon Aug 17, 2009 12:18 pm
Location: España

Re: enhancement for RPreview

Postby Enrico Maria Giordano » Thu Jun 23, 2011 9:10 pm

nageswaragunupudi wrote:
Code: Select all  Expand view
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
User avatar
Enrico Maria Giordano
 
Posts: 8712
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Re: enhancement for RPreview

Postby nageswaragunupudi » Wed Jun 29, 2011 3: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: Select all  Expand view
RPreview():bSaveAsPDF := { |oPreview| FWSavePreviewToPDF( oPreview, [cDestPDF] ) }
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10631
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: enhancement for RPreview

Postby hua » Wed Jun 29, 2011 6: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
hua
 
Posts: 1072
Joined: Fri Oct 28, 2005 2:27 am

Re: enhancement for RPreview

Postby nageswaragunupudi » Wed Jun 29, 2011 8: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
User avatar
nageswaragunupudi
 
Posts: 10631
Joined: Sun Nov 19, 2006 5:22 am
Location: India


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 86 guests