hur.cn - 华软网

 热门搜索

向CRichEditCtrl中插入位图,位图下方总有标题,如何去除此标题?

  作者:未知    来源:网络    更新时间:2010/12/9
最近我向CRichEditCtrl中插入位图,可是位图下方总显示有资料题目,试了很久也不能去除,求教高手,如何去除此题目?


代码摸仿MSDN,以下:

         USES_CONVERSION;

         LPLOCKBYTES lpLockBytes = NULL;
SCODE sc;
//print to RichEdit' s IClientSite
LPOLECLIENTSITE lpClientSite;
//ptr 2 storage
LPSTORAGE lpStorage;
//the object 2 b insert 2
LPOLEOBJECT lpObject;
CLSID clsid = CLSID_NULL;
OLERENDER render = OLERENDER_DRAW;
CLIPFORMAT cfFormat = 0;
LPFORMATETC lpFormatEtc = NULL;

//SCODE sc;

sc = ::CreateILockBytesOnHGlobal(NULL, TRUE, &lpLockBytes);
if (sc != S_OK)
AfxThrowOleException(sc);
ASSERT(lpLockBytes != NULL);

sc = ::StgCreateDocfileOnILockBytes(lpLockBytes,
STGM_SHARE_EXCLUSIVE|STGM_CREATE|STGM_READWRITE, 0, &lpStorage);
if (sc != S_OK)
{
VERIFY(lpLockBytes->Release() == 0);
lpLockBytes = NULL;
AfxThrowOleException(sc);
}
ASSERT(lpStorage != NULL);

// fill in FORMATETC struct
FORMATETC formatEtc;
lpFormatEtc = &formatEtc;
lpFormatEtc->cfFormat = cfFormat;
lpFormatEtc->ptd = NULL;
lpFormatEtc->dwAspect = DVASPECT_CONTENT;
lpFormatEtc->lindex = -1;
lpFormatEtc->tymed = TYMED_NULL;

// attempt to create the object
GetIRichEditOle()->GetClientSite(&lpClientSite);

sc = ::OleCreateFromFile(clsid, T2COLE(strPicPath),        // strPicPath 指向Bitmap资料完整路径
IID_IUnknown, OLERENDER_DRAW, lpFormatEtc, lpClientSite, lpStorage,
(void**)&lpObject);
if (sc != S_OK)
AfxThrowOleException(sc);

// m_lpObject is currently an IUnknown, convert to IOleObject
if (lpObject != NULL)
{
LPUNKNOWN lpUnk = lpObject;
lpUnk->QueryInterface(IID_IOleObject, (void**)&lpObject);
lpUnk->Release();
if (lpObject == NULL)
AfxThrowOleException(E_OUTOFMEMORY);
}

// all items are "contained" -- this makes our reference to this object
//  weak -- which is needed for links to embedding silent update.
OleSetContainedObject(lpObject, TRUE);

REOBJECT reobject;
ZeroMemory(&reobject, sizeof(REOBJECT));
reobject.cbStruct = sizeof(REOBJECT);

//CLSID clsid;
sc = lpObject->GetUserClassID(&clsid);
if (sc != S_OK)
AfxThrowOleException(sc);

reobject.clsid = clsid;
reobject.cp = REO_CP_SELECTION;
reobject.dvaspect = DVASPECT_CONTENT;
reobject.dwFlags = REO_RESIZABLE | REO_BELOWBASELINE;
reobject.dwUser = 0;
reobject.poleobj = lpObject;

ASSERT(lpClientSite != NULL);
reobject.polesite = lpClientSite;

ASSERT(lpStorage != NULL);
reobject.pstg = lpStorage;

SIZEL sizel;
sizel.cx = sizel.cy = 0;
reobject.sizel = sizel;

HWND hWndRT = this->m_hWnd;
::SendMessage(hWndRT, EM_SETSEL, 0, -1);
DWORD dwStart, dwEnd;
::SendMessage(hWndRT, EM_GETSEL, (WPARAM)&dwStart, (LPARAM)&dwEnd);
::SendMessage(hWndRT, EM_SETSEL, dwEnd+1, dwEnd+1);

CString strCr = "\r\n";
this->ReplaceSel(strCr,TRUE); 
pREO->InsertObject(&reobject);
         ::SendMessage(hWndRT, EM_SCROLLCARET, (WPARAM)0, (LPARAM)0);

if (lpObject)
{
lpObject->Release();
lpObject = NULL;
}
if (lpStorage)
{
lpStorage->Release();
lpStorage = NULL;
}
if (lpClientSite)
{
lpClientSite->Release();
lpClientSite = NULL;
}

---华软 网友回答---
你的做法跟他人不一样。

http://www.vckbase.com/document/viewdoc/?id=1290

---华软网友回复---
我这代码是从微软官方网站搬过来的,只是作了极少许的修改. 运用上述代码总是插入位图的图标。我试了很屡次。不过我已找到时了解决措施。

http://en.pudn.com/downloads77/sourcecode/windows/control/edit/detail295600_en.html      
华软声明:本内容来自网络,如有侵犯您版权请来信指出,本站立即删除。