drag and drop issue...

  • Thread starter Thread starter Lloyd Dupont
  • Start date Start date
L

Lloyd Dupont

If I use software like OpenOffice and try to drag text I could notice that
1. when I drag inside the document I'm moving the text
2. when I drag outside the document I'm copying the text

Yet it all looks like one smooth operation. With correct cursor feedback
(the little + marker next to the icon).
My problem is, once I call DoDragDrop() it's blocking, I have no other
opportunities to change the AllowedEffect to only Copy if I drag over, say,
an other control

And QueryContinueDrag:
1. don't allow me to change the efect
2. don't inform me about the current drop target

How could I do that?
(i.e. how could I modify the allowed efffect depending on the target (i.e.
wether it's me or not))
 
The DragDropEffects enum is a Flags enum so when DoDrapDrop'ing at the
source, if the data can be moved or copied then you set the effect to
DragDropEffects.Copy | DragDropEffects.Move
The when the destination handles drag enter, that can decide whether it
should be copied or moved to it.
I generally like to make a struct or class to hold more information that the
dragdrop'd data like the source object and anythign else used in the
descision. Then if dragging to another part of my app then i can handle it
easily.

HTH

Ciaran O'Donnell
 
No, it didn't H!

Perhaps I was not clear enough?
I'm trying to do something which looks impossible with the public .NET API,
yet Word and OpenOffice manage it.


In pseudo code it will look like that:

if(target == this)
AllowedEffect = Copy | Move;
else
AllowedEffect = Copy;

Of course the source should update the AllowedEffect every time the target
change. Which is not possible with the API, yet Word manage to do it.
So I wonder how it does it...
 
No, it didn't H!

Perhaps I was not clear enough?
I'm trying to do something which looks impossible with the public .NET
API, yet Word and OpenOffice manage it.

I do that with a TreeView as follows:

private void tvFav_DragOver(object sender, DragEventArgs e)
{
// Control key moves
if (e.Data.GetDataPresent(typeof(JExLVItem)))
{
if ((e.KeyState & 8) == 8)
e.Effect = DragDropEffects.Move;
else
e.Effect = DragDropEffects.Copy;
}
else
e.Effect = DragDropEffects.None;
}

Can you trap DragOver in whatever control you are dropping on? You could
then test for the type of data.
 
Back
Top