Create and Destroy objects at runtime
I need to create some objects (tfrxMemoview) for every record in the report, then number of objects may vary from one record to another. I am using the followin code in the MasterDataOnbeforeprint event:
It's work fine, however I need to destroy them for the next record, because some records needs less objects than others.
How can I do that?
Should I change my code?
Thanks in advance.
J.C. Arteaga
ARTESOFT
procedure MasterData1OnBeforePrint(Sender: TfrxComponent);
var
  s : string;
  i : integer;
  dLeft,dWidth : double;                                   Â
begin
  if <Cheques."POS"> = 'S' then
  begin
    picLogoS.DataField := 'LogoBanco'; Â
    picLogoI.Datafield := 'Logo';                                                                                       Â
  end
  else           Â
  begin
    picLogoI.DataField := 'LogoBanco'; Â
    picLogoS.Datafield := 'Logo';                                                                                       Â
  end;
  ChequesSimbolo.left := 653.86;                                                                               Â
  dWidth := ChequesSimbolo.width / 2;       Â
  dLeft := ChequesSimbolo.left + dwidth;
  ChequesSimbolo.Left := dLeft - ChequesSimbolo.width - (Length(<Cheques."MONTOSTR">) * dWidth);                                                                                           Â
  for i:= Length(<Cheques."MONTOSTR">) downto 1 do
  begin
    s := Copy(<Cheques."MONTOSTR">,i,1);
    with TfrxMemoView.Create(MasterData1) do
    begin
      Memo.text := s;
      Left := dLeft;
      AutoWidth := false;                                                   Â
      width := dWidth;
      Color := ChequesSimbolo.color;
      Font := chequesSimbolo.font;       Â
      Height := ChequesSimbolo.Height;
      Top := ChequesSimbolo.Top;                                                             Â
      HAlign := haCenter;
      VAlign := vaCenter;
    end;
    if i > 1 then                                     Â
      dLeft := dLeft - dWidth; Â
  end;
  ChequesSimbolo.left := dleft - ChequesSimbolo.Width;                                                               Â
  frmSombra.left := ChequesSimbolo.left;                                                                                   Â
end;
It's work fine, however I need to destroy them for the next record, because some records needs less objects than others.
How can I do that?
Should I change my code?
Thanks in advance.
J.C. Arteaga
ARTESOFT
Comments
Thank you