private static System.Windows.Forms.IDataObject GetDataObject(int retryTimes, int retryDelay) { System.Runtime.InteropServices.ComTypes.IDataObject data = null; int num; int num2 = retryTimes; do { num = System.Windows.Forms.UnsafeNativeMethods.OleGetClipboard(ref data); if (num != 0) { if (num2 == 0) { ThrowIfFailed(num); } num2--; Thread.Sleep(retryDelay); } }while (num != 0); if (data == null) { return(null); } if ((data is System.Windows.Forms.IDataObject) && !Marshal.IsComObject(data)) { return((System.Windows.Forms.IDataObject)data); } return(new DataObject(data)); }
public void FilterDataObject(System.Runtime.InteropServices.ComTypes.IDataObject pDO, ref System.Runtime.InteropServices.ComTypes.IDataObject ppDORet) { if (this.m_defaultUIHandler != null) { this.m_defaultUIHandler.FilterDataObject(pDO, ref ppDORet); } }
// Private method to help accessing clipBoard for know retries before failing. private static IDataObject GetDataObject(int retryTimes, int retryDelay) { IComDataObject dataObject = null; int hr, retry = retryTimes; do { hr = UnsafeNativeMethods.OleGetClipboard(ref dataObject); if (hr != 0) { if (retry == 0) { ThrowIfFailed(hr); } retry--; System.Threading.Thread.Sleep(retryDelay /*ms*/); } }while (hr != 0); if (dataObject != null) { if (dataObject is IDataObject && !Marshal.IsComObject(dataObject)) { return((IDataObject)dataObject); } else { return(new DataObject(dataObject)); } } return(null); }
public static object GetDropDescription(this System.Runtime.InteropServices.ComTypes.IDataObject dataObject) { FORMATETC formatETC; FillFormatETC(DropDescriptionFormat, TYMED.TYMED_HGLOBAL, out formatETC); if (0 == dataObject.QueryGetData(ref formatETC)) { STGMEDIUM medium; dataObject.GetData(ref formatETC, out medium); try { return((DataObject.DropDescription)Marshal.PtrToStructure(medium.unionmember, typeof(BExplorer.Shell.DataObject.DropDescription))); } catch (AccessViolationException) { } finally { ReleaseStgMedium(ref medium); } } return(null); }
public DataObjectWrapper(System.Windows.IDataObject underlyingDataObject) { this.underlyingDataObject = underlyingDataObject; this.comUnderlyingDataObject = (System.Runtime.InteropServices.ComTypes.IDataObject) this.underlyingDataObject; FieldInfo innerDataField = this.underlyingDataObject.GetType().GetField("innerData", BindingFlags.NonPublic | BindingFlags.Instance); }
ComTypes.IDataObject GetSelectionDataObject() { IntPtr result; if (m_ComInterface == null) { return(null); } m_ComInterface.GetItemObject(SVGIO.SVGIO_SELECTION, typeof(ComTypes.IDataObject).GUID, out result); if (result != IntPtr.Zero) { ComTypes.IDataObject wrapped = (ComTypes.IDataObject) Marshal.GetTypedObjectForIUnknown(result, typeof(ComTypes.IDataObject)); return(wrapped); } else { return(null); } }
public static FILEDESCRIPTOR[] GetFileDescriptors(System.Runtime.InteropServices.ComTypes.IDataObject DataObject, out IntPtr hGlobal) { FORMATETC _req = new FORMATETC(); _req.tymed = TYMED.TYMED_HGLOBAL; _req.dwAspect = DVASPECT.DVASPECT_CONTENT; _req.cfFormat = (short)(System.Windows.DataFormats.GetDataFormat("FileGroupDescriptorW").Id); _req.lindex = -1; STGMEDIUM _val; DataObject.GetData(_req, out _val); hGlobal = _val.unionmember; IntPtr _fgptr = GlobalLock(_val.unionmember); NativeMethods.FILEGROUPDESCRIPTOR _fg; _fg = (NativeMethods.FILEGROUPDESCRIPTOR)Marshal.PtrToStructure(_fgptr, typeof(NativeMethods.FILEGROUPDESCRIPTOR)); _fgptr = new IntPtr(_fgptr.ToInt64() + 4); NativeMethods.FILEDESCRIPTOR[] _fileDesc = new NativeMethods.FILEDESCRIPTOR[_fg.cItems]; for (int _i = 0; _i < _fg.cItems; _i++) { _fileDesc[_i] = (NativeMethods.FILEDESCRIPTOR)Marshal.PtrToStructure(_fgptr, typeof(NativeMethods.FILEDESCRIPTOR)); _fgptr = new IntPtr(_fgptr.ToInt64() + Marshal.SizeOf(typeof(NativeMethods.FILEDESCRIPTOR))); } return(_fileDesc); }
/// <summary> /// Initializes a new instance of the <see cref="OutlookDataObject"/> class. /// </summary> /// <param name="underlyingDataObject">The underlying data object to wrap.</param> public OutlookDataObject(System.Windows.Forms.IDataObject underlyingDataObject) { //get the underlying dataobject and its ComType IDataObject interface to it this.underlyingDataObject = underlyingDataObject; this.comUnderlyingDataObject = (System.Runtime.InteropServices.ComTypes.IDataObject) this.underlyingDataObject; //get the internal ole dataobject and its GetDataFromHGLOBLAL so it can be called later FieldInfo innerDataField = this.underlyingDataObject.GetType().GetField("innerData", BindingFlags.NonPublic | BindingFlags.Instance); try { this.oleUnderlyingDataObject = (System.Windows.Forms.IDataObject)innerDataField.GetValue(this.underlyingDataObject); } catch (Exception ex) { Console.WriteLine(ex.Message); } try { this.getDataFromHGLOBLALMethod = this.oleUnderlyingDataObject.GetType().GetMethod("GetDataFromHGLOBLAL", BindingFlags.NonPublic | BindingFlags.Instance); } catch (Exception ex) { Console.WriteLine(ex.Message); } }
/// <remarks> /// Private method to help accessing clipBoard for know retries before failing. /// </remarks> private static IDataObject GetDataObject(int retryTimes, int retryDelay) { IComDataObject dataObject = null; HRESULT hr; int retry = retryTimes; do { hr = Ole32.OleGetClipboard(ref dataObject); if (hr != HRESULT.S_OK) { if (retry == 0) { throw new ExternalException(SR.ClipboardOperationFailed, (int)hr); } retry--; Thread.Sleep(millisecondsTimeout: retryDelay); } }while (hr != 0); if (dataObject != null) { if (dataObject is IDataObject ido && !Marshal.IsComObject(dataObject)) { return(ido); } return(new DataObject(dataObject)); } return(null); }
public int Drop(System.Runtime.InteropServices.ComTypes.IDataObject pDataObj, int grfKeyState, Win32Point pt, ref int pdwEffect) { bool bFolder = ((_folderObj.Attributes & FolderAttributes.Folder) == FolderAttributes.Folder); if (!bFolder) { return(WinError.S_OK); } List <string> files = DataObjectHelper.GetFiles(pDataObj); string sr = string.Empty; foreach (string file in files) { sr += file + "\r\n"; } sr += "to\r\n" + _folderObj.PathString; //MessageBox.Show(sr); Debug.WriteLine(sr); _folderObj.CopyItems(_folderObj, files); pdwEffect = (int)SFGAO.SFGAO_CANCOPY; return(WinError.S_OK); }
internal IStream GetStream(System.Runtime.InteropServices.ComTypes.IDataObject cdata, int index) { var format = new FORMATETC { cfFormat = (short)DataFormats.GetFormat(CFSTR_FILECONTENTS).Id, dwAspect = DVASPECT.DVASPECT_CONTENT, tymed = TYMED.TYMED_ISTREAM, lindex = index }; cdata.GetData(ref format, out STGMEDIUM medium); if (medium.tymed == format.tymed) { if (medium.unionmember != IntPtr.Zero && Marshal.GetObjectForIUnknown(medium.unionmember) is IStream stream) { return(stream); } // Workaround for Xamarin.Mac mobile framework if (medium.unionmember == IntPtr.Zero && medium.pUnkForRelease is IStream stream2) { return(stream2); } } return(null); }
public AsyncDataObject(System.Runtime.InteropServices.ComTypes.IDataObject data) : base(data) { this.asynchMode = false; this.inAsyncOperation = false; }
public int FilterDataObject( IDataObject pDo, out IDataObject ppDoRet) { // no data object by default ppDoRet = pDo; return(NativeMethods.SRESULTS.S_FALSE); }
public int FilterDataObject( IDataObject pDo, out IDataObject ppDoRet) { // no data object by default ppDoRet = pDo; return NativeMethods.SRESULTS.S_FALSE; }
public void Initialize(IntPtr pidlFolder, IntPtr pDataObj, IntPtr hKeyProgID) { if (pDataObj == IntPtr.Zero) { throw new ArgumentException(); } FORMATETC fe = new FORMATETC(); fe.cfFormat = (short)CLIPFORMAT.CF_HDROP; fe.ptd = IntPtr.Zero; fe.dwAspect = DVASPECT.DVASPECT_CONTENT; fe.lindex = -1; fe.tymed = TYMED.TYMED_HGLOBAL; STGMEDIUM stm; // The pDataObj pointer contains the objects being acted upon. In this // example, we get an HDROP handle for enumerating the selected files // and folders. IDataObject dataObject = (IDataObject)Marshal.GetObjectForIUnknown(pDataObj); dataObject.GetData(ref fe, out stm); try { // Get an HDROP handle. IntPtr hDrop = stm.unionmember; if (hDrop == IntPtr.Zero) { throw new ArgumentException(); } // Determine how many files are involved in this operation. uint nFiles = NativeMethods.DragQueryFile(hDrop, UInt32.MaxValue, null, 0); if (nFiles == 1) { // Get the path of the file. StringBuilder fileName = new StringBuilder(260); if (0 == NativeMethods.DragQueryFile(hDrop, 0, fileName, fileName.Capacity)) { Marshal.ThrowExceptionForHR(WinError.E_FAIL); } _selectedFile = fileName.ToString(); if (!AcceptFile(_selectedFile)) { Marshal.ThrowExceptionForHR(WinError.E_FAIL); } } else { Marshal.ThrowExceptionForHR(WinError.E_FAIL); } } finally { NativeMethods.ReleaseStgMedium(ref stm); } }
public MyDataObject(System.Windows.Forms.IDataObject underlyingDataObject) { this.underlyingDataObject = underlyingDataObject; this.comUnderlyingDataObject = (System.Runtime.InteropServices.ComTypes.IDataObject) this.underlyingDataObject; //FieldInfo innerDataField = this.underlyingDataObject.GetType().GetField("innerData", BindingFlags.NonPublic | BindingFlags.Instance); //this.oleUnderlyingDataObject = (System.Windows.Forms.IDataObject)innerDataField.GetValue(this.underlyingDataObject); //this.getDataFromHGLOBLALMethod = this.underlyingDataObject.GetType().GetMethod("GetDataFromHGLOBLAL", BindingFlags.NonPublic | BindingFlags.Instance); }
private DirectoryObject[] ProcessSelections(System.Runtime.InteropServices.ComTypes.IDataObject dataObj) { const string ClipboardFormat = "CFSTR_DSOP_DS_SELECTION_LIST"; if (dataObj == null) { return(null); } DirectoryObject[] result = null; STGMEDIUM stg; var fe = new FORMATETC { cfFormat = (short)DataFormats.GetFormat(ClipboardFormat).Id, ptd = IntPtr.Zero, dwAspect = DVASPECT.DVASPECT_CONTENT, lindex = -1, tymed = TYMED.TYMED_HGLOBAL }; dataObj.GetData(ref fe, out stg); var dsSelectionList = Memory.NativeMethods.GlobalLock(stg.unionmember); if (dsSelectionList == IntPtr.Zero) { NativeMethods.ReportWin32Exception(); } try { var current = dsSelectionList; var count = Marshal.ReadInt32(current); var fetchedAttributesCount = Marshal.ReadInt32(current, Marshal.SizeOf(typeof(uint))); if (count > 0) { result = new DirectoryObject[count]; current += Marshal.SizeOf(typeof(uint)) * 2; for (var i = 0; i < count; i++) { var selection = (DSSelection)Marshal.PtrToStructure(current, typeof(DSSelection)); result[i] = new DirectoryObject(selection.pwzName, selection.pwzADsPath, selection.pwzClass, selection.pwzUPN, GetFetchedAttributes(selection.pvarFetchedAttributes, fetchedAttributesCount, selection.pwzClass)); current += Marshal.SizeOf(typeof(DSSelection)); } } } finally { Memory.NativeMethods.GlobalUnlock(dsSelectionList); COM.NativeMethods.ReleaseStgMedium(ref stg); } return(result); }
public int GetWatermarks(System.Runtime.InteropServices.ComTypes.IDataObject dataObject, ref IntPtr watermark, ref IntPtr header, ref IntPtr palette, ref int stretch) { // not implemented, implementation not required watermark = IntPtr.Zero; header = IntPtr.Zero; palette = IntPtr.Zero; stretch = 0; return(0); }
/// <summary> /// Initializes a new instance of the <see cref="OutlookDataObject" /> class and adds the specified object to it. /// </summary> /// <param name="dataObject">The data to store.</param> public OutlookDataObject(IWindowsDataObject dataObject) { Check.ArgumentNull(dataObject, nameof(dataObject)); Check.InvalidCast(dataObject is IComDataObject, nameof(dataObject)); DataObject = dataObject; ComDataObject = (IComDataObject)DataObject; OleDataObject = DataObject.GetType().GetField("_innerData", BindingFlags.NonPublic | BindingFlags.Instance).GetValue <IWindowsDataObject>(DataObject); GetDataFromHGlobalMethod = OleDataObject.GetType().GetMethod("GetDataFromHGLOBLAL", BindingFlags.NonPublic | BindingFlags.Instance); }
internal Ole2BclDataObject(OleInterop.IDataObject oleData) { if (null == oleData) { throw new ArgumentNullException("Microsoft.VisualStudio.OLE.Interop.IDataObject"); } this.oleData = oleData; //this.bclData = oleData as BclComTypes.IDataObject; this.bclData = null; }
internal Ole2BclDataObject(BclComTypes.IDataObject bclData) { if (null == bclData) { throw new ArgumentNullException("System.Runtime.InteropServices.ComTypes.IDataObject"); } //this.oleData = bclData as OleInterop.IDataObject; this.oleData = null; this.bclData = bclData; }
void Interop.IDropTarget.Drop(ComTypes.IDataObject pDataObj, MK grfKeyState, Point pt, ref DragDropEffects pdwEffect) { if (m_DragTarget != null) { m_DragTarget.DragDrop(pDataObj, grfKeyState, pt, ref pdwEffect); m_DragTarget.Dispose(); m_DragTarget = null; } }
/// <include file='doc\DataObject.uex' path='docs/doc[@for="DataObject.DataObject1"]/*' /> /// <devdoc> /// <para>Initializes a new instance of the <see cref='System.Windows.Forms.DataObject'/> class, with the specified <see langword='IComDataObject'/>.</para> /// </devdoc> internal DataObject(IComDataObject data) { if (data is DataObject) { innerData = data as IDataObject; } else { Debug.WriteLineIf(CompModSwitches.DataObject.TraceVerbose, "Constructed DataObject based on IComDataObject"); innerData = new OleConverter(data); } Debug.Assert(innerData != null, "You must have an innerData on all DataObjects"); }
internal static extern IntPtr OleCreateStaticFromData( [In, MarshalAs(UnmanagedType.Interface)] System.Runtime.InteropServices.ComTypes.IDataObject pSrcDataObj, [In] ref Guid riid, [In] OleRender renderopt, [In] ref FORMATETC pFormatEtc, [In, MarshalAs(UnmanagedType.Interface)] IOleClientSite pClientSite, [In, MarshalAs(UnmanagedType.Interface)] IStorage pStg);
public int DragEnter(System.Runtime.InteropServices.ComTypes.IDataObject pDataObj, int grfKeyState, Win32Point pt, ref int pdwEffect) { //List<string> files = DataObjectHelper.GetFiles(pDataObj); //_folderObj.PathString bool bFolder = ((_folderObj.Attributes & FolderAttributes.Folder) == FolderAttributes.Folder); pdwEffect = bFolder ? (int)SFGAO.SFGAO_CANCOPY : 0; return(WinError.S_OK); }
/// <summary> /// Initializes a new instance of the <see cref="OutlookDataObject"/> class. /// </summary> /// <param name="underlyingDataObject">The underlying data object to wrap.</param> public OutlookDataObject(System.Windows.Forms.IDataObject underlyingDataObject) { //get the underlying dataobject and its ComType IDataObject interface to it this.underlyingDataObject = underlyingDataObject; this.comUnderlyingDataObject = (System.Runtime.InteropServices.ComTypes.IDataObject)this.underlyingDataObject; //get the internal ole dataobject and its GetDataFromHGLOBLAL so it can be called later FieldInfo innerDataField = this.underlyingDataObject.GetType().GetField("innerData", BindingFlags.NonPublic | BindingFlags.Instance); this.oleUnderlyingDataObject = (System.Windows.Forms.IDataObject)innerDataField.GetValue(this.underlyingDataObject); this.getDataFromHGLOBLALMethod = this.oleUnderlyingDataObject.GetType().GetMethod("GetDataFromHGLOBLAL", BindingFlags.NonPublic | BindingFlags.Instance); }
/// <summary> /// Initializes a new instance of the class. /// </summary> /// <param name="underlyingDataObject">The underlying data object to wrap.</param> public RemoteDataObject(System.Windows.Forms.IDataObject underlyingDataObject) { //get the underlying dataobject and its ComType IDataObject interface to it this.underlyingDataObject = underlyingDataObject; comUnderlyingDataObject = (System.Runtime.InteropServices.ComTypes.IDataObject) this.underlyingDataObject; //get the internal ole dataobject and its GetDataFromHGLOBAL so it can be called later FieldInfo innerDataField = this.underlyingDataObject.GetType().GetField("innerData", BindingFlags.NonPublic | BindingFlags.Instance); oleUnderlyingDataObject = (System.Windows.Forms.IDataObject)innerDataField.GetValue(this.underlyingDataObject); getDataFromHGLOBALMethod = oleUnderlyingDataObject.GetType().GetMethod("GetDataFromHGLOBAL", BindingFlags.NonPublic | BindingFlags.Instance); }
void IDropTarget.Drop(IDataObject pDataObj, int grfKeyState, Point pt, ref int pdwEffect) { if (_mDragTarget != null) { _mDragTarget.Drop(pDataObj, grfKeyState, pt, ref pdwEffect); _mDragTarget.Dispose(); _mDragTarget = null; } }
/// <summary> /// Initializes a new instance of the <see cref="OutlookDataObject"/> class. /// </summary> /// <param name="underlyingDataObject">The underlying data object to wrap.</param> public OutlookDataObject(System.Windows.Forms.IDataObject underlyingDataObject) { //get the underlying dataobject and its ComType IDataObject interface to it this._underlyingDataObject = underlyingDataObject; _comUnderlyingDataObject = (System.Runtime.InteropServices.ComTypes.IDataObject) this._underlyingDataObject; //get the internal ole dataobject and its GetDataFromHGLOBLAL so it can be called later var innerDataField = this._underlyingDataObject.GetType().GetField("innerData", BindingFlags.NonPublic | BindingFlags.Instance); _oleUnderlyingDataObject = (System.Windows.Forms.IDataObject)innerDataField.GetValue(this._underlyingDataObject); _getDataFromHgloblalMethod = _oleUnderlyingDataObject.GetType().GetMethod("GetDataFromHGLOBLAL", BindingFlags.NonPublic | BindingFlags.Instance); }
internal DataObject(IComDataObject data) { if (data is DataObject) { innerData = data as IDataObject; } else { Debug.WriteLineIf(CompModSwitches.DataObject.TraceVerbose, "Constructed DataObject based on IComDataObject"); innerData = new OleConverter(data); } Debug.Assert(innerData != null, "You must have an innerData on all DataObjects"); }
public int QueryAcceptData(System.Runtime.InteropServices.ComTypes.IDataObject lpdataobj, IntPtr lpcfFormat, int reco, int fReally, IntPtr hMetaPict) { if (reco != 0) { return(-2147467263); } DataObject obj2 = new DataObject(lpdataobj); if ((obj2 == null) || (!obj2.GetDataPresent(DataFormats.Text) && !obj2.GetDataPresent(DataFormats.UnicodeText))) { return(-2147467259); } return(0); }
long MsHtmHstInterop.IDropTarget.DragEnter( [In] System.Runtime.InteropServices.ComTypes.IDataObject pDataObject, [In] int grfKeyState, [In] POINTL pt, [In, Out] ref uint pdwEffect ) { uint effect = 0; if (m_pPreDropTarget != null) { m_pPreDropTarget.DragEnter(pDataObject, grfKeyState, pt, ref effect); } pdwEffect = effect | 1; return(S_OK); }
/// <summary> /// Sets up an advisory connection to the data object. /// </summary> /// <param name="dataObject">The data object on which to set the advisory connection.</param> /// <param name="sink">The advisory sink.</param> /// <param name="format">The format on which to callback on.</param> /// <param name="advf">Advisory flags. Can be 0.</param> /// <returns>The ID of the newly created advisory connection.</returns> public static int Advise(this System.Runtime.InteropServices.ComTypes.IDataObject dataObject, IAdviseSink sink, string format, ADVF advf) { // Internally, we'll listen for any TYMED FORMATETC formatETC; FillFormatETC(format, TYMED_ANY, out formatETC); int connection; int hr = dataObject.DAdvise(ref formatETC, advf, sink, out connection); if (hr != 0) { Marshal.ThrowExceptionForHR(hr); } return(connection); }
internal Ole2BclDataObject(BclComTypes.IDataObject bclData) { if (null == bclData) throw new ArgumentNullException("System.Runtime.InteropServices.ComTypes.IDataObject"); //this.oleData = bclData as OleInterop.IDataObject; this.oleData = null; this.bclData = bclData; }
public int DragDrop(IDataObject pDataObj, int grfKeyState, Point pt, ref DragDropEffects pdwEffect) { try { if(DragFileOver != null) { DragEventArgs e = new DragEventArgs(null, grfKeyState, pt.X, pt.Y, DragDropEffects.Move | DragDropEffects.Copy | DragDropEffects.Scroll, pdwEffect); DragFileOver(null, e); pdwEffect = e.Effect; } else { pdwEffect = DragDropEffects.Copy; } if(pdwEffect != DragDropEffects.None) { if(DragFileDrop != null) { IntPtr ptr; byte[] buffer; switch(DragFileDrop(out ptr, out buffer)) { case -1: return 0; case 0: { IShellFolder ppv = null; object obj2 = null; Guid riid = ExplorerGUIDs.IID_IShellFolder; Guid guid2 = ExplorerGUIDs.IID_IDropTarget; using(IDLWrapper wrapper = new IDLWrapper(buffer)) { if(wrapper.Available && wrapper.IsDropTarget) { try { IntPtr ptr2; if(PInvoke.SHBindToParent(wrapper.PIDL, riid, out ppv, out ptr2) == 0) { uint rgfReserved = 0; IntPtr[] apidl = new IntPtr[] { ptr2 }; if(ppv.GetUIObjectOf(ptr, 1, apidl, ref guid2, ref rgfReserved, out obj2) == 0) { _IDropTarget target = obj2 as _IDropTarget; if(target != null) { DragDropEffects effects = pdwEffect; if(target.DragEnter(pDataObj, iLastKeyState, pt, ref effects) == 0) { effects = pdwEffect; if(target.DragOver(iLastKeyState, pt, ref effects) == 0) { if((iLastKeyState & 2) != 0) { pdwEffect = DragDropEffects.Link | DragDropEffects.Move | DragDropEffects.Copy; } return target.DragDrop(pDataObj, iLastKeyState, pt, ref pdwEffect); } } } } } } catch { } finally { if(ppv != null) { Marshal.ReleaseComObject(ppv); } if(obj2 != null) { Marshal.ReleaseComObject(obj2); } if(DragDropEnd != null) { DragDropEnd(this, EventArgs.Empty); } } } } return 0; } } } FORMATETC format = new FORMATETC(); format.cfFormat = 15; format.ptd = IntPtr.Zero; format.dwAspect = DVASPECT.DVASPECT_CONTENT; format.lindex = -1; format.tymed = TYMED.TYMED_HGLOBAL; STGMEDIUM medium = new STGMEDIUM(); try { pDataObj.GetData(ref format, out medium); PInvoke.SendMessage(hwnd, 0x233, medium.unionmember, IntPtr.Zero); } catch { } finally { PInvoke.ReleaseStgMedium(ref medium); } } } finally { if(pDataObj != null) { Marshal.FinalReleaseComObject(pDataObj); } } return 0; }
/// <summary> /// Creates an AdviseSink associated to the specified data object. /// </summary> /// <param name="data">The data object.</param> public AdviseSink(IDataObject data) { m_data = data; }
public static extern int OleSetClipboard(IComDataObject pDataObj);
public static extern int OleGetClipboard(ref IComDataObject data);
public static extern void DoDragDrop(IComDataObject dataObject, UnsafeNativeMethods.IOleDropSource dropSource, int allowedEffects, int[] finalEffect);
public int DragEnter(IDataObject pDataObj, int grfKeyState, Point pt, ref DragDropEffects pdwEffect) { try { if(DragFileEnter != null) { FORMATETC format = new FORMATETC(); format.cfFormat = 15; format.ptd = IntPtr.Zero; format.dwAspect = DVASPECT.DVASPECT_CONTENT; format.lindex = -1; format.tymed = TYMED.TYMED_HGLOBAL; if(pDataObj.QueryGetData(ref format) >= 0) { STGMEDIUM medium = new STGMEDIUM(); try { try { pDataObj.GetData(ref format, out medium); pdwEffect = DragFileEnter(medium.unionmember, pt, grfKeyState); } catch { pdwEffect = DragDropEffects.None; } goto Label_00A0; } finally { PInvoke.ReleaseStgMedium(ref medium); } } pdwEffect = DragDropEffects.None; } else { pdwEffect = DragDropEffects.Copy; } } finally { if(pDataObj != null) { Marshal.FinalReleaseComObject(pDataObj); } } Label_00A0: return 0; }
internal Ole2BclDataObject(OleInterop.IDataObject oleData) { if (null == oleData) throw new ArgumentNullException("Microsoft.VisualStudio.OLE.Interop.IDataObject"); this.oleData = oleData; //this.bclData = oleData as BclComTypes.IDataObject; this.bclData = null; }
public static DragDropEffects DoDragDrop(DependencyObject dragSource, IDataObject dataObject, DragDropEffects allowedEffects) { int[] finalEffect = new int[1]; try { NativeMethods.DoDragDrop(dataObject, new DropSource(), (int)allowedEffects, finalEffect); } finally { var virtualFileDataObject = dataObject as VirtualFileDataObject; if ((null != virtualFileDataObject) && !virtualFileDataObject.IsAsynchronous && virtualFileDataObject._inOperation) { // Call the end action and exit the operation if (null != virtualFileDataObject._endAction) { virtualFileDataObject._endAction(virtualFileDataObject); } virtualFileDataObject._inOperation = false; } } return (DragDropEffects)(finalEffect[0]); }
public OleConverter(IComDataObject data) { Debug.WriteLineIf(CompModSwitches.DataObject.TraceVerbose, "OleConverter: Constructed OleConverter"); innerData = data; }
/// <summary> /// Initializes a new instance of the class, with the specified /// </summary> internal DataObject(IComDataObject data) { if (data == null) { throw new ArgumentNullException("data"); } _innerData = new OleConverter(data); }
//------------------------------------------------------ // // Constructors // //------------------------------------------------------ #region Constructors public OleConverter(IComDataObject data) { _innerData = data; }
// Inserts an embedded object into the document, replacing a range of text. private void InsertEmbeddedAtRange(TextPointer startPosition, TextPointer endPosition, IComDataObject data, out UnsafeNativeMethods.TS_TEXTCHANGE change) { int symbolsRemoved; int removeStartIndex; int startIndex; // Remove the existing range content. // See the comments on RemoveContent for an explanation of the // out params. startIndex = startPosition.Offset; RemoveContent(startPosition, endPosition, out symbolsRemoved, out removeStartIndex); Invariant.Assert(startIndex >= removeStartIndex); // Remember where we're actually going to do the insert. startIndex = startPosition.Offset; Invariant.Assert(startIndex >= removeStartIndex); // Do the insert. // The TS_TEXTCHANGE reflects on the insert, we have to update it // for any content we may have removed above. InsertEmbeddedAtPosition(startPosition, data, out change); // Update change for the remove content step above. change.start = removeStartIndex; change.oldEnd += symbolsRemoved; }
private void InsertEmbeddedAtPosition(TextPointer position, IComDataObject data, out UnsafeNativeMethods.TS_TEXTCHANGE change) { SecurityHelper.DemandUnmanagedCode(); ITextContainer container; // Get enhanced metafile handle from IOleDataObject. FORMATETC formatetc = new FORMATETC(); STGMEDIUM stgmedium = new STGMEDIUM(); formatetc.cfFormat = NativeMethods.CF_ENHMETAFILE; formatetc.ptd = IntPtr.Zero; formatetc.dwAspect = DVASPECT.DVASPECT_CONTENT; formatetc.lindex = -1; formatetc.tymed = TYMED.TYMED_ENHMF; stgmedium.tymed = TYMED.TYMED_ENHMF; data.GetData(ref formatetc, out stgmedium); if (stgmedium.unionmember == IntPtr.Zero) { throw new COMException(SR.Get(SRID.TextStore_BadObjectData), NativeMethods.E_INVALIDARG); } IntPtr hbitmap = SystemDrawingHelper.ConvertMetafileToHBitmap(stgmedium.unionmember); // create a InkInteropObject framework element. InkInteropObject inkobject = new InkInteropObject(data); inkobject.Source = Imaging.CreateBitmapSourceFromHBitmap(hbitmap, IntPtr.Zero, Int32Rect.Empty, null); position = InsertInkAtPosition(position, inkobject, out change); // Move the selection. container = this.TextContainer; TextSelection.SetCaretToPosition(position, LogicalDirection.Backward, /*allowStopAtLineEnd:*/false, /*allowStopNearSpace:*/false); }