New Event OnAutoResize

Hi,

I'm using TAdvListEditor sitting on a panel which has to be dynamically resized when the AdvListEditor resizes automatically. Of course already TAdvListEditor.OnResize can be used, but it will also be fired if it's for example right anchored on the panel and the width of the panel will be resized. So I suggest an additional event, for example OnAutoResize. Then the code has to be changed in 2 procedures:

procedure TAdvListEditor.DoAutoSize;
var
oldHeight: Integer;
begin
oldHeight := Height;
Height := GetAutoHeight(Width);
FEdit.Height := Canvas.TextHeight('gh')+ 4;
if (Height <> oldHeight) and Assigned(FOnAutoResize) then
FOnAutoResize(Self);
end;

and

procedure TAdvListEditor.SetBounds(ALeft, ATop, AWidth, AHeight: Integer);
var
oldHeight: Integer;
begin
oldHeight := Height;

if FAutoSize and HandleAllocated and not (csLoading in ComponentState) then
AHeight := GetAutoHeight(AWidth);

inherited SetBounds(ALeft, ATop, AWidth, AHeight);

if (oldHeight <> Height) and Assigned(FOnAutoResize) then
FOnAutoResize(Self);
end;

This feature was implemented.

1 Like