Solved

TDragObject

Posted on 2001-06-22
5
593 Views
Last Modified: 2008-02-26
I know this sounds like I just want you to write code for me, but I HAVE tried to figure this one out. I'm implementing some drag and drop into my program. When a user starts dragging, I need to display a custom cursor/image, moving with mouse. I've done a little reading, and I found the TDragObject and TDragImageList, but I cant seem to get them to work. What I want is to have two TImage's, one with a picture and one without. When a user drags the first with a picture, the cursor turns into the picture (or at least displays behind the cursor) and moves and can be "dropped" into the second TImage. Just a simple example will get me on my way. :)
0
Comment
Question by:Matt2000
  • 3
5 Comments
 
LVL 44

Accepted Solution

by:
CrazyOne earned 200 total points
Comment Utility
This may help you get started

From Delphi Help

QUOTE

TDragObject.GetDragCursor

Indicates which cursor should be displayed in response to mouse moves.

function GetDragCursor(Accepted: Boolean; X, Y: Integer): TCursor; virtual;

Description

When the mouse is moved, GetDragCursor is called automatically.  The Accepted parameter indicates whether the object under the mouse accepts the drag. The X and Y parameters represent the current position of the mouse. The TCursor value returned by GetDragCursor is used to indicate the current drag cursor.

GetDragCursor returns crDrag to when Accepted is True, crNoDrop otherwise.

UNQUOTE


QUOTE

TDragObject.GetDragImages

Returns an image list containing the image to be displayed while dragging.

function GetDragImages: TDragImageList; virtual;

Description

GetDragImages is called at the beginning of a drag and drop operation. As implemented in TDragObject, GetDragImages returns nil, meaning that only the cursor is used to indicate the drag operation.

In descendant classes, the image list normally contains only one image, and the drag object automatically creates and maintains the image list.

UNQUOTE


The Crazy One
0
 
LVL 17

Expert Comment

by:inthe
Comment Utility
Hi,
i would make life easy and say look at :

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

one of the examples is doing just as you want.

Regards Barry
0
 

Author Comment

by:Matt2000
Comment Utility
ok.. I didnt think it would be this hard, but for some reason I cannot find ANYWHERE (I've spent the last 3 hours searching) an example of what I'm looking for. Those components are nice, Barry, but I'm going to need to be able to do it another way. For one, I dont want my dragging and dropping available to other apps. And second, I'm going to be making some major modifications to the object being dragged..  the visual part is one minor aspect. Anyways.. if anybody has an example, please :)
0
 

Author Comment

by:Matt2000
Comment Utility
........  it figures...... I finally got it. I'm not going to delete the question tho, because theres nothing I hate more than finding the exact question I wanted on here and then seeing that it was deleted :) so, I'm going to clean up the coding tomorrow and post it, then figure out something to do with the points...
0
 

Author Comment

by:Matt2000
Comment Utility
Ok.. the trick is in the GetDragImages. A class of TControl with the GetDragImages function overriden to return an internal (or external) TDragImageList will do it. The other thing is in the ControlStyle. Over any control that you want to display the image over (including the drag source class) you need to add [csDisplayDragImage] to its ControlSytle set.
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now