Link to home
Start Free TrialLog in
Avatar of Diono
Diono

asked on

TDragObject

How to correctly implement.
Avatar of rwilson032697
rwilson032697

You will find all you need to know here:

http://www.melander.dk/delphi/dragdrop/

Cheers,

Raymond.
ASKER CERTIFIED SOLUTION
Avatar of Lischke
Lischke

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Ouch Mike, stop spanking me so hard! :o)

Mike is right. I confused TDropTarget with TDragObject.

I'll withdraw the answer... If you really meant the drag/drop stuff I pointed you at you know what to do :-)

Cheers,

Raymond.
;-) didn't mean it hard...

Ciao, Mike

PS: This is the first answer withdraw I'
ve seen. Cool feature I think...
Avatar of Diono

ASKER

An example would've been great!
Well, there's nothing special. Look at this code:

type
  TMyDragObject = class(TDragObject)
  protected
    procedure Finished(Target: TObject; X, Y: Integer; Accepted: Boolean); override;
  end;


  TMainForm = class(TForm)
  private
    FMyDragObject: TMyDragObject;
  end;


procedure TMainForm.ListBox1StartDrag(Sender: TObject; var DragObject: TDragObject);

begin
  if FMyDragObject = nil then FMyDragObject := TMyDragObject.Create;
  DragObject := FMyDragObject;
end;

{ TMyDragObject }

procedure TMyDragObject.Finished(Target: TObject; X, Y: Integer;
  Accepted: Boolean);
begin
  Beep;
  inherited;
end;

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

procedure TMainForm.FormDragDrop(Sender, Source: TObject; X, Y: Integer);
begin
  if Source = FMyDragObject then ShowMessage('It''s mine');
end;


Ciao, Mike