unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
ExtCtrls;
type
TForm1 =
class(TForm)
Image1: TImage;
Image2: TImage;
procedure FormCreate(Sender: TObject);
procedure FormKeyDown(Sender: TObject;
var Key: Word;
Shift: TShiftState);
private
{ Private-Deklarationen }
public
{ Public-Deklarationen }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.FormCreate(Sender: TObject);
var Bitmap1,Bitmap2:TBitmap;
begin
Bitmap1:=TBitmap.Create;
try
Bitmap1.Width:=Image1.Width;
Bitmap1.Height:=Image1.Height;
Bitmap1.Canvas.pen.color:=clGreen;
Bitmap1.Canvas.pen.width:=10;
Bitmap1.Canvas.Ellipse(5,5,50,50);
Image1.Picture.Assign(Bitmap1);
finally
Bitmap1.Free;
end;
Bitmap2:=TBitmap.Create;
try
Bitmap2.Width:=Image2.Width;
Bitmap2.Height:=Image2.Height;
Bitmap2.Canvas.pen.color:=clBlue;
Bitmap2.Canvas.pen.width:=10;
Bitmap2.Canvas.Rectangle(10,10,1000,15);
Image2.Picture.Assign(Bitmap2);
finally
Bitmap2.Free;
end;
with Image1
do
begin
transparent:=true;
end;
with Image2
do
begin
transparent:=true;
end;
end;
procedure TForm1.FormKeyDown(Sender: TObject;
var Key: Word;
Shift: TShiftState);
begin
case Key
of
VK_LEFT:
if Image1.Left -10 < Image2.Left
then
begin
Image1.Left := Image1.Left -10;
end;
end;
end;
end.