TDragObject

How to correctly implement.
DionoAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

rwilson032697Commented:
You will find all you need to know here:

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

Cheers,

Raymond.
0
LischkeCommented:
Ray, please inform yourself a bit better. I'm a bit surprised about this and other quick shots which didn't hit the goal. TDragObject has nothing to do with OLE drag'n drop (for which you gave the link). Do I really need such a top expert like you to remind about proposing comments instead of answers?

Diono,

TDragObjects are mainly to give you a means to control how the drag'n drop stuff of the VCL happens. You can create your own descentant of TDragObject in the OnStartDrag event of a control. Usually this is not done and the VCL creates an internal object. In this case the OnDragOver and OnDragDrop events contain as Source parameter the control which initiated the drag'n drop operation. If you create your own drag object, though, then you get this object as Source parameter in the mentioned events. What you then do with this drag object is totally up to you. E.g. you could create one global drag object and pass it in every drag operation around but can store some sensible data in it which is needed by other controls while dragging.

Ciao, Mike
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
rwilson032697Commented:
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.
0
Cloud Class® Course: C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

LischkeCommented:
;-) didn't mean it hard...

Ciao, Mike

PS: This is the first answer withdraw I'
ve seen. Cool feature I think...
0
DionoAuthor Commented:
An example would've been great!
0
LischkeCommented:
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
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.