How do I know my current line position on a page during runtime?
During RunTime of the report, I am trying to insert a line at my current
position on a page... so I'm creating a line, and setting the properties for
it... But I can't seem to find the right thing to assign the Top Position of
the line I just created.
How do I tell where I am at the current moment on a given page?
My line is not going to print in the same spot on every page, so I can't use
a hard-coded position... So I need to set its Top Position on a per-page
basis, before it does its automatic page break.
Denise Mace
Applications Developer
Computrition, Inc.
dmace@computrition.com
//******************************************************************************
procedure TF_MenuCalendarRpt.ppReportEndPage(Sender: TObject);
//******************************************************************************
begin //At the End of Each Page, prints a line, so the page doesn't
continue onto
// a new page without a bottom line before the page break.
(*
//Done elsewhere in the code...
ppDrawLinePageBottom := TppDrawLine.Create(nil);
ppDrawLinePageBottom.LinePosition := lpTop;
*)
ppDrawLinePageBottom.Page := ppReport.Engine.Page;
ppDrawLinePageBottom.Left := 0.75;
ppDrawLinePageBottom.Width := 6.00;
ppDrawLinePageBottom.Top := ??????????? // want to set
this to the current position on the page
//so it prints at my current position before it does the page
break...
end;
position on a page... so I'm creating a line, and setting the properties for
it... But I can't seem to find the right thing to assign the Top Position of
the line I just created.
How do I tell where I am at the current moment on a given page?
My line is not going to print in the same spot on every page, so I can't use
a hard-coded position... So I need to set its Top Position on a per-page
basis, before it does its automatic page break.
Denise Mace
Applications Developer
Computrition, Inc.
dmace@computrition.com
//******************************************************************************
procedure TF_MenuCalendarRpt.ppReportEndPage(Sender: TObject);
//******************************************************************************
begin //At the End of Each Page, prints a line, so the page doesn't
continue onto
// a new page without a bottom line before the page break.
(*
//Done elsewhere in the code...
ppDrawLinePageBottom := TppDrawLine.Create(nil);
ppDrawLinePageBottom.LinePosition := lpTop;
*)
ppDrawLinePageBottom.Page := ppReport.Engine.Page;
ppDrawLinePageBottom.Left := 0.75;
ppDrawLinePageBottom.Width := 6.00;
ppDrawLinePageBottom.Top := ??????????? // want to set
this to the current position on the page
//so it prints at my current position before it does the page
break...
end;
This discussion has been closed.
Comments
that earlier...
Anyways, I found the details on rbWiki for what I needed... very similar to
what I had done... with using 'ppReport.Engine.PrintPosRect.Top' to find
the current position on the page. Ok, so I've got that.... AND -- That
should have worked... but it doesn't... my underline [that I want to print
at the end of the page, directly under the last detail band] prints a bit
furthur down than what it should [instead of being right after the last
detail line that printed].
I did some digging, and it appears that the problem is.... It thinks it
printed one more detail band than it actually did print... so the
'ppReport.Engine.PrintPosRect.Top' is set one line furthur down on the page
than it actually should be.
I stepped through to see what was happening.... and it goes into the
DetailBandAfterPrint.... to indicate that the band had printed.... the
'ppReport.Engine.PrintPosRect.Top' is based on that (supposedly printed)
detail line.... And then it goes to my EndOfpage event to print the
underline, and it prints it too far down.
So I checked the last detail band that it says it printed in the
DetailBandAfterPrint.... and that detail line did not really print, it
bumped onto the next page. Why would the AfterPrint event kick in, if the
line in fact didn't print?
I end up with something like this....
Detail line prints data here, fine.... xxxxxxxxxxxxxxxxxxxxxxxxxx
Detail line prints data here, fine.... xxxxxxxxxxxxxxxxxxxxxxxxxx
[This next detail line goes into the after print, as
if it printed, BUT it didn't, this line is blank space]
------------------------ Now I'm in the EndPage Event, printing the
Underline -------------------
So I end up with a space between my final detail line, and the underline....
because it thinks it printed an additional DetailBand in between them, thus
incrementing the 'ppReport.Engine.PrintPosRect.Top' value as if it
printed.... and thus, printing my underline furthur down than it should
have.
The detail line that it says it printed as the last line on Page 1, ends up
as the first detail line on the Next Page.... even though it went into the
AfterPrint event for that detail line before the PageBreak. Frustrating.
Is there another way to tell me that that detail line really didn't print,
in spite of the fact that it went into the AfterPrint event before page
breaking?
Denise Mace
Applications Developer
Computrition, Inc.
dmace@computrition.com
====================================================================
Is this occurring at the end of every page or at the end of your report?
Are you able to recreate this behavior using the example included with
the article on the rbWiki site? In my testing the line is always lined
directly with the last detail of the page, regardless whether I increase
the size of the detail band so some groups span multiple pages.
http://www.digital-metaphors.com/tips/LastDynamicDetailLine.zip
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com
Thanks for your reply...
Well.... It's random, so no it doesn't happen at the end of every page. AND
it is definitely not specific to the end of the report, I see it randomly on
multiple pages throughtout... but sometimes it doesn't happen at all...
Depends very much on the data, and where exactly the page break occurs.
Somehow it thinks it printed a detail line that it didn't print... as it
goes into the AfterPrint event... but then that Detail Line shows up as the
first detail line on the next page... so it obviously knows on page 2 that
it didn't print it.
Yes, I am able to duplicate this with my report setup like that article on
the rbWiki site. In fact, I have it setup exactly that way. And logically,
yes, it should work. However, my detailbands have Memos on them... and they
stretch depending on the data that prints in them. So my detail bands are
not always the same height. Depending on the data, the detail band can be
1, 2, or sometimes 3 lines high... depending on what is printing in the
MemoBox, and how it wraps. I'm guessing that is part of the problem, that
it thinks it had room for the detail line.... and went into the After
Print... but it didn't fit... and so it bumped it. And I don't care that
its bumping that Detail Line to the next page.... that's fine. I just don't
want it to tell me that it printed it before the page break, when it really
didn't... as it messes up my 'ppReport.Engine.PrintPosRect.Top' value by
going into the AfterPrint for that line that gets bumped.
So, is there any other way... other than it going into the AfterPrint event,
to tell if a Detail Line really printed? It obviously knows, somehow, that
it didn't.... as it has no problem printing that Detailband as the first
line on the Next Page. So it seems as if there's got to be something that
knows a bump occurred....
Denise Mace
================================================
Are you able to duplicate this with the actual example itself? I am
unable to recreate this behavior using the example. This leads me to
believe there is something different between how the example works and
how your application is working. Finding this difference will help
track down the problem.
If possible, alter the example to show this behavior and either send it
to me (.zip format to support@digital-metaphors.com) or let me know the
steps I need to take to recreate it with the original.
Nico Cizik
Digital Metaphors
http://www.digital-metaphors.com