Solved

TDragObject

Posted on 2001-06-22
5
624 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
5 Comments
 
LVL 44

Accepted Solution

by:
CrazyOne earned 200 total points
ID: 6220103
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
ID: 6220201
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
ID: 6220888
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
ID: 6220996
........  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
ID: 6226120
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
If you're a developer or IT admin, you’re probably tasked with managing multiple websites, servers, applications, and levels of security on a daily basis. While this can be extremely time consuming, it can also be frustrating when systems aren't wor…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

691 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