RAD Studio VCL Reference
ContentsIndex
PreviousUpNext
Controls.TDragState Enumeration

TDragState is used to specify how the mouse is moving in relation to a control.

Pascal
TDragState = (
  dsDragEnter,
  dsDragLeave,
  dsDragMove
);
C++
enum TDragState {
  dsDragEnter,
  dsDragLeave,
  dsDragMove
};

Controls

TDragState describes how the mouse is moving in relation to a control that it is passing over. It has one of the following values:

Value 
Meaning 
dsDragEnter  
The mouse just moved over the control.  
dsDragLeave  
The mouse is moving off of the control.  
dsDragMove  
The mouse is moving while over the control.  

 

Delphi Examples: 

{
This code is an OnDragOver event handler that won't allow a
label control to be dropped on a panel control and stops the
dragging of the label as soon as the user drags the label
onto the panel:
Note: Set the label's DragMode property to dmAutomatic.
}
procedure TForm1.FormDragDrop(Sender, Source: TObject; X, Y: Integer);
begin
  TForm1(Source).Left := X;
  TForm1(Source).Top := Y;
end;

procedure TForm1.FormDragOver(Sender, Source: TObject; X, Y: Integer;
  State: TDragState; var Accept: Boolean);
begin
  Accept := Source is TLabel;
end;

procedure TForm1.Panel1DragOver(Sender, Source: TObject; X, Y: Integer;
  State: TDragState; var Accept: Boolean);
begin
  Accept := False;
  if (Source is TLabel) and (State = dsDragEnter) then
    (Source as TLabel).EndDrag(False);
end;

 

Copyright(C) 2008 CodeGear(TM). All Rights Reserved.
What do you think about this topic? Send feedback!