Skip to content

TStyledToolbar.ChangeScale is not compatible with ScaleBy (cumulative scaling issue) #94

@surfjf69

Description

@surfjf69

I identified a structural issue in TStyledToolbar.ChangeScale.

The current implementation applies cumulative scaling:

FButtonWidth := MulDiv(FButtonWidth, M, D);
FButtonHeight := MulDiv(FButtonHeight, M, D);

However, ChangeScale can be called multiple times during a control’s lifecycle (MDI layout changes, parent scaling, alignment recalculations, DPI changes, etc.).
When ScaleBy is used, this leads to exponential growth of button sizes (for example, ButtonWidth growing from 48 to 149), even when:

AutoSize is disabled

no ImageList is assigned

By contrast, the standard VCL TToolBar and TStyledButton do not perform cumulative scaling; they recalculate metrics from a base value (or only react to real DPI changes via isDpiChange), which keeps them stable.

Conclusion

TStyledToolbar is not compatible with ScaleBy by design due to cumulative scaling in ChangeScale.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions