Home > Back-end >  Delphi drag for implementation
Delphi drag for implementation

Time:09-18



Masters, the younger brother new to Delphi, to achieve a function, similar to Delphi editor seems to drag an object, the mouse will generate a across other control box, and down to generate a new object, and how to implement masters glad you please, the younger brother thank humbly.

CodePudding user response:

Don't empty box is simple DragMode changed then add gridlines oneself study the GDI +

Procedure TForm1. Btn7EndDrag (Sender, Target: TObject; X, Y: Integer);
The begin
(Sender as TButton). Left:=X;
(Sender as TButton). Top:=Y;
The end;

Procedure TForm1. FormDragOver (Sender, Source: TObject; X, Y: Integer; State:
TDragState; Var Accept: Boolean);
The begin
Self. Caption:=IntToStr (X) + ', '+ IntToStr (Y);
If the Source is TForm then
Accept:=True;
end;
  • Related