conditional preventing of dragging files outside of my own app

  • Thread starter Thread starter Stephan Steiner
  • Start date Start date
S

Stephan Steiner

Hi

I'm currently working on an application which can be seen as sort of a
modern version of Norton Commander - I have a file list of a directory
on my local machine in a Listview in detail mode, and the same for a
remote location (not via SMB but a self-written remoting based API).

In order to make the application as useful as possible, I've added cut/
copy&paste and drag&drop operations. For each operation, I look at the
source and destination and then do the appropriate action (e.g. if you
drag a file to my left hand side listview.. it's a local copy/move
operation - if you drag it to the right hand side listview, the file
has to be uploaded to the remote machine). So far so good - there are
a few instances though where I'd like to prevent that information be
taken from the remote side and dropped into another file-capable
application (e.g. Windows Explorer) since in that case, the external
application would handle the drop operation and naturally it isn't
aware of all the conditions of my application.

So I looked at DragLeave and the GiveFeedback events... but the first
one gives me zero control over the DragDropEffect - and the latter
doesn't allow any modifications. Thus I'm left wondering if there's a
way to set the DragDropEffect to None when a drag operation
originating in my right hand side listview leaves the bounds of my
forum or of I have to resort to not using FileDrop for operations
originating from my remote side listview (which would be kinda
annoying seeing as operations that originate outside that listview
need to be in that format (since I want drag and drop TO the remote
machine)..

Regards
Stephan
 
I've found a sample that appears to do what I need:
http://msdn2.microsoft.com/en-us/library/system.windows.forms.control.querycontinuedrag.aspx

It makes use of the QueryContinueDrag event. So I've written an event
handler for my remote listview which mimics what is done in the
sample, but I never got the event the fire in the first place - but
when I searched for that behavior I found that I need to call
DoDragDrop on my listview - I used to call it on my main form.
 
Back
Top