Zitat von
nailor:
Aber ich glaube, du kannst zur Laufzeit noch weitere Instanzen auf dein Form klatschen.
Warum?
Owner war leider ReadOnly, deswegen sieht es jetzt so aus:
Delphi-Quellcode:
constructor TLayeredForm.Create(AOwner: TComponent);
var i: Word;
begin
inherited;
if csDesigning
in ComponentState
then begin
if not Owner.InheritsFrom(TForm)
then begin
raise Exception.Create('
The LayeredForm component must be put on a form!');
self.Destroy;
exit;
end;
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;
(Owner
as TForm).BorderStyle := bsNone;
end else begin
bf^.BlendOp := AC_SRC_OVER;
bf^.BlendFlags := 0;
bf^.SourceConstantAlpha := 0;
bf^.AlphaFormat := AC_SRC_ALPHA;
setWindowLong((Owner
as TForm).Handle, GWL_EXSTYLE, getWindowLong((Owner
as TForm).Handle, GWL_EXSTYLE)
or WS_EX_LAYERED);
end;
end;