Creating groups in RAP (Porting code from Delphi)...
Hi,
Earlier I was said to port Delphi code for run-time groups creation to RAP,
after making sure that it works in Delphi itself. But Almost immediately I
run into a problem with the following string:
lGroup := TppGroup.Create(Self);
RAP doesn't see "Self" variable and writing this way "lGroup :=
TppGroup.Create" doesn't help as well. I get an error in this case.
Can you help me please?
Thanks,
MB.
Earlier I was said to port Delphi code for run-time groups creation to RAP,
after making sure that it works in Delphi itself. But Almost immediately I
run into a problem with the following string:
lGroup := TppGroup.Create(Self);
RAP doesn't see "Self" variable and writing this way "lGroup :=
TppGroup.Create" doesn't help as well. I get an error in this case.
Can you help me please?
Thanks,
MB.
This discussion has been closed.
Comments
I seem to find the solution. One just have to pass "nil" value instead of
"self" value into the method.
But another problem appeared immediately. I'm not sure of the cause.
Here is the code I put in my global OnCreate method:
procedure GlobalOnCreate;
Var
lGroup: TppGroup;
lHeader: TppGroupHeaderBand;
lShape: TppShape;
lLabel: TppLabel;
begin
lGroup := TppGroup.Create(nil);
lGroup.Report := Report;
lGroup.DataPipeline := Report.DataPipeline;
lGroup.BreakName := 'Level';
lHeader := TppGroupHeaderBand.Create(nil);
lHeader.Group := lGroup;
lHeader.Height := 0.2187;
{add components to group header}
lShape := TppShape.Create(nil);
lShape.Band := lHeader;
lShape.Left := 0;
lShape.Top := 0;
lShape.Width := 8;
lShape.Height := 0.2187;
lShape.Brush.Color := clYellow;
lLabel := TppLabel.Create(nil);
lLabel.Band := lHeader;
lLabel.Caption := 'Group1';
lLabel.Left := 0.0313;
lLabel.Top := 0.0313;
lLabel.Transparent := True;
end;
As you can see - everything is taken from your demo:
"DynamicReportCreation". I just chaged aReport on Report,
Create(Self) on Create(nil), and chaged 2 strings to lGroup.BreakName :=
'Level'; and lLabel.Caption := 'Group1';
That is it.
The problem is that it doesn't work.
After I try to preview new report - I get an access violation error.
Even if I try to create an absolutely new report with just this code and one
pipeline - it still doesn't work. Even if you try to comment everything
after those words: "{add components to group header}", it still gives the
error.
Could you tell me what the reason might be?
Thanks,
MB.
string:
lHeader.Group := lGroup;
But both lHeader and lGroup are not nils. The reason still eludes me.
Will be grateful for any help.
Thanks,
MB.
pass the report object in the parameter of the pass through so that in the
Delphi code of the pass through, you can pull out the Report.Owner object
which is the form. That way you can still create a group in RAP, via a pass
through function and still have the form be the owner of the group. In
general, if you create something with a nil owner, then you have to take
responsibility for freeing that object because its owner (the form in this
case) will not try to free it.
There are RAP pass through function tutorials and demos in the RAP sections
of the RBuilder/Demos and RBuilder/Tutuorials sections of the installation.
Cheers,
Jim Bennett
Digital Metaphors
http://www.digital-metaphors.com
info@digital-metaphors.com
exception on the same string.
Could you try this yourself?
Thanks,
MB.
RB 7.02 D6 format example I just created, with RAP pass through function to
create the group with form as owner:
http://www.digital-metaphors.com/tips/RAPGroupFunctions.zip
Cheers,
Jim Bennett
Digital Metaphors
http://www.digital-metaphors.com
info@digital-metaphors.com