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

FreeDesignControl

edited August 2006 in General
We are upgrading from Delphi 5 to Delphi 2006 and the latest Report Builder.
The following code no longer works. Is there a different method I should be
calling to do this now?


for x := FB.ObjectCount - 1 downto 0 do
begin
FB.Objects[x].FreeDesignControl;
end;


Thanks,
Mark Greenhaw
Reports Developer
One Domain, Inc.

Comments

  • edited August 2006

    You should not need to call FreeDesignControl. Internally RB will
    created/destroy the design controls as needed.

    As a side note, be aware that starting with RB 9 the RCL architecture was
    enhanced....

    ---------------------------------------
    Article: RB RCL Architecture Changes
    ---------------------------------------

    ReportBuilder 9 introduces architecture changes to more cleanly separate
    Designer code from Report code. The code related to component popup menus
    and design controls has been broken out into separate classes.

    For an example, check out RBuilder\Demos\RCL.


    The myChkBox.pas unit contains the component classes....


    TppCustomComponent

    |
    |

    TMyCustomCheckBox

    |
    |-- TmyCheckBox
    |
    |-- TmyDBCheckBox


    The myChkBoxDesign.pas unit contains popup menu and design control classes.
    These are compiled into a separate package.


    A. Popup Menu classes....

    TppComponentPopupMenu

    |
    |

    TmyCustomCheckBoxPopupMenu

    |
    |-- TmyCheckBoxPopupMenu
    |
    |-- TmyDBCheckBoxPopupMenu


    B. Design Control classes.....



    TmyCustomCheckBoxControl

    |
    |

    TmyCustomCheckBoxPopupMenu

    |
    |-- TmyCheckBoxControl
    |
    |-- TmyDBCheckBoxControl







    --
    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com

    Best regards,

    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com
  • edited August 2006
    Maybe I need to explain a bit more.

    I have a unit called uPrintHeader which is passed a report. The unit takes
    the report and creates a large header or small header depending on which
    parameter is passed. This way I have a standard header used throughout the
    system. Since the large header has a graphic and a lot more labels, etc. I
    delete all the components on the header and start fresh. This allows the
    user to checnge between header sizes in the print preview. The code in the
    previous message was given to me by DM support.

    Should I just change it to....

    for x := FB.ObjectCount - 1 downto 0 do
    begin
    TempObject := FB.Objects[x];
    TempObject.Free;
    // or FreeAndNil(TempObject);
    end;

    Mark Greenhaw
    Reports Developer
    One Domain, Inc.



  • edited August 2006
    Is it ok to use RemoveObject instead and does it free the control?



  • edited August 2006


    You can try that or here is the code from TppBand.Destroy...very similar to
    what are suggesting...

    {free each component associated with this band}
    for liObject := 0 to FObjects.Count - 1 do
    begin
    if (FObjects.Count > 0) then
    begin
    lObject := FObjects.Last;
    lObject.Free;
    end;
    end;

    --
    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com

    Best regards,

    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com
  • edited August 2006

    - never call Band.RemoveObject

    - to free an object call Object.Free. The object will remove itself from the
    Band.Objects[] list by internally setting Object.Band := nil

    - to remove an object from a Band without freeing the object, set
    Object.Band := nil

    - setting Object.Band internally calls sets up a notification relationship
    and internally calls AddObject/RemoveObject as needed.


    --
    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com

    Best regards,

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