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
Solved

TDragObject

Posted on 2001-06-22
5
615 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
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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
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…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used.

790 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