1 imageole.dll 导入imageole.dll
2 插入图片方法
void TForm5::InsertPicture(WideString strFilePath,TRichEdit *edit,int i)
{
//WideString strFilePath = ExtractFilePath(Application->ExeName)+"1.png";
//ShowMessage(strFilePath);
HWND hwndRichEdit = edit->Handle;
LPLOCKBYTES lpLockBytes = NULL;
SCODE sc;
HRESULT hr;
//print to RichEdit' s IClientSite
LPOLECLIENTSITE lpClientSite;
//A smart point to IAnimator
IGifAnimatorPtr lpAnimator;
//ptr 2 storage
LPSTORAGE lpStorage;
//the object 2 b insert 2
LPOLEOBJECT lpObject;
//Create lockbytes
sc = ::CreateILockBytesOnHGlobal(NULL, TRUE, &lpLockBytes);
if (sc != S_OK) RaiseLastOSError();
assert(lpLockBytes != NULL);
//use lockbytes to create storage
sc = ::StgCreateDocfileOnILockBytes(lpLockBytes,
STGM_SHARE_EXCLUSIVE|STGM_CREATE|STGM_READWRITE, 0, &lpStorage);
if(sc != S_OK)
{
lpLockBytes->Release();
lpLockBytes = NULL;
RaiseLastOSError();
}
assert(lpStorage != NULL);
//get the ClientSite of the very RichEditCtrl
TComInterface<IRichEditOle> pRichEditOle;
SendMessage(hwndRichEdit,EM_GETOLEINTERFACE,0,(LPARAM)&pRichEditOle);
if(!pRichEditOle) RaiseLastOSError();
pRichEditOle->GetClientSite(&lpClientSite);
assert(lpClientSite != NULL);
//I