Drag and drop in the ShpST1 get the position of the X, Y not _click (X, Y?
Procedure TForm1. FormDragOver (Sender, Source: TObject; X, Y: Integer;
State: TDragState; Var Accept: Boolean);
The begin
If (Sender is TShape) then
Accept:=true;
end;
Procedure TForm1. ShpST1DragOver (Sender, Source: TObject; X, Y: Integer;
State: TDragState; Var Accept: Boolean);
The begin
If (Source is TShape) then
Accept:=true;
end;
Procedure TForm1. ShpST1EndDrag (Sender, Target: TObject; X, Y: Integer);
The begin
ShpST1. Brush. Color:=clHighLight;
ShpST1. Left:=X - ShpST1. Width div 2;
ShpST1. Top:=Y - ShpST1. Height div 2;
end;
Procedure TForm1. ShpST1MouseDown (Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
The begin
If the Button=mbLeft then
(Sender as TShape). BeginDrag (false);
end;
CodePudding user response:
Try this code, BCB, can drag for://-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
Void __fastcall TForm1: : Button1MouseDown (TObject * Sender,
TMouseButton Button, TShiftState Shift, int X, int Y)
{
ReleaseCapture ();
The SendMessage (for - & gt; Handle, WM_NCLBUTTONDOWN HTCAPTION, 0);
}
//-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
CodePudding user response:
Procedure TForm1. ShpST1EndDrag (Sender, Target: TObject; X, Y: Integer);The begin
ShpST1. Brush. Color:=clHighLight;
ShpST1. Left:=X - ShpST1. Width div 2;
ShpST1. Top:=Y - ShpST1. Height div 2;
end;
In the X and Y are the coordinates of the screen, not the coordinates of the Form
CodePudding user response:
That how to become a Form of X, Y coordinates?