Gaining Access To Rave Components from Delphi/C++Builder

Category

Code Based - General

Question

Gaining Access To Rave Components from Delphi/C++Builder

Solution

You may gain access to components in Rave through the ProjectManager component. You can access this object through the TRaveProject.ProjMan property. The class is defined in the file RVPROJ.pas and many of its properties and methods are documented in section 3.0 of RANT.TXT. You may also want to take a look at RPPro/Rave 3.0G Public Class/Unit List in Adobe Acrobat Format - by Lawrence Lichtman mailto:condaptriol@earthlink.net - PublicClasses30G.pdf (16K) http://www.nevrona.com/rave/files/publicclasses30g.pdf.

Basically, you will want to use the FindRaveComponent method which has two parameters. First, you will need to find the page. Then you will need to find the component on that page. Something like this:

Delphi Example:

uses
    RVClass, RVProj, RVCsStd;
	
  var
    MyPage: TRavePage;
    MyText: TRaveText;
	
  begin
    RaveProject1.Open;
    With RaveProject1.ProjMan do begin
      MyPage := FindRaveComponent('Report5.Page2',nil) as TRavePage;
      MyText := FindRaveComponent('Text3',MyPage) as TRaveText;
      MyText.Text := 'Some Text';
      MyText.Color := clGreen;
    end; { with }
    RaveProject1.ExecuteReport('Report5');
    RaveProject1.Close;
  end;

C++Builder Example:

void __fastcall TForm1::BitBtn1Click(TObject *Sender)

  {
    TRaveProject *rp = RaveProject1;
    TRaveProjectManager *pm = rp->ProjMan;
    TRaveComponent *rc;
    TRavePage *pg;
    TRaveText *tx;

    rp->Open();
    rc = pm->FindRaveComponent("Report1.Page1",NULL);
    pg = dynamic_cast(rc);
    rc = pm->FindRaveComponent("Text1",pg);
    tx = dynamic_cast(rc);
    tx->Text = "Some Text";
    tx->Color = clGreen;
    rp->ExecuteReport("Report1");
    rp->Close();
  }