I have TCustomPanel with own AlignControls to align some (99%) controls by my way. I would like to have both align system: my own + original LCL for other controls.
It's possible remove "my" controls from LCL alignment (because of performance)?
procedure THtmlPanel.AlignControls(AControl: TControl;
var RemainingClientRect: TRect);
begin
ResizeControlsByHtml; // here is my logic to align 2001 controls
inherited AlignControls(AControl, RemainingClientRect); // please align only ONE control, not 2002 :)
end;
btn := TButton.Create(Self);
btn.Caption := 'This button will be alligned by LCL';
btn.Parent := HtmlPanel;
btn.Align := alTop;
btn.BorderSpacing.Top := 50;
for I := 0 to 2000 do begin
shape := THtmlGraphicControl.Create(Self);
shape.Align := alCustom;
shape.HTML.Name := 'OBJ:' + I.ToString;
shape.HTML.InlineStyle := 'width:' + (5+Random(10)).ToString + 'px;border:1px solid red;background-color: #ffff' + Random(255).ToHexString(2) + ';display:inline;height:' + (2+ random(30)).ToString+ 'px;';
if I mod 100 = 0 then
shape.HTML.InlineStyle := shape.HTML.InlineStyle + 'display:block;background-color:red;';
shape.Parent := HtmlPanel;
end;
Where is correct way to calculate Height of control for autosize. (now my calculation is in
ResizeControlsByHtml). It's correct?
procedure THtmlPanel.CalculatePreferredSize(var PreferredWidth,
PreferredHeight: integer; WithThemeSpace: Boolean);
begin
inherited CalculatePreferredSize(PreferredWidth, PreferredHeight,
WithThemeSpace);
if (AutoSize) and (FAutoHeight>PreferredHeight) then
PreferredHeight := FAutoHeight; // height calculated in ResizeControlsByHtml
end;