Exemplo n.º 1
1
		public uint GetData(ref FORMATETC pFormatetc, ref STGMEDIUM pMedium)
		{
			IntPtr hDst = mBitmap.GetHbitmap();

			pMedium.tymed = (int)TYMED.TYMED_GDI;
			pMedium.unionmember = hDst;
			pMedium.pUnkForRelease = IntPtr.Zero;

			return (uint)S_OK;
		}
Exemplo n.º 2
0
		public uint SetData(ref FORMATETC a, ref STGMEDIUM b, bool fRelease)
		{
			//mpFormatetc = pFormatectIn;
			//mpmedium = pmedium;
		
			Trace.WriteLine("SetData");

			return (int)S_OK;
		}
Exemplo n.º 3
0
		public uint GetCanonicalFormatEtc(ref FORMATETC pFormatetcIn, out FORMATETC pFormatetcOut)
		{
			Trace.WriteLine("GetCanonicalFormatEtc");

			pFormatetcOut = new FORMATETC();

			return (uint)E_NOTIMPL;
		}
Exemplo n.º 4
0
		public uint QueryGetData(ref FORMATETC pFormatetc)
		{
			Trace.WriteLine("QueryGetData");

			return (uint)E_NOTIMPL;
		}
Exemplo n.º 5
0
		public uint GetDataHere(ref FORMATETC pFormatetc, out STGMEDIUM pMedium)
		{
			Trace.WriteLine("GetDataHere");

			pMedium = new STGMEDIUM();

			return (uint)E_NOTIMPL;
		}
Exemplo n.º 6
0
			public bool InsertImageFromFile(string strFilename)
			{
				//-----------------------
				ILockBytes pLockBytes;
				CreateILockBytesOnHGlobal(IntPtr.Zero, true, out pLockBytes);

				IStorage pStorage;
				StgCreateDocfileOnILockBytes(pLockBytes, (uint)(STGM.STGM_SHARE_EXCLUSIVE|STGM.STGM_CREATE|STGM.STGM_READWRITE), 0, out pStorage);
				
				IOleClientSite pOleClientSite;
				this.IRichEditOle.GetClientSite(out pOleClientSite);
				//-----------------------

				
				//-----------------------
				FORMATETC formatEtc = new FORMATETC();

				formatEtc.cfFormat = 0;
				formatEtc.ptd = IntPtr.Zero;
				formatEtc.dwAspect = DVASPECT.DVASPECT_CONTENT;
				formatEtc.lindex = -1;
				formatEtc.tymed = TYMED.TYMED_NULL;
				
				Guid IID_IOleObject = new Guid("{00000112-0000-0000-C000-000000000046}");
				Guid CLSID_NULL = new Guid("{00000000-0000-0000-0000-000000000000}");
				
				object pOleObjectOut;

				// I don't sure, but it appears that this function only loads from bitmap
				// You can also try OleCreateFromData, OleLoadPictureIndirect, etc.
				int hr = OleCreateFromFile(ref CLSID_NULL, strFilename, ref IID_IOleObject, (uint)OLERENDER.OLERENDER_DRAW, ref formatEtc, pOleClientSite, pStorage, out pOleObjectOut);

				if (pOleObjectOut == null)
				{
					Marshal.ReleaseComObject(pLockBytes);
					Marshal.ReleaseComObject(pOleClientSite);
					Marshal.ReleaseComObject(pStorage);

					return false;
				}

				IOleObject pOleObject = (IOleObject)pOleObjectOut;
				//-----------------------


				//-----------------------
				Guid guid = new Guid();

				//guid = Marshal.GenerateGuidForType(pOleObject.GetType());
				pOleObject.GetUserClassID(ref guid);
				//-----------------------

				//-----------------------
				OleSetContainedObject(pOleObject, true);

				REOBJECT reoObject = new REOBJECT();

				reoObject.cp = this._richEdit.TextLength;

				reoObject.clsid = guid;
				reoObject.pstg = pStorage;
				reoObject.poleobj = Marshal.GetIUnknownForObject(pOleObject);
				reoObject.polesite = pOleClientSite;
				reoObject.dvAspect = (uint)(DVASPECT.DVASPECT_CONTENT);
				reoObject.dwFlags = (uint)(REOOBJECTFLAGS.REO_BELOWBASELINE);
				reoObject.dwUser = 0;

				this.IRichEditOle.InsertObject(reoObject);
				//-----------------------

				//-----------------------
				Marshal.ReleaseComObject(pLockBytes);
				Marshal.ReleaseComObject(pOleClientSite);
				Marshal.ReleaseComObject(pStorage);
				Marshal.ReleaseComObject(pOleObject);
				//-----------------------

				return true;
			}
Exemplo n.º 7
0
		static extern int OleCreateLinkFromData([MarshalAs(UnmanagedType.Interface)]IDataObject pSrcDataObj,
			[In] ref Guid riid, uint renderopt, ref FORMATETC pFormatEtc,
			IOleClientSite pClientSite, IStorage pStg,
			[MarshalAs(UnmanagedType.IUnknown)] out object ppvObj);
Exemplo n.º 8
0
		static extern int OleCreateFromFile([In] ref Guid rclsid,
			[MarshalAs(UnmanagedType.LPWStr)] string lpszFileName, [In] ref Guid riid,
			uint renderopt, ref FORMATETC pFormatEtc, IOleClientSite pClientSite,
			IStorage pStg, [MarshalAs(UnmanagedType.IUnknown)] out object ppvObj);
Exemplo n.º 9
0
		public myDataObject()
		{
			mBitmap = new Bitmap(16, 16);
			mpFormatetc = new FORMATETC();
		}
Exemplo n.º 10
0
		public uint DAdvise(ref FORMATETC a, int advf, IAdviseSink pAdvSink, out uint pdwConnection)
		{
			Trace.WriteLine("DAdvise");

			pdwConnection = 0;

			return (uint)E_NOTIMPL;
		}