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

OnCreateComponent question

edited November 2006 in General
Greetings!

I am using the OnCreateComponent event to show a form to the user that
gathers info which I then use for the properties of that component. If the
user cancels out of the form, is there a way to then cancel the component
creation (TppLabel), or remove/delete the component from the designer
surface?

I am using D7 - RB 10.04.

TIA for the help!

Gary

Comments

  • edited November 2006
    Hi Gary,

    Try freeing the component if the dialog is canceled inside the
    OnCreateComponent event. In my quick testing this prevented the component
    from ever being added to the designer workspace.

    --
    Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited November 2006
    Hi Nico,

    When I try freeing the component in the OnCreateComponent Event, the
    attached error message appears (or I get an AV). Is there anything else I
    could try?

    Thanks, Gary


  • edited November 2006
    Hi Gary,

    For future reference, please send all attachments to
    support@digital-metaphors.com.

    I apoligize, instead of using the OnCreateComponent to free the component,
    try using the OnValidateComponent event to set the Valid parameter to False
    if you would not like the component to appear. In my testing the following
    code worked correctly...

    procedure TForm1.ppDesigner1ValidateComponent(Sender: TObject; Component:
    TComponent; var Valid: Boolean);
    begin
    if Component is TppLabel then
    Valid := False;
    end;

    --
    Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com

    Best Regards,

    Nico Cizik
    Digital Metaphors
    http://www.digital-metaphors.com
  • edited November 2006
    Hi Nico,

    Yep - the OnValidateComponent event did the trick. Thanks very much for the
    help!

    Gary

This discussion has been closed.