Reputation: 725
My requirement is to get details about the items which are being dragged from outlook 2007.
I have used a windows API to register drag drop event on Outlook 2007 as following ...
(public static extern int RegisterDragDrop(IntPtr hwnd, IOleDropTarget target);
),
and used IOleDropTarget
interface to retrieve information when the drag drop events occur.
Following is what I have done so far
IOleDropTarget Interface
[ComImport, Guid("00000122-0000-0000-C000-000000000046"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)]
public interface IOleDropTarget
{
[PreserveSig]
int OleDragEnter([In, MarshalAs(UnmanagedType.Interface)] object pDataObj, [In, MarshalAs(UnmanagedType.U4)] int grfKeyState, [In, MarshalAs(UnmanagedType.U8)] long pt, [In, Out] ref int pdwEffect);
[PreserveSig]
int OleDragOver([In, MarshalAs(UnmanagedType.U4)] int grfKeyState, [In, MarshalAs(UnmanagedType.U8)] long pt, [In, Out] ref int pdwEffect);
[PreserveSig]
int OleDragLeave();
[PreserveSig]
int OleDrop([In, MarshalAs(UnmanagedType.Interface)] object pDataObj, [In, MarshalAs(UnmanagedType.U4)] int grfKeyState, [In, MarshalAs(UnmanagedType.U8)] long pt, [In, Out] ref int pdwEffect);
}
At event of an item being dragged from outlook, following method fires with all the parameters passed in to the method .
int IOleDropTarget.OleDragEnter(object pDataObj, int grfKeyState, long pt, ref int pdwEffect)
{
retirn 0;
}
Is it possible to get the information about the item which is being dragged using the pDataObj
?
So far i have tried following to get information out of this object which gave me no information about the item being dragged.
Type myType = pDataObj.GetType();
Is there other things to do to get the information I want ?
Code examples will be appreciated
Thank you
Upvotes: 0
Views: 269
Reputation: 49397
You need to get the running Outlook instance and then get the Selection object from the active explorer window. It will contain the dragged data.
// Check whether there is an Outlook process running.
if (Process.GetProcessesByName("OUTLOOK").Count() > 0)
{
// If so, use the GetActiveObject method to obtain the process and cast it to an Application object.
application = Marshal.GetActiveObject("Outlook.Application") as Outlook.Application;
}
See How to: Get and Log On to an Instance of Outlook for more information.
Upvotes: 1