Dynamic Objects runtime

edited 7:21AM in FastReport 4.0
Hi everybody.
I'm trying to create somw BarCode runtime so I wrote like this:

rpt_dyn_barCode:= TfrxBarCodeView.Create(rpt_report);
rpt_dyn_barCode.CreateUniqueName;
rpt_dyn_barCode.Left := 3;
rpt_dyn_barCode.Top := 3;
rpt_dyn_barCode.Width := 3;
rpt_dyn_barCode.Height := 1;
rpt_dyn_barCode.Zoom := 1;
rpt_dyn_barCode.Rotation := 0;

rpt_dyn_barCode.BarCode.Text := '12345678';
rpt_dyn_barCode.Visible := true;

When I show my report I can't see the new BarCode.
Have You got any ideas about it?

Thanks

Bye

Comments

  • edited 7:21AM
    I don't put any bands and any data?
    I only use this object from code... I don't need to connect to database...
    Is It possible?
    Maybe It's for this reason that I don't see the dynamic BarCode?
    Giulio wrote: »
    Hi everybody.
    I'm trying to create somw BarCode runtime so I wrote like this:

    rpt_dyn_barCode:= TfrxBarCodeView.Create(rpt_report);
    rpt_dyn_barCode.CreateUniqueName;
    rpt_dyn_barCode.Left := 3;
    rpt_dyn_barCode.Top := 3;
    rpt_dyn_barCode.Width := 3;
    rpt_dyn_barCode.Height := 1;
    rpt_dyn_barCode.Zoom := 1;
    rpt_dyn_barCode.Rotation := 0;

    rpt_dyn_barCode.BarCode.Text := '12345678';
    rpt_dyn_barCode.Visible := true;

    When I show my report I can't see the new BarCode.
    Have You got any ideas about it?

    Thanks

    Bye
  • gordkgordk St.Catherines On. Canada.
    edited 7:21AM
    object should be created in the page.
    read the programmers manual about creating reports from code
  • edited 7:21AM
    In the paragraph "Creating a report form from code" I can't find where it's writen what You said.
    Do You mean that I have to create object in the report?
    On the beforePrint of some elements of the reports (maybe on PagebeforePrint)?


    Thanks a lot

    gordk wrote: »
    object should be created in the page.
    read the programmers manual about creating reports from code
  • gordkgordk St.Catherines On. Canada.
    edited 7:21AM
    the object must be created in the context of its parent.
    look at the sanple code from the manual
    var

    DataPage: TfrxDataPage;

    Page: TfrxReportPage;

    Band: TfrxBand;

    DataBand: TfrxMasterData;

    Memo: TfrxMemoView;



    { clear a report }

    frxReport1.Clear;



    { add a dataset to the list of ones accessible for a report }

    frxReport1.DataSets.Add(frxDBDataSet1);



    { add the "Data" page }

    DataPage := TfrxDataPage.Create(frxReport1);



    { add a page }

    Page := TfrxReportPage.Create(frxReport1);
    //Note the design page was created in the context of the report.

    { create a unique name }

    Page.CreateUniqueName;

    { set sizes of fields, paper and orientation by default }

    Page.SetDefaults;

    { modify paper???s orientation }

    Page.Orientation := poLandscape;



    { add a report title band}

    Band := TfrxReportTitle.Create(Page);
    // note the band was created in the context of the page
    Band.CreateUniqueName;

    { it is sufficient to set the ?«Top?» coordinate and height for a band }

    { both coordinates are in pixels }

    Band.Top := 0;

    Band.Height := 20;

    your barcode should be created in the context of a design page or a band.
  • edited 7:21AM
    Nothing to do....
    I write this code as You said but I don't see any CodeBar...
    only empty report...



    procedure Tfrm_main.rpt_reportBeforePrint(Sender: TfrxReportComponent);
    var
    rpt_page: TfrxReportPage ;
    rpt_band: TfrxBand;
    rpt_dyn_barCode: TfrxBarCodeView;
    begin
    rpt_report.Clear;
    rpt_page := TfrxReportPage.Create(rpt_report);
    rpt_page.CreateUniqueName;
    rpt_page.SetDefaults;
    rpt_band := TfrxReportTitle.Create(rpt_page);
    rpt_band.CreateUniqueName;
    rpt_band.Top := 0;
    rpt_band.Height := 20;

    rpt_dyn_barCode:= TfrxBarCodeView.Create(rpt_band);
    rpt_dyn_barCode.CreateUniqueName;
    rpt_dyn_barCode.Left := 3;
    rpt_dyn_barCode.Top := 3;
    rpt_dyn_barCode.Width := 3;
    rpt_dyn_barCode.Height := 1;
    rpt_dyn_barCode.Zoom := 1;
    rpt_dyn_barCode.Rotation := 0;

    rpt_dyn_barCode.BarCode.Text := '12345678';
    rpt_dyn_barCode.Visible := true;

    end;

    gordk wrote: »
    the object must be created in the context of its parent.
    look at the sanple code from the manual
    var

    DataPage: TfrxDataPage;

    Page: TfrxReportPage;

    Band: TfrxBand;

    DataBand: TfrxMasterData;

    Memo: TfrxMemoView;



    { clear a report }

    frxReport1.Clear;



    { add a dataset to the list of ones accessible for a report }

    frxReport1.DataSets.Add(frxDBDataSet1);



    { add the "Data" page }

    DataPage := TfrxDataPage.Create(frxReport1);



    { add a page }

    Page := TfrxReportPage.Create(frxReport1);
    //Note the design page was created in the context of the report.

    { create a unique name }

    Page.CreateUniqueName;

    { set sizes of fields, paper and orientation by default }

    Page.SetDefaults;

    { modify paper???s orientation }

    Page.Orientation := poLandscape;



    { add a report title band}

    Band := TfrxReportTitle.Create(Page);
    // note the band was created in the context of the page
    Band.CreateUniqueName;

    { it is sufficient to set the ?«Top?» coordinate and height for a band }

    { both coordinates are in pixels }

    Band.Top := 0;

    Band.Height := 20;

    your barcode should be created in the context of a design page or a band.
  • gordkgordk St.Catherines On. Canada.
    edited 7:21AM
    your first problem is not enough height for the barcode.
    2nd may be the event you are trying to work in
    look at this sample
    code
    procedure TForm1.Button1Click(Sender: TObject);
    var
    rpt_report:tfrxreport;
    rpt_datapage:tfrxdatapage;
    rpt_page: TfrxReportPage ;
    rpt_band: TfrxBand;
    rpt_dyn_barCode: TfrxBarCodeView;
    begin
    rpt_report:=frxreport1;
    rpt_report.Clear;
    rpt_datapage:=tfrxdatapage.Create(rpt_report);
    rpt_page := TfrxReportPage.Create(rpt_report);
    rpt_page.CreateUniqueName;
    rpt_page.SetDefaults;
    rpt_band := TfrxReportTitle.Create(rpt_page);
    rpt_band.CreateUniqueName;
    rpt_band.Top := 0;
    rpt_band.Height := 20;

    rpt_dyn_barCode:= TfrxBarCodeView.Create(rpt_band);
    rpt_dyn_barCode.CreateUniqueName;
    rpt_dyn_barCode.Left := 3;
    rpt_dyn_barCode.Top := 3;
    rpt_dyn_barCode.Width := 3;
    rpt_dyn_barCode.Height := 10;// note the size change
    rpt_dyn_barCode.Zoom := 1;
    rpt_dyn_barCode.Rotation := 0;

    rpt_dyn_barCode.BarCode.Text := '12345678';
    rpt_dyn_barCode.Visible := true;

    rpt_report.designreport; // call design to see what you have designed


    end;
  • edited 7:21AM
    You're great !!
    It was the height...
    Many thanks
    Bye

Leave a Comment

Rich Text Editor. To edit a paragraph's style, hit tab to get to the paragraph menu. From there you will be able to pick one style. Nothing defaults to paragraph. An inline formatting menu will show up when you select text. Hit tab to get into that menu. Some elements, such as rich link embeds, images, loading indicators, and error messages may get inserted into the editor. You may navigate to these using the arrow keys inside of the editor and delete them with the delete or backspace key.