为任意控件添加阴影的效果
在Delphi的ShadowWnd单元中定义了一个TShadowWindow的类,这个类可以用来给人任意的可视化控件添加阴影效果,示意代码如下:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ShadowWnd;
type
TForm1 = class(TForm)
lbl1: TLabel;
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure lbl1Click(Sender: TObject);
private
{ Private declarations }
FShadow:TShadowWindow;
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
FShadow := TShadowWindow.CreateShadow(lbl1, csRight);
FShadow.Control:=lbl1;
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
FShadow.Free;
end;
procedure TForm1.lbl1Click(Sender: TObject);
begin
if FShadow.Visible then
FShadow.Hide
else
FShadow.Show;
end;
end.