Re: Band lines and brush [new issue]
Hi,
EventNotifies
engine
draw
end
approach
can
demos
I decided to create a TppCommunicator descendent who catch event
notifications from all reports on current module (form, datamodule) avoiding
subclass TppReport. It's working great this way with simple reports.
But I get an AV when using groups. Even the demo project you send to me
weeks ago throws an AV if I add a group. The error occurs when trying to
remove the drawcommands:
ppReport1.Engine.Page.RemoveDrawCommand(lShape);
I have similar problems using subreports but I don't investigate this issue
so much.
//--------------
// From your demo:
//
procedure TfrmExample.ppReport1EndPage(Sender: TObject);
var
liIndex: Integer;
lShape: TppDrawShape;
begin
for liIndex := 0 to FShapes.Count - 1 do
begin
lShape := TppDrawShape(FShapes[liIndex]);
if ((liIndex mod 2) <> 0) then
begin
ppReport1.Engine.Page.RemoveDrawCommand(lShape);
lShape.Free;
end;
end;
end;
//--------------
I'm debugging the code but that AV makes no sense to me.
Do you have any ideia ?
--
Fabio Lindner
EventNotifies
engine
draw
end
approach
can
demos
I decided to create a TppCommunicator descendent who catch event
notifications from all reports on current module (form, datamodule) avoiding
subclass TppReport. It's working great this way with simple reports.
But I get an AV when using groups. Even the demo project you send to me
weeks ago throws an AV if I add a group. The error occurs when trying to
remove the drawcommands:
ppReport1.Engine.Page.RemoveDrawCommand(lShape);
I have similar problems using subreports but I don't investigate this issue
so much.
//--------------
// From your demo:
//
procedure TfrmExample.ppReport1EndPage(Sender: TObject);
var
liIndex: Integer;
lShape: TppDrawShape;
begin
for liIndex := 0 to FShapes.Count - 1 do
begin
lShape := TppDrawShape(FShapes[liIndex]);
if ((liIndex mod 2) <> 0) then
begin
ppReport1.Engine.Page.RemoveDrawCommand(lShape);
lShape.Free;
end;
end;
end;
//--------------
I'm debugging the code but that AV makes no sense to me.
Do you have any ideia ?
--
Fabio Lindner
This discussion has been closed.
Comments
Basically what is happening is that the report engine was never intended to
have anyone else change the draw commands as it it running in this manner.
You can't free a draw command when any KeepTogether action is taking place.
The engine is caching the draw commands as it may have to free them form the
page to support KeepTogether. The report engine would have to be enhanced to
support being notified that some draw commands were freed and that they
should be removed from the cache mechanism, so that it could safely work
this way.
To workaround this, instead of freeing the draw commands, set the text
properties to an empty string in order to allow you to move forward in your
development. This way the text draw commands won't generate any visible
output, eventhough they exist on the page.
Cheers,
Jim Bennett
Digital Metaphors
http://www.digital-metaphors.com
info@digital-metaphors.com
to
place.
the
to
I understand.
your
But I need to hide the background shape, not the labels. I'm changing the
DrawShape.Brush.Color to clWhite so the even shapes become hidden.
Interesting this only works when KeepTogether is false else a get a AV too.
I'll try with subreports now.
Thanks your suggestions.
--
Fabio Lindner
the bands to generate. In the case when a group should keep together, the
report engine removes the draw commands for the group on the current page
and they are moved to the next page. Depending on the timing of which you
are referencing the draw commands, they may not be on the page anymore when
KeepTogether is true. You'll have to setup a free notification relationship
between a TppCommunicator you create in your app and the draw commands on
the page. When a communicator is freed, it calls the notify event of the
communicator. Assign the OnNotify event of the communicator and check for
the operation to be ppopRemove and the communicator is one of your draw
command objects. In order to set this relationship up, you c code somethign
like this:
aDrawCommand.AddNotify(FmyCommunicator);
This will add FmyCommunicator to the aDrawCommand's notify list so that it
can notify it for certain events with using Delphi event handlers for
communication. So, when the aDrawCommand is freed, it notifies the
FmyCommunicator that it is being freed. This results in the FmyCommunicator
firing the OnNotify event so that you can hook into it using a Delphi event
handler to perform an operation. In this case, you want to remove
aDrawCommand from your TList of draw commands so that you don't try to
reference it in the OnEndPage event (hence no more AV's, hopefully).
Cheers,
Jim Bennett
Digital Metaphors
http://www.digital-metaphors.com
info@digital-metaphors.com
TppDrawCommand isn't a TppCommunicator (it inherits from TComponent atleast
with RB6.03), thus I can't call AddNotify(). Instead I tryed with
Notification() and FreeNotification(). I was unable of find the correct
timing to remove drawcommands this way.
So I give up removing drawcommands. I just change aDrawCommand.Brush.Color
to the correct color when a drawcommand of the background shape is created.
This way works with KeepTogether also and it don't generates AV's.
Thank you anyway your ideas. I learned a bit more about the RB's internals.
--
Fabio Lindner
allow
when
relationship
somethign
FmyCommunicator
event
they are communicators in order to support full text searching in the
preview beginning in RB 7.01. The TppCommunicator is pretty powerful and can
be used in many ways with RB.
Here is a good example of using the communicator to create cool report
features yourself, such as drill down with history marks for the subreports
you have drilled down in a preview:
http://www.digital-metaphors.com/tips/DrillDownHistory.zip
Cheers,
Jim Bennett
Digital Metaphors
http://www.digital-metaphors.com
info@digital-metaphors.com