作者在 2010-01-25 17:32:21 发布以下内容
unit MainUnit;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ExtCtrls, StdCtrls, jpeg;
type
TMainForm = class(TForm)
Panel1: TPanel;
Button1: TButton;
Button2: TButton;
Image1: TImage;
procedure FormCreate(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
MainForm: TMainForm;
AppPath: String;
implementation
{$R *.DFM}
procedure TMainForm.FormCreate(Sender: TObject);
begin
AppPath:= ExtractFilePath(ParamStr(0));
ClientWidth:= 640;
ClientHeight:= 480;
with Panel1 do
begin
BevelInner:= bvLowered;
BevelOuter:= bvRaised;
BevelWidth:= 3;
BorderWidth:= 3;
Caption:= '';
end;
with Image1 do
begin
Align:= alClient;
Center:= True;
Stretch:= True;
Picture.LoadFromFile(AppPath+ '1.jpg');
end;
Button1.Caption:= '多种颜色阴影效果';
Button2.Caption:= '深度阴影效果';
end;
procedure TMainForm.Button1Click(Sender: TObject);
var
x,y,i: Integer;
begin
x:= 0;
y:= 0;
MainForm.Canvas.Pen.Width:= 1;
for i:= 0 to 10 do
begin
with MainForm.Canvas do
begin
Pen.Color:= clTeal;
MoveTo(Panel1.Left+ Panel1.Width+ x, Panel1.Top+ y);
LineTo(Panel1.Left+ Panel1.Width+ x, Panel1.Top+ Panel1.Height+ y);
Pen.Color:= clBlue;
MoveTo(Panel1.Left+ x, Panel1.Top+ Panel1.Height+ y);
LineTo(Panel1.Left+ Panel1.Width+ x, Panel1.Top+ Panel1.Height+ y);
end;
x:= x+ 1;
y:= y+ 1;
end;
end;
procedure TMainForm.Button2Click(Sender: TObject);
var
x, y, i: Integer;
begin
x:= 0;
y:= 0;
MainForm.Canvas.Pen.Width:= 1;
for i:= 0 to 10 do
begin
with MainForm.Canvas do
begin
Pen.Color:= clNone;
Pen.Color:= clBlack;
MoveTo(Panel1.Left+ Panel1.Width+ x, Panel1.Top+ 10);
LineTo(Panel1.Left+ Panel1.Width+ x, Panel1.Top+ Panel1.Height+ 10);
MoveTo(Panel1.Left+ 10, Panel1.Top+ Panel1.Height+ y);
LineTo(Panel1.Left+ Panel1.Width+ 10, Panel1.Top+ Panel1.Height+ y);
end;
x:= x+ 1;
y:= y+ 1;
end;
end;
end.