Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Newbie to ReportListener - Preview probs
Message
General information
Forum:
Visual FoxPro
Category:
Reports & Report designer
Miscellaneous
Thread ID:
01159111
Message ID:
01159455
Views:
20
Hi Albert,

I did a presentation at our local Foxpro users group a few months back on Report Listeners and you might be able to get some more detail out of that. I have the stuff available with working samples and different uses of listeners...

its at www.pafox.org in the downloads section...

HTH

>Thanks for the comments and the links....I will look into them.
>
>My client basically had me implement some "orphan/widow" protection for a printout of "payments". That is, for a multiple page printout, they did not want 1 line left on the very last page of the printout. What I did under VFP7 was to hack the .frx and figure out the header height (which could grow and so I had to take that into account) and the footer height, then figure out how many lines of detail were going to print on each page. I would then run through the data and figure out where the last detail line would print (I had to "run through it" as they also had me implement a blank line every 5 payments). If the last detail line was slated to print on the first row of the last page, I then inserted enough blank lines on the previous page ahead of the 2nd last payment to "bump" the 2nd last payment to the last page so that it printed along with the last payment. It was a lot of work but actually did work in VFP7.
>
>But it does not work at all in VFP9. Somehow my line numbering is always off a bit even though the .frx still gives back the same figures for header height and detail band height etc.
>
>So someone suggested implementing a report listener. Below is the code that he suggested. I have one question (he has not been on-line since), do you know what oProp below refers to? I have actually not tried filling in the AdjustObjectSize() method yet as I was still working on just getting the report to print as it used to be.
>
>
>
>DEFINE CLASS MyRL AS ReportListener
>
>nStretchRect = 0   && Recno of our stretchy rectangle
>...
>
>FUNCTION BeforeReport
>  ** Find the stretchy rectangle
>  SET DATASESSION TO (This.FRXDataSession)
>  SELECT frx
>  LOCATE FOR "*:stretchy" $ comment
>  IF FOUND()
>    This.nStretchRect = RECNO()
>  ENDIF
>  SET DATASESSION TO (This.CurrentDataSession)
>ENDFUNC
>
>FUNCTION AdjustObjectSize(nFRXRecNo, oProp)
>  IF nFRXRecNo = This.nStretchRect AND isthirdup
>    ** We are on the strtch rectangle and the 3rd from
>    ** the bottom record...
>    ** Do we have enough room to draw 3 detail bands?
>    IF oProp.Height*3 < oProp.MaxHeightAvailable
>      ** If not, force this band to take up all avaiable
>      ** space so the last 2 detail bands will start
>      ** on a new page
>      oProp.Height = oProp.MaxHeightAvailable
>      oProp.Reload = .T.
>    ENDIF
>  ENDIF
>ENDFUNC
>
>ENDDEFINE
>
>
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform