I wanna do a node which outputs Drag and Drop information about a window selected by a handle. I searched for it and I found very simple solutions like this http://www.jonasjohn.de/snippets/csharp/drag-and-drop-example.htm which was planned to be used for listboxes.
currently i only want a simple bang when DragEnter, DragDrop and DragLeave happens on that window and maybe i would like to retrieve the string what is dragged. Anyway I’ve only came to a mess which produces nothing but an “Object reference not set to an instance of an object.” exception. I’m suspicious that i’ve used “this”
window.DragEnter += new DragEventHandler(this.window_DragEnter);
in a wrong way. however if i say
window.DragEnter += new DragEventHandler(VVVV.Nodes.WindowsDragAndDropNode.window_DragEnter);
instead of “this” the compiler says
“An object reference is required for non-static field, method or property ‘VVVV.Nodes.WindowsDragAndDropNode.window_DragEnter(object, System.Windows.Forms.DragEventArgs)’”
however in all examples the method called on the event doesn’t have those “object” and “DragEventArgs” arguments in the DragEventHandler() just in the declaration so I don’t really understand where those two come from in the examples as well.
Anybody could help with this?
this is what i’m talking about (19.5 kB)
the first line is good. but the window you are trying to cast to a form is null. i think you can only cast c# form windows like this.
the compiler tries to tell you that you have to provide a object method reference and not a static method reference.
if the window cast would work, the code could work like this:
- region usings
[PluginInfo(Name = “DragAndDrop”, Category = “Windows”, Help = “Basic template with one value in/out”, Tags = “”)](PluginInfo(Name = “DragAndDrop”, Category = “Windows”, Help = “Basic template with one value in/out”, Tags = “”))
public class WindowsDragAndDropNode : IPluginEvaluate
#region fields & pins
[Input(“Window Handle”, DefaultValue = 0)](Input(“Window Handle”, DefaultValue = 0))
Control FWindow; //store the window so that it doesn't get garbage collected
object FDragThreadLock = new object();
#endregion fields & pins
//called when data for any output pin is requested
public void Evaluate(int SpreadMax)
FDragEnter.SliceCount = 1;
IntPtr handle = new IntPtr(FHandle(0));
FWindow = (handle==IntPtr.Zero) ? null : Control.FromHandle(handle); //store window
if(FWindow != null)
//do this only once
FWindow.DragEnter += new DragEventHandler(this.window_DragEnter);
FLogger.Log(LogType.Debug, "window is good");
FLogger.Log(LogType.Debug, "window of handle " + handle.ToInt64() + " is null, cast isn't working");
lock(FDragThreadLock) //make sure that no other thread is changing the state while writing it
//write the state
FDragEnter(0) = FDragEnterState;
//reset the state
FDragEnterState = false;
//this can happen at any time, so you have to store the state until the vvvv main loop can read it
public void window_DragEnter(object sender, System.Windows.Forms.DragEventArgs e)
lock(FDragThreadLock) //make sure vvvv is not writing the state while it gets changed
FDragEnterState = true;
e.Effect = DragDropEffects.All;
aah thanks! I see now! well that’s a bad news. do you know another way to get drag’n’drop data about that renderer?
i found this: http://msdn.microsoft.com/en-us/library/windows/desktop/bb774303(v=vs.85).aspx but retrieving the info about the dropped file with “DragQueryFile” requires some pointer story i’m not really sure about in managed environment.
hmm that’s some kind of low-level network communication method it seems to have nothing to do with window messages
it was using the same terms, probably the same api, but check the new links. maybe they help…?
that message trapping seems useful. i’ve tried GetMessage with DLLImport from user32.dll but that freezed vvvv. I’ll give that a try!
edit: maaan this is a disaster. i’ll just create a separate form for dropping files:D