Drag and drop from windows forms to desktop and windows explorer

Please support our C# advertiser: Intel Parallel Studio Home
Reply

Join Date: Aug 2008
Posts: 169
Reputation: murderotica is an unknown quantity at this point 
Solved Threads: 2
murderotica's Avatar
murderotica murderotica is offline Offline
Junior Poster

Drag and drop from windows forms to desktop and windows explorer

 
0
  #1
Jan 6th, 2009
Hello there, I've been having a hard time lately with implementing the drag and drop functionality outside the windows forms. I have no problem doing drag and drop within and between windows forms and from the desktop to the windows form. I have created an application where you can drag and drop any item on it. My problem is, I do not know how to implement the reverse of my application, to drag and drop from my app to the desktop or any destination outside my form. Any advise and ideas I will gratefully accept. Thank you.
An Avalanche In D Minor
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 1,735
Reputation: LizR has a spectacular aura about LizR has a spectacular aura about 
Solved Threads: 186
LizR LizR is offline Offline
Posting Virtuoso

Re: Drag and drop from windows forms to desktop and windows explorer

 
0
  #2
Jan 6th, 2009
google is your friend - a bit of resarch to find out what the desktop wants and will accept dropped onto it should help.
Did I just hear "You gotta help us, Doc. We've tried nothin' and we're all out of ideas" ? Is this you? Dont let this be you! I will put in as much effort as you seem to.
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 169
Reputation: murderotica is an unknown quantity at this point 
Solved Threads: 2
murderotica's Avatar
murderotica murderotica is offline Offline
Junior Poster

Re: Drag and drop from windows forms to desktop and windows explorer

 
0
  #3
Jan 6th, 2009
I found a resource and tried it but it seems that when I try to drop my file to the desktop, nothing happens. I can drag it already but it cannot drop the file. Here's what I did:

  1. private void listview_ItemDrag(object sender, ItemDragEventArgs e){
  2. DataObject object = new DataObject()
  3. string f = listview.SelectedItems[0].Text;
  4. object.SetData(DataFormats.FileDrop, f);
  5. DoDragDrop(object, DragDropEffects.All);
  6. }

It can drag already but cannot drop. What do you think is the problem?
Last edited by murderotica; Jan 6th, 2009 at 5:17 am.
An Avalanche In D Minor
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 169
Reputation: murderotica is an unknown quantity at this point 
Solved Threads: 2
murderotica's Avatar
murderotica murderotica is offline Offline
Junior Poster

Re: Drag and drop from windows forms to desktop and windows explorer

 
0
  #4
Jan 7th, 2009
Maybe I need a RegisterDragDrop() function but it seems its not available in C#?
An Avalanche In D Minor
Reply With Quote Quick reply to this message  
Join Date: Jun 2009
Posts: 1
Reputation: exploree_123 is an unknown quantity at this point 
Solved Threads: 0
exploree_123 exploree_123 is offline Offline
Newbie Poster

Re: Drag and drop from windows forms to desktop and windows explorer

 
0
  #5
Jun 20th, 2009
hi
i want to implement that u have implemented..drag and drop anywhere outside the form but using mouse events only no drag and drop events....
can u help me regarding this...........

thanks in advance
Reply With Quote Quick reply to this message  
Join Date: May 2007
Posts: 81
Reputation: it2051229 is an unknown quantity at this point 
Solved Threads: 1
it2051229 it2051229 is offline Offline
Junior Poster in Training

Re: Drag and drop from windows forms to desktop and windows explorer

 
0
  #6
Jun 20th, 2009
hmmm... the only way I can think of to do that one is that to play with the location of the object that is being dragged.. so let's say while you
're dragging your object the X and Y Coordinates is updated.. now when you release the mouse, you try to check the X and Y coordinates of the object and if it is outside the bounds of the FORM, then you assume that the object has been dragged out of the form and perform the necessary event...

i haven't done this yet but give it a try and tell me if it worked
Reply With Quote Quick reply to this message  
Join Date: Mar 2008
Posts: 323
Reputation: Diamonddrake is a jewel in the rough Diamonddrake is a jewel in the rough Diamonddrake is a jewel in the rough 
Solved Threads: 39
Diamonddrake's Avatar
Diamonddrake Diamonddrake is offline Offline
Posting Whiz

Re: Drag and drop from windows forms to desktop and windows explorer

 
0
  #7
Jun 20th, 2009
http://social.msdn.microsoft.com/for...-0421a6378b47/

This information seems hand, for files, but just for sake of working code, there is a codeproject example that has a demo app with source code of how to drag a url shortcut to the desktop from you application found here

http://www.codeproject.com/KB/cs/dra...tshortcut.aspx

I wish I had more, I have been putting off working this out for a feature in an app I'm working on myself.

best of luck.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:



Similar Threads
Other Threads in the C# Forum
Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC