Since RAP doesn't support records, you'll have to break the record structure up and surface four individual properties in RAP through the RAP RTTI class that you create. They would be PrintPosLeft, PrintPosRight, PrintPosTop, and PrintPosBottom integer properties that you would surface in RAP. You should unregister the TraTppCustomBandRTTI class (see initialization/finalization section of ppBands.pas for an example) and register a new one which is a descendent of it, but includes the new properties.
here is my code, similar to the demo in the help-file. I can compile this unit and built it into a package, but the RAP-Compiler doesn't recognize my new property "PrintPosTop". Can you see, what I did wrong?
Type TmyCustomBandRTTI = class(TraTppCustomBandRTTI) public class procedure GetPropList(aClass: TClass; aPropList: TraPropList); override; class function GetPropRec(aClass: TClass; const aPropName: String; var aPropRec: TraPropRec): Boolean; override; class function GetPropValue(aObject: TObject; const aPropName: String; var aValue): Boolean; override; class function RefClass: TClass; override; end; {class, TraTppCustomBandRTTI}
class function TMyCustomBandRTTI.RefClass: TClass; begin Result := TppCustomBand; end;
class procedure TMyCustomBandRTTI.GetPropList(aClass: TClass; aPropList: TraPropList); begin inherited GetPropList(aClass, aPropList); aPropList.AddProp('PrintPosTop'); end;
class function TMyCustomBandRTTI.GetPropRec(aClass: TClass; const aPropName: String; var aPropRec: TraPropRec): Boolean; begin Result := True; if ppEqual(aPropName, 'PrintPosTop') then PropToRec(aPropName, daInteger, True, aPropRec) else Result := inherited GetPropRec(aClass, aPropName, aPropRec); end;
class function TMyCustomBandRTTI.GetPropValue(aObject: TObject; const aPropName: String; var aValue): Boolean; begin Result := True; if ppEqual(aPropName, 'PrintPosTop') then Integer(aValue) := TppCustomBand(aObject).PrintPosRect.Top else Result := inherited GetPropValue(aObject, aPropName, aValue); end;
Sorry, this won't work. The way that the RTTI works is that the RTTI manageer works up the hierarchy to find the RTTI class. The architecture is such that you can only replace the lowest level RTTI, such as TraTppDetailBandRTTI, not TraTppCustomBandRTTI.
What is your goal? If you are trying to change the print pos rect, it might be better to try to set the SpaceUsed property on the band to control the engine's print pos rect. The print pos rect is actually inside the report engine. You can access it directly by in Delphi with Report.Engine.PrintPosRect, although not from RAP.
Comments
up and surface four individual properties in RAP through the RAP RTTI class
that you create. They would be PrintPosLeft, PrintPosRight, PrintPosTop,
and PrintPosBottom integer properties that you would surface in RAP. You
should unregister the TraTppCustomBandRTTI class (see
initialization/finalization section of ppBands.pas for an example) and
register a new one which is a descendent of it, but includes the new
properties.
Cheers,
Jim Bennett
Digital Metaphors
http://www.digital-metaphors.com
info@digital-metaphors.com
here is my code, similar to the demo in the help-file.
I can compile this unit and built it into a package, but the RAP-Compiler
doesn't recognize my new property "PrintPosTop".
Can you see, what I did wrong?
Thanks,
Juergen
unit MyRapFuncs;
interface
uses Classes, Forms, raFunc, ppRTTI, ppUtils, ppTypes, ppBands;
Type
TmyCustomBandRTTI = class(TraTppCustomBandRTTI)
public
class procedure GetPropList(aClass: TClass; aPropList: TraPropList);
override;
class function GetPropRec(aClass: TClass; const aPropName: String;
var aPropRec: TraPropRec): Boolean; override;
class function GetPropValue(aObject: TObject; const aPropName:
String; var aValue): Boolean; override;
class function RefClass: TClass; override;
end; {class, TraTppCustomBandRTTI}
implementation
{*******************************************************}
class function TMyCustomBandRTTI.RefClass: TClass;
begin
Result := TppCustomBand;
end;
class procedure TMyCustomBandRTTI.GetPropList(aClass: TClass; aPropList:
TraPropList);
begin
inherited GetPropList(aClass, aPropList);
aPropList.AddProp('PrintPosTop');
end;
class function TMyCustomBandRTTI.GetPropRec(aClass: TClass; const aPropName:
String; var aPropRec: TraPropRec): Boolean;
begin
Result := True;
if ppEqual(aPropName, 'PrintPosTop') then
PropToRec(aPropName, daInteger, True, aPropRec)
else
Result := inherited GetPropRec(aClass, aPropName, aPropRec);
end;
class function TMyCustomBandRTTI.GetPropValue(aObject: TObject; const
aPropName: String; var aValue): Boolean;
begin
Result := True;
if ppEqual(aPropName, 'PrintPosTop') then
Integer(aValue) := TppCustomBand(aObject).PrintPosRect.Top
else
Result := inherited GetPropValue(aObject, aPropName, aValue);
end;
{*******************************************************}
initialization
raUnregisterRTTI(TraTppCustomBandRTTI);
raRegisterRTTI(TmyCustomBandRTTI);
finalization
raUnregisterRTTI(TmyCustomBandRTTI);
raRegisterRTTI(TraTppCustomBandRTTI);
end.
manageer works up the hierarchy to find the RTTI class. The architecture is
such that you can only replace the lowest level RTTI, such as
TraTppDetailBandRTTI, not TraTppCustomBandRTTI.
What is your goal? If you are trying to change the print pos rect, it might
be better to try to set the SpaceUsed property on the band to control the
engine's print pos rect. The print pos rect is actually inside the report
engine. You can access it directly by in Delphi with
Report.Engine.PrintPosRect, although not from RAP.
Cheers,
Jim Bennett
Digital Metaphors
http://www.digital-metaphors.com
info@digital-metaphors.com
now, i have it!
My goal was to print the summary band at the bottom of the page, like your
example AlignSummaryToBottom.zip, but all within RAP.
I followed your tip to replace the lowest level RTTI - in my case
TraTppReportBandRTTI.
Now, my new property "PrintPosTop" is available.
RAP is really fantastic.
Thank you very much.
Cheers
Juergen