Solved

TDragObject

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
Migrating to Microsoft Office 365 is becoming increasingly popular for organizations both large and small. If you have made the leap to Microsoft’s cloud platform, you know that you will need to create a corporate email signature for your Office 365…

895 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

12 Experts available now in Live!

Get 1:1 Help Now