public REOBJECT InsertOleObject(global::CJBasic.Widget.Internals.IOleObject oleObject, int index, int pos) { global::CJBasic.Widget.Internals.ILockBytes bytes; global::CJBasic.Widget.Internals.IStorage storage; global::CJBasic.Widget.Internals.IOleClientSite site; if (oleObject == null) { return(null); } global::CJBasic.Widget.Internals.NativeMethods.CreateILockBytesOnHGlobal(IntPtr.Zero, true, out bytes); global::CJBasic.Widget.Internals.NativeMethods.StgCreateDocfileOnILockBytes(bytes, 0x1012, 0, out storage); this.IRichEditOle.GetClientSite(out site); Guid pClsid = new Guid(); oleObject.GetUserClassID(ref pClsid); global::CJBasic.Widget.Internals.NativeMethods.OleSetContainedObject(oleObject, true); REOBJECT lpreobject = new REOBJECT(); lpreobject.posistion = pos; lpreobject.clsid = pClsid; lpreobject.pstg = storage; lpreobject.poleobj = Marshal.GetIUnknownForObject(oleObject); lpreobject.polesite = site; lpreobject.dvAspect = 1; lpreobject.dwFlags = 2; lpreobject.dwUser = (uint)index; this.IRichEditOle.InsertObject(lpreobject); Marshal.ReleaseComObject(bytes); Marshal.ReleaseComObject(site); Marshal.ReleaseComObject(storage); return(lpreobject); }
public bool InsertImageFromFile(string strFilename, int position) { global::CJBasic.Widget.Internals.ILockBytes bytes; global::CJBasic.Widget.Internals.IStorage storage; global::CJBasic.Widget.Internals.IOleClientSite site; object obj2; global::CJBasic.Widget.Internals.NativeMethods.CreateILockBytesOnHGlobal(IntPtr.Zero, true, out bytes); global::CJBasic.Widget.Internals.NativeMethods.StgCreateDocfileOnILockBytes(bytes, 0x1012, 0, out storage); this.IRichEditOle.GetClientSite(out site); FORMATETC pFormatEtc = new FORMATETC(); pFormatEtc.cfFormat = (CLIPFORMAT)0; pFormatEtc.ptd = IntPtr.Zero; pFormatEtc.dwAspect = DVASPECT.DVASPECT_CONTENT; pFormatEtc.lindex = -1; pFormatEtc.tymed = TYMED.TYMED_NULL; Guid riid = new Guid("{00000112-0000-0000-C000-000000000046}"); Guid rclsid = new Guid("{00000000-0000-0000-0000-000000000000}"); global::CJBasic.Widget.Internals.NativeMethods.OleCreateFromFile(ref rclsid, strFilename, ref riid, 1, ref pFormatEtc, site, storage, out obj2); if (obj2 == null) { Marshal.ReleaseComObject(bytes); Marshal.ReleaseComObject(site); Marshal.ReleaseComObject(storage); return(false); } global::CJBasic.Widget.Internals.IOleObject pUnk = (global::CJBasic.Widget.Internals.IOleObject)obj2; Guid pClsid = new Guid(); pUnk.GetUserClassID(ref pClsid); global::CJBasic.Widget.Internals.NativeMethods.OleSetContainedObject(pUnk, true); REOBJECT lpreobject = new REOBJECT(); lpreobject.posistion = position; lpreobject.clsid = pClsid; lpreobject.pstg = storage; lpreobject.poleobj = Marshal.GetIUnknownForObject(pUnk); lpreobject.polesite = site; lpreobject.dvAspect = 1; lpreobject.dwFlags = 2; lpreobject.dwUser = 0; this.IRichEditOle.InsertObject(lpreobject); Marshal.ReleaseComObject(bytes); Marshal.ReleaseComObject(site); Marshal.ReleaseComObject(storage); Marshal.ReleaseComObject(pUnk); return(true); }
public REOBJECT InsertOleObject(global::CJBasic.Widget.Internals.IOleObject oleObject, int index) { return(this.InsertOleObject(oleObject, index, this.agileRichTextBox.TextLength)); }