Preview-How to pass a parameter

Post Reply
User avatar
Otto
Posts: 4470
Joined: Fri Oct 07, 2005 7:07 pm
Contact:

Preview-How to pass a parameter

Post by Otto »

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
Richard Chidiak
Posts: 946
Joined: Thu Oct 06, 2005 7:05 pm
Location: France
Contact:

Re: Preview-How to pass a parameter

Post by Richard Chidiak »

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
Otto
Posts: 4470
Joined: Fri Oct 07, 2005 7:07 pm
Contact:

Post by Otto »

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
Richard Chidiak
Posts: 946
Joined: Thu Oct 06, 2005 7:05 pm
Location: France
Contact:

Post by Richard Chidiak »

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

Post by Enrico Maria Giordano »

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
Otto
Posts: 4470
Joined: Fri Oct 07, 2005 7:07 pm
Contact:

Post by Otto »

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

Post by Enrico Maria Giordano »

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
Otto
Posts: 4470
Joined: Fri Oct 07, 2005 7:07 pm
Contact:

Post by Otto »

Sorry Enrico, I edited my post. Could you please read the post again?
User avatar
Enrico Maria Giordano
Posts: 7355
Joined: Thu Oct 06, 2005 8:17 pm
Location: Roma - Italia
Contact:

Post by Enrico Maria Giordano »

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
Otto
Posts: 4470
Joined: Fri Oct 07, 2005 7:07 pm
Contact:

Post by Otto »

Enrico, if you inherit a class could you also overwrite the new method?
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post by Antonio Linares »

Otto,

yes
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Otto
Posts: 4470
Joined: Fri Oct 07, 2005 7:07 pm
Contact:

Post by Otto »

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

Post by Antonio Linares »

Otto,

yes
regards, saludos

Antonio Linares
www.fivetechsoft.com
Post Reply