Drag & Drop / Copy & Move (Respond to control key presses...)

Hi Guys.

I have an app that does drag & Drop. It works great. It looks somewhat like the windows folder explorer. I can move files from folders to folders.

Now I want to add the capability to respond to the Control key to change the behavior from copy to move (i.e. with CONTROL it copes, without CONTROL it moves). Like in many applications.

It seems like quite a common thing to do, but I'm not sure how to do it.

In my app, I have OnStartDrag in the "files" listbox, and then I put the file's ID as the DragObject. The cursor is changed automatically to the "drag" cursor.

Pretty simple so far. But now I'm baffled on how to proceed... how can I intercept the press/depress on Control while draging? I guess I can do it on the dragged-to object (The folders list) only. And then somehow change the cursor and remember that the CONTROL is pressed?

Any advice before I start tackling this?

Ron.
merteroAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

andrewjbCommented:
You probably want to catch it in the DragDrop event when you let go...

(Look at explorer - you can change whether shift/ctl are pressed as you drag a file)

To change the cursor as you go... doesn't the source of the drag/drop keep getting MouseMove events as you drag? (Even after the mouse has left the boundary of the component)... so you can check the button state in MouseMove, if you're dragging, and change the cusros there?
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
kretzschmarCommented:
take a look into my solution at
http://www.experts-exchange.com/Programming/Programming_Languages/Delphi/Q_20407731.html#7873367

your needed part from there (in procedure SetTreeItemTypeSet):

....
  //First do as want to Move
  Result := [ddtMove];
  //Get Shift Key
  if (GetAsyncKeyState(VK_SHIFT) OR $FFFF) = -1 then
    Result := Result + [ddtSort] - [ddtMove];

  //Get Control Key
  if (GetAsyncKeyState(VK_CONTROL) OR $FFFF) = -1 then
    Result := Result + [ddtCopy] - [ddtMove];
.....

hope you get it

meikl ;-)

0
merteroAuthor Commented:
Thanks guys.

I had to do some tweaking myself (Chagne the dragged OBJECT was the key) but you got me started in the right direction.

Cheers,

M.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.