TAdvToolBarButton does not autosize when assigned action caption change

In the recent versions I saw that TAdvToolBarButtons with AutoSize, in a TAdvToolBar, does not resize their width when the assigned action caption changes.

Looking at latest unit code version there is this check that disable auto-sizing:

procedure TAdvCustomToolBarButton.AdjustSize;
var
ImgS, CS, W, H, TH, Scaledoffset, ScaledSpacing: integer;
images: TCustomImageList;
imgidx: Integer;
R: TRect;
ToolBarStyler: TCustomAdvToolBarStyler;
IsAeroVista: Boolean;
scale: single;
begin
if not Assigned(Parent) then
Exit;

{$IFNDEF DELPHIXE15_LVL}
if AutoSize then
{$ENDIF}
{$IFDEF DELPHIXE15_LVL}
if 1 < 0 then
{$ENDIF}
begin
IsAeroVista := Assigned(AdvQuickAccessToolBar) and AdvQuickAccessToolBar.FIsAeroVista and not AdvQuickAccessToolBar.FullSize;
...

I'm on Delphi 12.3 so if 1 < 0 is applied.

To solve I've, at the moment, commented check code and program back to works fine.

Any idea about this check ?

Addressed in TMS VCL UI Pack v13.5.10.0

The if 1 < 0 is still present in latest v13.5.10.1:

procedure TAdvCustomToolBarButton.AdjustSize;
var
ImgS, CS, W, H, TH, Scaledoffset, ScaledSpacing: integer;
images: TCustomImageList;
imgidx: Integer;
R: TRect;
ToolBarStyler: TCustomAdvToolBarStyler;
IsAeroVista: Boolean;
scale: single;
begin
if not Assigned(Parent) then
Exit;

{$IFNDEF DELPHIXE15_LVL}
if AutoSize then
{$ENDIF}
{$IFDEF DELPHIXE15_LVL}
if 1 < 0 then
{$ENDIF}
begin
IsAeroVista := Assigned(AdvQuickAccessToolBar) and AdvQuickAccessToolBar.FIsAeroVista and not AdvQuickAccessToolBar.FullSize;

It has been changed & improved and is ready to be included in v13.5.11.0

1 Like

A last question...

I've updated to 13.5.11 (latest version) but in my products I've always used, as TAdvToolBar container, a classic TPanel and not the TAdvDockPanel, so the AutoSize at language text changes is not performed yet.

It is necessary to change the structure and use TAdvDockPanel ?

At movement I've changed sources from:

if Assigned(Parent.Parent) and (Parent.Parent.ClassName = 'TAdvDockPanel') then
  IsOnDockPanel := true;

to:

if Assigned(Parent.Parent) and ((Parent.Parent.ClassName = 'TAdvDockPanel') or (Parent.Parent.ClassName = 'TPanel')) then
  IsOnDockPanel := true;

I've a lot of TAdvToolBar placed in simple TPanel in all my projects so changes to do will be so much...

Can you provide a test project with which we can reproduce this issue here, as so far, we could not see it here.

Hi, we’re running VCL UI Pack v13.5.12.0 and the issue still exists.

Very easy to reproduce:
Create a new project using the TMS wizard with Office 2019 toolbar.

Add a button to the toolbar:

As you can see, AutoSize for the button is checked but the button doesn’t auto-resize.

I have to add a AdbDockPanel to the AdvPage control in order for the auto-size to work:

the problem this now introduces is the AdvToolBar components no longer auto-index:

My question would be: Why auto-sizing and ToolbarIndex depend on what the parent it? They should work regardless of the parent type.

Sizing and positioning should never be conditioned on the type of parent unless there’s a very specific reason for it.

Here’s toolbarindex setter:

And here’s the AdjustSize() for the button:

We applied an improvement that will be included in the next release.

Thanks @Bruno_Fierens !

What I’ve done in the mean-time is comment the following code which fixes auto-sizing for me:

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.