OnEndDrag (Delphi)

From RAD Studio Code Examples
Jump to: navigation, search

Description

This code displays a message in a label named Status. The message displayed depends on whether the dragged label control was successfully dropped into and accepted by another control.

Code

procedure TForm1.Label1EndDrag(Sender, Target: TObject; X, Y: Integer);
var
  S: string;
begin
  S := (Sender as TLabel).Name + ' was dropped... and ';
  if Target <> nil then 
    S := S + 'accepted!'
  else 
    S := S + 'rejected!';
  Status.Caption := S;
end;

Uses