Preview-How to pass a parameter

Preview-How to pass a parameter

Postby Otto » Tue Nov 13, 2007 8:57 am

Preview
Could someone suggest an easy way to pass a parameter to preview?

In certain cases I need more buttons than the standard preview menu has.
How could I pass a parameter for example cCalledFrom to rpreview to know which function called the preview to adapt the menu.

If cCalledFrom = “Billing”

DEFINE BUTTON RESOURCE "Printer" OF oBar GROUP ;
MESSAGE TXT_PRINT_CURRENT_PAGE ;
ACTION f_name() ;
prompt "T e s t" TOOLTIP Strtran(TXT_PRINT,"&","")

endif

Thanks in advance
Otto
Image
User avatar
Otto
 
Posts: 6342
Joined: Fri Oct 07, 2005 7:07 pm

Re: Preview-How to pass a parameter

Postby Richard Chidiak » Tue Nov 13, 2007 9:35 am

Otto

I write to a txt file username.txt and the preview checks to see if the file is there, it erases it at the end

Hth

Richard
http://www.cbati.com

Uestudio
Fwh 13.05 Harbour 3.2 MSVC 2013
User avatar
Richard Chidiak
 
Posts: 946
Joined: Thu Oct 06, 2005 7:05 pm
Location: France

Postby Otto » Tue Nov 13, 2007 10:08 am

Richard, thank you for your tip.
How do you care if the txt is deleted after printing. What if the system crashes.

Regards,
Otto
User avatar
Otto
 
Posts: 6342
Joined: Fri Oct 07, 2005 7:07 pm

Postby Richard Chidiak » Tue Nov 13, 2007 10:17 am

Otto

if i understood correctly your question, the data is needed to be used by the preview, so it has to be deleted after printing in order to load some other data if needed next time.

The file i use is unique per user, so the information is there. The name of the file is retreived from netname() + '.txt' . i use it to pass to the preview the customer's email from the customer file and then the preview email's at the correct address.

Another solution would be to chane the preview and add data to the classs , cargo or anything else.

This depends what you want to do at preview

Hth

Richard
http://www.cbati.com

Uestudio
Fwh 13.05 Harbour 3.2 MSVC 2013
User avatar
Richard Chidiak
 
Posts: 946
Joined: Thu Oct 06, 2005 7:05 pm
Location: France

Postby Enrico Maria Giordano » Tue Nov 13, 2007 10:47 am

Richard Chidiak wrote:Another solution would be to chane the preview and add data to the classs , cargo or anything else.


Or, better, inherit from TPreview and add to the inherited class what you need to.

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

Postby Otto » Tue Nov 13, 2007 10:56 am

Thank you for your answers.

Enrico, do you have some code how this could be done.

Do I have to start in printer.prg which calls rpreview?

Do you think this could work?

add xPreview to printer.prg

METHOD xPreview() INLINE If( ::lMeta .and. Len( ::aMeta ) > 0 .and. ::hDC != 0,;
xRPreview( Self ), ::End() )

and add xRPreview.prg with the changes.
Last edited by Otto on Tue Nov 13, 2007 11:00 am, edited 1 time in total.
User avatar
Otto
 
Posts: 6342
Joined: Fri Oct 07, 2005 7:07 pm

Postby Enrico Maria Giordano » Tue Nov 13, 2007 10:59 am

Otto wrote:Enrico, do you have some code how this could be done.


No, sorry.

Otto wrote:Do I have to start in printer.prg which calls rpreview?


Yes, TPreview is used by TPrinter so you have to inherit a class from TPrinter also, I'm afraid.

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

Postby Otto » Tue Nov 13, 2007 11:01 am

Sorry Enrico, I edited my post. Could you please read the post again?
User avatar
Otto
 
Posts: 6342
Joined: Fri Oct 07, 2005 7:07 pm

Postby Enrico Maria Giordano » Tue Nov 13, 2007 11:05 am

Otto wrote:Do you think this could work?

add xPreview to printer.prg

METHOD xPreview() INLINE If( ::lMeta .and. Len( ::aMeta ) > 0 .and. ::hDC != 0,;
xRPreview( Self ), ::End() )

and add xRPreview.prg with the changes.


Yes, but the problem in creating a modified copy of rpreview.prg is that you have to apply to it any changes/fixes made later to the original file. I recommend inheritance instead.

EMG
Last edited by Enrico Maria Giordano on Tue Nov 13, 2007 12:49 pm, edited 1 time in total.
User avatar
Enrico Maria Giordano
 
Posts: 8718
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia

Postby Otto » Tue Nov 13, 2007 11:10 am

Enrico, if you inherit a class could you also overwrite the new method?
User avatar
Otto
 
Posts: 6342
Joined: Fri Oct 07, 2005 7:07 pm

Postby Antonio Linares » Tue Nov 13, 2007 11:23 am

Otto,

yes
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

Postby Otto » Tue Nov 13, 2007 11:34 am

Antonio
if I use in the inherited class, example xPrinter from TPrinter

METHOD New(cMyData ) CONSTRUCTOR

do I have all the data in the new class

METHOD New( cDocument, lUser, lMeta, cModel, lModal, lSelection ) CONSTRUCTOR
plus
cMyData?
Thanks in advance
Otto
User avatar
Otto
 
Posts: 6342
Joined: Fri Oct 07, 2005 7:07 pm

Postby Antonio Linares » Tue Nov 13, 2007 12:01 pm

Otto,

yes
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


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 35 guests