Ну да бог тогда с Вашей функцией, а Вы вот этот модуль можете мне доработать так, чтобы его как компонент (название - LabelF) можно было на делфи установить, со всеми свойствами обычного Label и там несколько новых, которые в модуле?
В какой раздел среды неважно, можно и в вкладку Samples.
Код:
unit LabelShadowUnit;
interface
uses
SysUtils, Classes, Graphics, Controls, StdCtrls;
type
TLabel2 = class(TLabel);
TLabel = class(TLabel2)
constructor Create(Owner : TComponent); override;
destructor Destroy; override; //запуск деструктора
procedure AddShadow(x: integer = 3; y: integer = 1; colorr : TColor = clBlack);
procedure AddShadowText(widthh : byte = 1; colorr : TColor = clBlack);
procedure ClearShadow;
private
shad : TList;
end;
implementation
{ TLabel }
procedure TLabel.AddShadow(x : integer = 3; y : integer = 1; colorr : TColor = clBlack);
var
sh: TLabel;
begin
sh := TLabel.Create(self.Owner);
with sh do
begin
WordWrap := self.WordWrap;
Alignment := self.Alignment;
Autosize := self.AutoSize;
Parent := TWinControl(self.Parent);
Font := self.Font;
Top := self.Top + y;
Left := self.Left + x;
Width := self.width;
Height := self.Height;
Font.Color := colorr;
Caption := self.Caption;
Transparent := True;
end;
self.Transparent := True;
self.BringToFront;
shad.Add(sh);
end;
procedure TLabel.AddShadowText(widthh: byte; colorr : TColor);
begin
// прямоугольник
AddShadow(widthh, 0, colorr);
AddShadow(-1 * widthh, 0, colorr);
AddShadow(0, widthh, colorr);
AddShadow(0, -1 * widthh, colorr);
// по бокам
AddShadow(widthh, widthh, colorr);
AddShadow(-1 * widthh, -1 * widthh, colorr);
AddShadow(-1 * widthh, widthh, colorr);
AddShadow(widthh, -1 * widthh, colorr);
end;
procedure TLabel.ClearShadow;
var
I : Integer;
begin
for I := 0 to shad.Count - 1 do
TLabel(shad[i]).Destroy;
shad.Clear;
end;
constructor TLabel.Create(Owner : TComponent);
begin
inherited Create(Owner);
shad := TList.Create;
end;
destructor TLabel.Destroy;
var
I : Integer;
begin
for I := 0 to shad.Count - 1 do
TLabel(shad[i]).Destroy;
shad.Destroy;
inherited Destroy;
end;
end.