I want to create an application which places shapes (circles) on a panel everytime I click the mouse.
Is there a way to create new instances of this shape component without affecting the position of the original component ?
TIA;
procedure TForm1.FormMouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
with TShape.Create(Self) do
begin
Parent:=Panel1;
Shape:=ReferenceShape.Shape;
Brush:=ReferenceShape.Brush;
{Copy/set other properties as required}
Left:=X-Panel1.Left-Self.Left;
Top:=Y-Panel1.Top-Self.Top;
{not sure I've got Left/Top correct, but you get the idea <g>}
end;
end;
By making the owner the form (self) the new shape will be freed by the form when the form is freed.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.