SkinSection not applied in runtime TsPanel

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #34357
    sriver
    Participant

    Hi AC

    Thanks for all the great work you're doing on these components – great stuff.

    I have found the following issue since upgrading to 7.30 (D2006):

    1. Place a TsScrollbox on a form and add this code in a button to create a TsPanel and add it to the sScrollBox:

    Code:
    procedure TForm1.Button1Click(Sender: TObject);
    var
    pnl: TsPanel;
    begin
    pnl := TsPanel.Create(sScrollBox1);
    pnl.Align := alTop;
    pnl.SkinData.SkinSection := 'CHECKBOX'; // <== this will be ignored here
    pnl.Caption := 'panel';
    pnl.Parent := sScrollBox1;
    // pnl.SkinData.SkinSection := 'CHECKBOX'; // <== SkinSection has to be set after the parent is set - why??
    end;

    You will see that the panel is skinned as a 'PANEL' and not as 'CHECKBOX'. Now move the SkinSection line to after setting the parent and it will skin the panel as a 'CHECKBOX'. I don't think this was an issue before 7.30.

    While this is a simple workaround, the code is not working as I would expect and has broader implications when sub-classing from AC controls.

    e.g. If I create a composite control with say a TsButton on a TsPanel, setting the SkinSection of the button in the constructor (see below) will cause an exception.

    Code:
    constructor Td2sSplitButton.Create(AOwner: TComponent);
    begin
    inherited; // inherits from TsPanel
    Caption := '';
    SkinData.SkinSection := 'CHECKBOX';
    fBtn := Td2sBitBtn.Create(self);
    with fBtn do
    begin
    Name := Name + 'Button';
    Parent := self;
    Align := alClient;
    SkinData.SkinSection := 'TOOLBUTTON'; // <== will cause an exception - must be set in Td2sSplitButton.Loaded
    SetSubComponent(true);
    end;
    end;

    The way around this is to override Loaded and set the SkinSection in there. However, if the Td2sSplitButton is created at runtime then Loaded is not automatically called and has to be called manually. This ends up creating unnecessary code in parent controls when it should all just be encapsulated in the Td2sSplitButton control itself.

    Perhaps some other design issue may require this behaviour, but even though I can workaround this issue I think the whole SkinSection handling for runtime controls needs to be looked at.

    Again, thanks for you excellent work.

    Cheers,

    Michael

    #44870
    Support
    Keymaster

    Hello

    The problem in sPanel occurs because support of panel bevels was added. SkinSection is changed automatically after changing of the BevelOuter property.

    So, you can write “pnl.BevelOuter := bvNone” and remove “pnl.SkinData.SkinSection := 'CHECKBOX'”

    Also you can write “pnl.SkinData.SkinSection := 'MENUITEM'”, panel will be transparent in this case too.

    I will test buttons created in run-time, now.

    #44871
    Support
    Keymaster

    I have made test for buttons, but haven't an error.

    Maybe you must show me your component… Can you use TeamViewer tool for sharing of your PC?

    #44954
    sriver
    Participant
    'Support' wrote:

    Hello

    The problem in sPanel occurs because support of panel bevels was added. SkinSection is changed automatically after changing of the BevelOuter property.

    So, you can write “pnl.BevelOuter := bvNone” and remove “pnl.SkinData.SkinSection := 'CHECKBOX'”

    Also you can write “pnl.SkinData.SkinSection := 'MENUITEM'”, panel will be transparent in this case too.

    I will test buttons created in run-time, now.

    Thanks! I can confirm that this fixed the problem 🙂

    #44955
    sriver
    Participant
    'Support' wrote:

    I have made test for buttons, but haven't an error.

    Maybe you must show me your component… Can you use TeamViewer tool for sharing of your PC?

    I've just retested and I no longer have the problem either?! I must have hit the error before I had finished coding the components and just assumed that is was related to the earlier issue. Sorry for raising a non-issue.

    Cheers,

    m

Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.