예제 #1
0
        public void InsertGIF(string Name, Image Data)
        {
            MyGIF gif = new MyGIF(Name, Data);

            gif.Box.Invalidate();
            this.gifPanel.Controls.Add(gif.Box);
            this.gifList.Add(gif);

            RichEditOle ole = new RichEditOle(this);

            ole.InsertControl(gif);


            this.Invalidate();
        }
예제 #2
0
        public string GetGIFInfo()
        {
            string   imageInfo = "";
            REOBJECT reObject  = new REOBJECT();

            for (int i = 0; i < this.richEditOle.GetObjectCount(); i++)
            {
                this.richEditOle.GetObject(i, reObject, GETOBJECTOPTIONS.REO_GETOBJ_ALL_INTERFACES);
                MyGIF gif = this.gifList.Find(p => p != null && p.Index == reObject.dwUser);
                if (gif != null)
                {
                    imageInfo += reObject.cp.ToString() + ":" + gif.Name + "|";
                }
            }
            return(imageInfo);
        }
예제 #3
0
            internal void InsertControl(MyGIF gif)
            {
                if (gif == null)
                {
                    return;
                }

                Guid guid = Marshal.GenerateGuidForType(gif.Box.GetType());

                ILockBytes lockBytes;

                CreateILockBytesOnHGlobal(IntPtr.Zero, true, out lockBytes);

                IStorage storage;

                StgCreateDocfileOnILockBytes(lockBytes, (uint)(STGM.STGM_SHARE_EXCLUSIVE | STGM.STGM_CREATE | STGM.STGM_READWRITE), 0, out storage);

                IOleClientSite oleClientSite;

                this.ole.GetClientSite(out oleClientSite);

                REOBJECT reObject = new REOBJECT()
                {
                    cp       = this.richTextBox.SelectionStart,
                    clsid    = guid,
                    pstg     = storage,
                    poleobj  = Marshal.GetIUnknownForObject(gif.Box),
                    polesite = oleClientSite,
                    dvAspect = (uint)(DVASPECT.DVASPECT_CONTENT),
                    dwFlags  = (uint)0x00000002,
                };

                try
                {
                    reObject.dwUser = gif.Index;
                }
                catch { }

                this.ole.InsertObject(reObject);

                Marshal.ReleaseComObject(lockBytes);
                Marshal.ReleaseComObject(oleClientSite);
                Marshal.ReleaseComObject(storage);
            }