Hab das jetzt so realisiert:
Delphi-Quellcode:
constructor TLayeredForm.Create(AOwner: TComponent);
var i: Word; c: TComponent;
begin
inherited;
if csDesigning
in ComponentState
then begin
c := Owner;
while not c.InheritsFrom(TCustomForm)
do begin
c := c.Owner;
if c =
nil then begin
raise Exception.Create('
The LayeredForm component must be put on a form!');
self.Destroy;
exit;
end;
end;
Owner := c;
for i := 0
to Owner.ComponentCount -1
do
if (Owner.Components[i].InheritsFrom(TLayeredForm))
and (Owner.Components[i] <> self)
then begin
raise Exception.Create('
There can be only one LayeredForm component on every form!');
self.Destroy;
exit;
end;
end;
end;