Issues using TAdvSmoothPanel as subcomponent

I have created a new compound component, which contains a TAdvSmoothPanel, plus a couple of other different components (buttons etc)

The relevant bits of the code are

type
  TLandingPage = class(TCustomControl)
  private
    fBackPanel : TAdvSmoothPanel;
    // other controls here
  public
    constructor Create(AOwner:TComponent); override;
    destructor Destroy; override;
  published
    property BackPanel:TAdvSmoothPanel read fBackPanel;
    ///
  end;

constructor TLandingPage.Create(AOwner:TComponent);
begin
  inherited;

  { create components }
  fBackPanel:=TAdvSmoothPanel.Create(self);
  with fBackPanel do
  begin
    Parent:=self;
    Name:='BackPanel';
    Align:=alClient;
    SetComponentStyle(tsOffice2010Blue);
    Fill.BorderWidth:=0;
    Fill.BorderColor:=clNone;
    Fill.ShadowOffset:=0;
    Fill.ShadowColor:=clNone;
    Fill.Rounding:=0;
    Fill.RoundingType:=rtNone;
    Caption.Text:='';
    SetSubComponent(TRUE);
  end;

  // other component initialisation here

end;

Almost everything works perfectly, I can set all the properties of my 'BackPanel' and the other components at design time and they are all saved correctly in the .dfm, with one exception. The Caption.Text property is continually reset to 'BackPanel' at design time. If I change it (either to an empty string - which is what I want - or something else, the new value is stored in the dfm, but as soon as I reload the form in the IDE it's reset.

Am I missing something in my component creation (everything else works as expected), or is there a way to stop resetting this value.

Thanks in advance for your help.

Hi, 


To solve this issue you might want to check if csDesigning is in ComponentState before setting the Caption.Text to an empty value. When dropping the component on the form, the value will be set to an empty string.

I want the value as an empty string. The issue is that it is always reset to 'BackPanel' (or whatever I name the subcomponent) whenever I reload the form.

I would assume it is not needed to name your component to 'BackPanel', if you already have access to it. You can leave the component name empty, which will then solve the issue for the reset. Internally, the Name is used to initialize the caption at designtime.

No, I don't need to name the component (I've always named components when I've created compound components this way, but dont need to), and leaving it blank resets the caption.text blank

However, although in this case I want the caption.text left blank, if I did want to set the caption to a non blank value, it would now revert back to blank on reloading the form! Is there a way of stopping the Name from initialising the Caption.text property?

You would need to create your own Caption property that maps on the caption property of the internal panel.

Ok. Thanks for the advice.