ginsonic
asked on
Drag&Drop a panel from a panel to another
I need to drag a panel from another panel toa 3th panel .
Erase the panel from first panel and create it in the second panel .
Erase the panel from first panel and create it in the second panel .
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Your form and both panels must have this function in the OnDragOver action.
procedure TForm1.FormDragOver(Sender , Source: TObject; X, Y: Integer;
State: TDragState; var Accept: Boolean);
begin
Panel3.Parent:=Sender as TWinControl;
Accept:=True;
panel3.Left:=x;
panel3.top:=y;
end;
and the panel3 must have the following function in the OnDragOver action. This is done so that as the mouse moves over panel3, it will pass its movements to the parent.
procedure TForm1.Panel3DragOver(Send er, Source: TObject; X, Y: Integer;
State: TDragState; var Accept: Boolean);
begin
FormDragOver(Panel3.Parent , Source, Panel3.Left+X, Panel3.Top+Y, State, Accept);
end;
procedure TForm1.FormDragOver(Sender
State: TDragState; var Accept: Boolean);
begin
Panel3.Parent:=Sender as TWinControl;
Accept:=True;
panel3.Left:=x;
panel3.top:=y;
end;
and the panel3 must have the following function in the OnDragOver action. This is done so that as the mouse moves over panel3, it will pass its movements to the parent.
procedure TForm1.Panel3DragOver(Send
State: TDragState; var Accept: Boolean);
begin
FormDragOver(Panel3.Parent
end;
BTW if you want the dragging centered, change the following:
panel3.Left:=x-panel3.Widt h div 2;
panel3.top:=y-panel3.heigh t div 2;
panel3.Left:=x-panel3.Widt
panel3.top:=y-panel3.heigh
ASKER
Your code just splash the panel in another panel . I wish a real drag&drop .
Can help me ?