Home RAP
New Blog Posts: Merging Reports - Part 1 and Part 2

How do i draw lines in RAP code?

edited December 2005 in RAP
Hi,

How do i draw lines in RAP code? The delphi procedure below needs translated
to RAP code but it won't compile. It doesn't recognize Page/PrintPosRect? Is
this possible to do? I'm new at using RAP.

Greetings,
Filip Moons

Var
ALine: TppDrawLine;
begin
// Normale horizontale lijn 2
ALine := TppDrawLine.Create(Report);
ALine.Page := Report.Engine.Page;
ALine.LinePosition := lpTop;
ALine.Weight := 0.75;
ALine.Top := Report.Engine.PrintPosRect.Top;
ALine.Left := Report.Engine.PrintPosRect.Left;
ALine.Width := ppTopLine.mmWidth;

Comments

  • edited December 2005

    By default, not all of the properties and methods are exposed to RAP. You
    can easily extend RAP, see the following article.

    --------------------------------------------------
    Article: Extending RAP
    ---------------------------------------------------

    There are two very simple and powerful techniques to extend the capabilities
    of RAP infinitely. These are summarized below and covered in more detail in
    the RAP.hlp online help. Demos and tutorials are installed to
    RBuilder\Demos\RAP. The tutorial text is located in RAP.hlp.


    1. RAP Pass-Through Functions

    These are functions that appear in the Language tab of RAP's Code Toolbox.
    These functions are written in Delphi and can be called from RAP. RAP's
    pass-through function architecture enable's developers to add new built-in
    functions to RAP's code toolbox.

    2. Extend RAP's RTTI

    RAP's Run-time Type information defines what classes and properties can be
    accessed via RAP. By default the published properties of any class that is
    registered with Delphi's RegisterClass procedure is recognized by RAP. In
    addition many of the public properties and methods of ReportBuilder classes
    are exposed.







    --
    Tech Support mailto:support@digital-metaphors.com
    Digital Metaphors http://www.digital-metaphors.com




    Best regards,

    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com
  • edited December 2005
    Hi Nard,

    This is as far as i got. Below you can find the source i used for extending
    the RTTI and registering classes.

    The TppDrawLine compiles without errors.

    RAP-code
    procedure ReportOnEndPage;
    Var
    ALine: TppDrawLine;
    begin
    ALine := TppDrawLine.Create(Report);
    ALine.Page := ALine.Page;
    end;

    The TppCustomEngine still doesn't compiles without errors. How do I register
    the TppCustomEngine so it can be used in RAP code?

    RAP-code
    procedure ReportOnEndPage;
    Var
    ALine: TppDrawLine;
    begin
    ALine := TppDrawLine.Create(Report);
    ALine.Page := Report.Engine.Page; <<<
    ALine.LinePosition := lpTop;
    ALine.Weight := 0.75;
    ALine.Top := Report.Engine.PrintPosRect.Top; <<<
    ALine.Left := Report.Engine.PrintPosRect.Left; <<<
    ALine.Width := Line1.mmWidth;
    end;

    Could u please give me some more info how to get this running. Thanks.

    Greetings,
    Filip Moons

    unit Unit1;

    interface

    uses
    Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
    ppComm, ppRTTI, ppCache, ppDevice, ppEndUsr, ppRelatv, ppProd, ppClass,
    ppReport, StdCtrls;

    type
    TacTppReportRTTI = class(TraTppReportRTTI);

    {@TraTppDrawLineRTTI}
    TraTppDrawLineRTTI = class(TraTppDrawCommandRTTI)
    public
    class function RefClass: TClass; override;
    end; {class, TraTppDrawLineRTTI}

    {@TraTppCustomEngineRTTI}
    TraTppCustomEngineRTTI = class(TraTppCacheableRTTI)
    public
    class function RefClass: TClass; override;
    end; {class, TraTppCustomEngineRTTI}


    TForm1 = class(TForm)
    ppReport1: TppReport;
    Designer: TppDesigner;
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
    private
    { Private declarations }
    public
    { Public declarations }
    end;

    var
    Form1: TForm1;

    implementation

    uses
    raIDE,ppDrwCmd;

    {$R *.DFM}

    procedure TForm1.Button1Click(Sender: TObject);
    begin
    Designer.ShowModal;
    end;

    class function TraTppDrawLineRTTI.RefClass: TClass;
    begin
    Result := TppDrawLine;
    end; {TraTppDrawLineRTTI}

    class function TraTppCustomEngineRTTI.RefClass: TClass;
    begin
    Result := TppCustomEngine;
    end; {TraTppCustomEngineRTTI}

    Initialization
    raUnregisterRTTI(TraTppReportRTTI);
    raRegisterRTTI(TacTppReportRTTI);
    raRegisterRTTI(TraTppCustomEngineRTTI);
    raRegisterRTTI(TraTppDrawLineRTTI);
    Finalization
    raUnRegisterRTTI(TraTppCustomEngineRTTI);
    raUnRegisterRTTI(TraTppDrawLineRTTI);
    raUnregisterRTTI(TacTppReportRTTI);
    raRegisterRTTI(TraTppReportRTTI);
    end.

  • edited December 2005

    Its going to simpler to code a few RAP pass-thru functions.

    However, if you want to extend the RTTI you need to add support for any
    public properties that you wish to access (only published properties are
    supported by default). Your TacTppReportRTTI class does not add support for
    any additional properties/methods, such as Engine.





    Best regards,

    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com
  • edited December 2005
    I tried that and it gives me access violations on AReport.Engine.Page. I
    really could use some help. How would you implement drawing a line in RAP
    code. I would be really gratefull for some sample code.

    RAP code:
    Procedure ReportOnEndPage;
    Var
    ALine: TppDrawLine;
    begin
    ALine := TppDrawLine.Create(Report);
    ALine.LinePosition := lpTop;
    ALine.Weight := 0.75;
    ALine.Top := -1;
    ALine.Left := -1;
    ALine.Width := Label1.Width;
    DrawLineCMD(Report,ALine);
    end;

    Delphi Code
    TacDrawLineCMD = class (TraSystemFunction)
    public
    class function Category: string; override;
    procedure ExecuteFunction(aParams: TraParamList); override;
    class function GetSignature: string; override;
    end;

    class function TacDrawLineCMD.Category: string;
    begin
    Result := 'Draw Line Command';
    end;

    class function TacDrawLineCMD.GetSignature: string;
    begin
    Result := 'function DrawLineCMD(var AReport: TppCustomReport; var ALine:
    TppDrawLine): Boolean;';
    end;

    procedure TacDrawLineCMD.ExecuteFunction(aParams: TraParamList);
    var
    ALine: TppDrawLine;
    AReport: TppCustomReport;
    begin
    GetParamValue(0,AReport);
    GetParamValue(1,ALine);

    ALine.Page := AReport.Engine.Page;
    if ALine.Top = -1 then
    ALine.Top := AReport.Engine.PrintPosRect.Top;
    if ALine.Left = -1 then
    ALine.Left := AReport.Engine.PrintPosRect.Left;

    SetParamValue(2,True);
    end;

  • edited December 2005

    1. Try removing the 'var' from the RAP function signature for DrawLineCMD.

    2. Modify the Delphi library path to include RBuilder\Source and trace in
    the debugger

    3. If you still have an issue, create a simple example using DBDemos and
    email to support@digital-metaphors.com in zip format.



    Best regards,

    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com
This discussion has been closed.