Winforms Control Drag/Drop registration via InterOp
quite a long one I am afraid but please bear with me...

I have a VSTO project which allows dragging and dropping of Outlook items (mails, attachments etc) onto a winforms control - specifically a TreeView (hosted in a CustomTaskPane inside Outlook) which provides the usual UI feedback by highlighting folders that the drag is occuring over.
I have set the TreeView's AllowDrop property to true and all the events I want are firing and everything is working great.

However, I have a situation in older versions of Outlook (pre 2010) where the object model exposed by VSTO is older and I don't have access to the properties which allow me to capture what is being dragged via Outlook iself through managed code.

I have got around this problem by hooking directly into the native Windows drag/drop. The code to allow this is pretty extensive and involves alot of interop work but the crux of it is I have to register a control via - 

    
    [DllImport("OLE32.DLL", ExactSpelling = true, CharSet = CharSet.Auto, PreserveSig = false)]
        public static extern void RegisterDragDrop(HandleRef hwnd, IOleDropTarget target);

I extend the TreeView class and implement IOleDropTarget to allow my new control class to be registered via this method. Again this works great and after a bit of c# magic anything dropped anywhere in the treview gives me the dropped object as a byte array that I can use.

**Here's the problem**
Registering the TreeView via interop means I can't register it using it's AllowDrop property. Trying to do both throws an error telling me I can only register a control for drag/drop once. Registering it only via interop bypasses the 'managed' registration completely and as far as the TreeView is concerned it isn't registered, meaning I don't get any Drag/Drop events coming through and I can't handle any feedback to the user.

Is there any way I can use the interop method of registration and at the same time tell the same control that it is registered for drag drop via the usual winforms method?
Alternatively can anyone think of any clever way of overlaying controls so that I get the feedback from the TreeView and a dropped event from an interop registerd control?

Hope this all makes sense.

Huge thanks in advance for any answers.

 
Winforms Control Drag/Drop registration via InterOp
===

quite a long one I am afraid but please bear with me...

I have a VSTO project which allows dragging and dropping of Outlook items (mails, attachments etc) onto a winforms control - specifically a TreeView (hosted in a CustomTaskPane inside Outlook) which provides the usual UI feedback by highlighting folders that the drag is occuring over.
I have set the TreeView's AllowDrop property to true and all the events I want are firing and everything is working great.

However, I have a situation in older versions of Outlook (pre 2010) where the object model exposed by VSTO is older and I don't have access to the properties which allow me to capture what is being dragged via Outlook iself through managed code.

I have got around this problem by hooking directly into the native Windows drag/drop. The code to allow this is pretty extensive and involves alot of interop work but the crux of it is I have to register a control via - 

    
    [DllImport("OLE32.DLL", ExactSpelling = true, CharSet = CharSet.Auto, PreserveSig = false)]
        public static extern void RegisterDragDrop(HandleRef hwnd, IOleDropTarget target);

I extend the TreeView class and implement IOleDropTarget to allow my new control class to be registered via this method. Again this works great and after a bit of c# magic anything dropped anywhere in the treview gives me the dropped object as a byte array that I can use.

**Here's the problem**
Registering the TreeView via interop means I can't register it using it's AllowDrop property. Trying to do both throws an error telling me I can only register a control for drag/drop once. Registering it only via interop bypasses the 'managed' registration completely and as far as the TreeView is concerned it isn't registered, meaning I don't get any Drag/Drop events coming through and I can't handle any feedback to the user.

Is there any way I can use the interop method of registration and at the same time tell the same control that it is registered for drag drop via the usual winforms method?
Alternatively can anyone think of any clever way of overlaying controls so that I get the feedback from the TreeView and a dropped event from an interop registerd control?

Hope this all makes sense.

Huge thanks in advance for any answers.

 