Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Drag and Drop, and Images

100 views
Skip to first unread message

Bill Lee

unread,
Oct 7, 1998, 3:00:00 AM10/7/98
to
I have basic drag and drop working just fine in my application. Looking
through controls.pas, I see what looks like a nice addition: images that
can be dragged along with the cursor during drag/drop. However, I
haven't gotten this to work.

I have a TControl descendant, non visual, in which I encapsulate drag
information. I override GetDragImages to return a TImageList with an
image in it. I call BeginDrag on the control. The drag happens, but no
image gets displayed.

I have tried playing with SetDragIndex, ShowDragImage and other
functions of TImageList, and scanned through how controls.pas hooks up
to the imagelist and control through a proxy object it creates. I've
looked through the included demos, the help files, and the several
Delphi tomes I have.

I could not find any example showing this functionality in use. Can
someone point me to a sample, or otherwise show how I add drag images to
my drag operations? This is for inside the app, not the global image
dragging such as used when dragging to the trashcan.

Delphi3.02. I have 4, but haven't ported the app to it yet.


--Bill Lee
remove '-junk' in address if you want to reply directly to me.

Stuart C. Naifeh

unread,
Oct 7, 1998, 3:00:00 AM10/7/98
to
You have to create a TDragObject decendent, and create an instance of it in
the OnStartDrag event of the control. The TDragControlObject has some
behavior built in for images so you may save some work by decending from
that. In your drag object, you need to override the GetDragImages method to
return the image list you want to use.

Regards,
Stuart


Bill Lee wrote in message <361B761E...@junk-qualcomm.com>...

Bill Lee

unread,
Oct 8, 1998, 3:00:00 AM10/8/98
to
Looking at controls.pas, it wouldn't seem to be necessary to do this.
In OnStartDrag, if you don't create a drag object, the default
processing creates an instance of TDragControlObject. It in turn
responds to the GetDragImages by executing the same function on the
'contained' control.

But since *something* isn't working right with this process, I'll try
what you suggest.

Bill Lee

unread,
Oct 8, 1998, 3:00:00 AM10/8/98
to
Looking through controls.pas again, I see some clues.

First, the default processing never does a ShowDragImage, so that's part
of the problem. I was calling this on the ImageList directly during
processing of BeginDrag. Since other things are done to the ImageList
during drag startup, deferring this may be useful. I'll try handling it
in the first DragOver handler.

I also notice a control style, 'csDisplayDragImage'. This shows up in
the procedure DragTo, and seems to end ImageList dragging if the Target
doesn't have this control style set.

It looks like I have to add this control style to all controls that I
want to have the images show up over? Quite a pain, if so.

Confirmations? Comments?

0 new messages