When the user drags something over a control, that control receives an OnDragOver event, at which time it must indicate whether it can accept the item if the user drops it there. The drag cursor changes to indicate whether the control can accept the dragged item. To accept items dragged over a control, attach an event handler to the control's OnDragOver event.
The drag-over event has a parameter called Accept that the event handler can set to True if it will accept the item. Accept changes the cursor type to an accept cursor or not.
The drag-over event has other parameters, including the source of the dragging and the current location of the mouse cursor, that the event handler can use to determine whether to accept the drag. In the following VCL example, a directory tree view accepts dragged items only if they come from a file list box.
procedure TFMForm.DirectoryOutline1DragOver(Sender, Source: TObject; X, Y: Integer; State: TDragState; var Accept: Boolean); begin if Source is TFileListBox then Accept := True else Accept := False; end;
void __fastcall TForm1::TreeView1DragOver(TObject *Sender, TObject *Source, int X, int Y, TDragState State, bool &Accept) { if (Source->InheritsFrom(__classid(TFileListBox))) }
Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
|
What do you think about this topic? Send feedback!
|