insert a shape in delphi code example
Example 1: how to add shape in delphi 10
with TShape.Create(Self) do
begin
Name:='name here';
Align:=alNone;
Left:=10; */ make your own
Top:=10; */ make your own
Width:=100;
Height:=100;
Shape:=stRectangle;
Brush.Style:=bssolid;
Brush.Color:=clRed;
Pen.Color:=clRed;
Visible:=true;
Enabled:=true;
Parent:=Form1;
end;
Example 2: how to make a shape move in delphi
procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
case Key of
VK_UP:
Shape1.Top := Shape1.Top - 10;
VK_DOWN:
Shape1.Top := Shape1.Top + 10;
VK_LEFT:
Shape1.Left := Shape1.Left - 10;
VK_RIGHT:
Shape1.Left := Shape1.Left + 10;
end;
end;