|
Tracking the TFormDesigner
TFormDesigner has two special events fired after changing the selection and changing the selected controls position or size: OnChangeSelection and OnChange. The code below shows how these events can be used.
procedure TForm1.FormDesigner1SelectionChange(Sender: TObject);
begin
Label1.Caption:=Format(
'%d control(s) selected',[FormDesigner1.ControlCount]);
end;
procedure TForm1.FormDesigner1Change(Sender: TObject);
var
i,L,T,R,B: Integer;
begin
L:=MaxInt;
T:=MaxInt;
R:=-MaxInt;
B:=-MaxInt;
with FormDesigner1 do
for i:=0 to Pred(ControlCount) do
with Controls[i] do
begin
if L>Left then L:=Left;
if T>Top then T:=Top;
if R<Left+Width then R:=Left+Width;
if B<Top+Height then B:=Top+Height;
end;
Label2.Caption:=Format(
'The edited controls occupy rectangle (%d,%d,%d,%d)',[L,T,R,B]);
end;
|