Insert a picture in Richedit

xiaoxiao2021-03-06  45

How to insert a picture void __fastcall insertbmptorich (trichmedit * re, widestring wstrbmpfile) {IricHeditole * Richole; sendMessage (Re-> Handle, EM_GETOLINTERFACE, 0, INT (& Richole);

IlockBytes * flockbytes; createilockbytesonhglobal (0, 1, & flockbytes);

IStorage * fStorage; strcreatedocfileonilockbytes (flockbytes, stgm_share_exclusive | str_create | strm_readwrite, 0, & fstorage);

TFormatetc.cfformat = 0; formatetc.ptd = null; formatetc.dwaspect = dvaspect_content; formatetc.lindex = -1; formatetc.tymed = TYMED_NULL;

IoleObject * fole; olecreatefromfile (guid_null, wstrbmpfile, :: IID_IOLOBJECT, 0, & Formatetc, null, fstorage, (void **) & fole); OleSetContainedObject (fole, true);

REOBJECT ReObject; ZeroMemory (& ReObject, sizeof (REOBJECT)); ReObject.cbStruct = sizeof (REOBJECT); CLSID xt; FOle-> GetUserClassID (& xt); ReObject.clsid = xt; ReObject.cp = REO_CP_SELECTION; ReObject.dvaspect = DVASPECT_CONTENT Reobject.dwflags = Reo_Static | Reo_belowbaseline; reobject.dwuser = 0; Reobject.poleobj = fole;

IoleClientSite * fclientSite; Richole-> getClientSite (& fclientSite); Reobject.polesite = fClientSite; Reobject.pstg = fStorage; Reobject.Sizel.cx = 0; Reobject.Sizel.cy = 0;

Richole-> InsertObject (& Reobject);

// Call method:

INSERTBMPTORICH (Richedit1, WideString ("D: //Source//linux_image//header-projects.png"));

// or use RichView

转载请注明原文地址:https://www.9cbs.com/read-115902.html

New Post(0)