Why does accessing a fmx controls "height" in "DoRealign" crash the Delphi designer?

  

Writing my own slider control in Firemonkey that works fine at runtime but will often crash the designer. I have tracked the crash down to accessing the controls Height called from my overridden “DoRealign”.

It does not crash all of the time and often pressing “OK” will allow me to continue designing the form but it never crashes at runtime. My only work around is to simply exit this routine on the condition “csDesigning in ComponentState”. I am curious to know where I am going wrong with my component design.

procedure TLFFader.DoRealign;
var
vI, T: TFmxObject;
NewSize: Single;
begin
inherited;
if not FDisableAlign then
begin
FDisableAlign := True;
try
T := FindStyleResource(‘vtrack’);
if Assigned(T) and (T is TControl) then
TControl(T).Visible := True;
if Assigned(T) and (T is TControl) and (Max > Min) then
begin
vI := FindStyleResource(‘vindicator’);

if Assigned(vI) and (vI is TControl) then
begin
NewSize := (TControl(T).Height –
TControl(T).Padding.top –
TControl(T).Padding.bottom –
TControl(vI).Margins.top –
TControl(vI).Margins.bottom) * FValueRange.RelativeValue;
TControl(vI).Height := Round(NewSize);
TControl(vI).Visible := TControl(vI).Height > 2;
end;
end;

if assigned(FThumb) then
begin
FThumb.Width := Width;
FThumb.Height := FThumbHeight;
FThumb.Position.X := 0;
FThumb.Position.Y := (Height – FThumbHeight) * (1-FValueRange.RelativeValue);
FThumbText.Text := FPercentPrefix + IntToStr(Round(FValueRange.RelativeValue * 100))+’%’;
end;

finally
FDisableAlign := False;
end;
end;
end;

Comments are closed.