/// <summary>
        /// Sets the drop description for the drag image manager.
        /// </summary>
        /// <param name="dataObject">The DataObject to set.</param>
        /// <param name="dropDescription">The drop description.</param>
        public static void SetDropDescription(this IDataObject dataObject, DropDescription dropDescription)
        {
            ComTypes.FORMATETC formatETC;
            FillFormatETC(DropDescriptionFormat, TYMED.TYMED_HGLOBAL, out formatETC);

            // We need to set the drop description as an HGLOBAL.
            // Allocate space ...
            IntPtr pDD = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(DropDescription)));
            try
            {
                // ... and marshal the data
                Marshal.StructureToPtr(dropDescription, pDD, false);

                // The medium wraps the HGLOBAL
                System.Runtime.InteropServices.ComTypes.STGMEDIUM medium;
                medium.pUnkForRelease = null;
                medium.tymed = ComTypes.TYMED.TYMED_HGLOBAL;
                medium.unionmember = pDD;

                // Set the data
                ComTypes.IDataObject dataObjectCOM = (ComTypes.IDataObject)dataObject;
                dataObjectCOM.SetData(ref formatETC, ref medium, true);
            }
            catch
            {
                // If we failed, we need to free the HGLOBAL memory
                Marshal.FreeHGlobal(pDD);
                throw;
            }
        }
Exemple #2
0
        /// <summary>
        /// Sets the drop description for the drag image manager.
        /// </summary>
        /// <param name="dataObject">The DataObject to set.</param>
        /// <param name="dropDescription">The drop description.</param>
        public static void SetDropDescription(IDataObject dataObject, DropDescription dropDescription)
        {
            FillFormatETC(DropDescriptionFormat, TYMED.TYMED_HGLOBAL, out FORMATETC formatETC);

            // We need to set the drop description as an HGLOBAL.
            // Allocate space ...
            IntPtr pDD = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(DropDescription)));

            try
            {
                // ... and marshal the data
                Marshal.StructureToPtr(dropDescription, pDD, false);

                // The medium wraps the HGLOBAL
                STGMEDIUM medium;
                medium.pUnkForRelease = null;
                medium.tymed          = TYMED.TYMED_HGLOBAL;
                medium.unionmember    = pDD;

                // Set the data
                dataObject.SetData(ref formatETC, ref medium, true);
            }
            catch
            {
                // If we failed, we need to free the HGLOBAL memory
                Marshal.FreeHGlobal(pDD);
                throw;
            }
        }
Exemple #3
0
        /// <summary>
        /// Sets the drop description for the drag image manager.
        /// </summary>
        /// <param name="dataObject">TheSome text DataObject to set.</param>
        /// <param name="dropDescription">The drop description.</param>
        public static void SetDropDescription(this IDataObject dataObject, DropDescription dropDescription)
        {
            ComTypes.FORMATETC formatETC;
            FillFormatETC(DropDescriptionFormat, TYMED.TYMED_HGLOBAL, out formatETC);

            // We need to set the drop description as an HSome textGLOBAL.
            // Allocate space ...
            IntPtr pDD = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(DropDescription)));

            try
            {
                // ... and marshal the data
                Marshal.StructureToPtr(dropDescription, pDD, false);

                // The medium wraps the HGLOBAL
                System.Runtime.InteropServices.ComTypes.STGMEDIUM medium;
                medium.pUnkForRelease = null;
                medium.tymed          = ComTypes.TYMED.TYMED_HGLOBAL;
                medium.unionmember    = pDD;

                // Set the data
                ComTypes.IDataObject dataObjectCOM = (ComTypes.IDataObject)dataObject;
                dataObjectCOM.SetData(ref formatETC, ref medium, true);
            }
            catch
            {
                // If we failed, we need to free the HGLOBAL memory
                Marshal.FreeHGlobal(pDD);
                throw;
            }
        }
Exemple #4
0
        public static void SetDropDescription(System.Windows.IDataObject dataObject, DropDescription dropDescription)
        {
            FillFormatETC("DropDescription", TYMED.TYMED_HGLOBAL, out FORMATETC formatETC);
            IntPtr num = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(DropDescription)));

            try
            {
                Marshal.StructureToPtr((object)dropDescription, num, false);
                STGMEDIUM medium;
                medium.pUnkForRelease = (object)null;
                medium.tymed          = TYMED.TYMED_HGLOBAL;
                medium.unionmember    = num;
                ((System.Runtime.InteropServices.ComTypes.IDataObject)dataObject).SetData(ref formatETC, ref medium, true);
            }
            catch
            {
                Marshal.FreeHGlobal(num);
                throw;
            }
            if (dropDescription.szMessage != null)
            {
                SetBoolFormat(dataObject, "IsShowingText", true);
            }
        }
 public static void SetDropDescription(this System.Windows.IDataObject dataObject, DropDescription dropDescription)
 {
     FORMATETC formatETC;
     DataObjectExtensions.FillFormatETC("DropDescription", TYMED.TYMED_HGLOBAL, out formatETC);
     IntPtr num = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(DropDescription)));
     try
     {
         Marshal.StructureToPtr((object)dropDescription, num, false);
         STGMEDIUM medium;
         medium.pUnkForRelease = (object)null;
         medium.tymed = TYMED.TYMED_HGLOBAL;
         medium.unionmember = num;
         ((System.Runtime.InteropServices.ComTypes.IDataObject)dataObject).SetData(ref formatETC, ref medium, true);
     }
     catch
     {
         Marshal.FreeHGlobal(num);
         throw;
     }
     if (dropDescription.szMessage == null)
         return;
     DataObjectExtensions.SetIsShowingText(dataObject, true);
 }