OnEndDrag (C++)

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

void __fastcall TForm1::Label1EndDrag(TObject *Sender, TObject *Target, int X,
	  int Y)
{
  if (Sender->ClassNameIs("TLabel"))
  {
	String S = (dynamic_cast<TLabel *>(Sender))->Name + " was dropped and ";
	if (Target)
	  S = S + "accepted!";
	else
	  S = S + "rejected.";
	Status->Caption = S;
  }
}

Uses