本文整理汇总了C++中IRichEditOle::Release方法的典型用法代码示例。如果您正苦于以下问题:C++ IRichEditOle::Release方法的具体用法?C++ IRichEditOle::Release怎么用?C++ IRichEditOle::Release使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IRichEditOle
的用法示例。
在下文中一共展示了IRichEditOle::Release方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SetRichCallback
bool SetRichCallback(HWND hwnd, MCONTACT hContact, bool subany, bool subnew)
{
RichEditData* rdt = g_RichEditList.find((RichEditData*)&hwnd);
if (rdt == NULL) {
IRichEditOle* RichEditOle;
if (SendMessage(hwnd, EM_GETOLEINTERFACE, 0, (LPARAM)&RichEditOle) == 0)
return false;
RichEditOle->Release();
rdt = new RichEditData;
rdt->hwnd = hwnd;
rdt->hContact = hContact;
rdt->inputarea = (GetWindowLongPtr(hwnd, GWL_STYLE) & ES_READONLY) == 0;
rdt->dontReplace = false;
rdt->tipActive = -1;
rdt->hToolTip = NULL;
g_RichEditList.insert(rdt);
if (subnew)
mir_subclassWindow(hwnd, RichEditSubclass);
}
else {
if (hContact && !rdt->hContact)
rdt->hContact = hContact;
if (subany)
mir_subclassWindow(hwnd, RichEditSubclass);
}
return true;
}
示例2: bbCodeImageFunc
static bool bbCodeImageFunc(IFormattedTextDraw *ftd, CHARRANGE range, TCHAR *txt, DWORD cookie)
{
ITextServices *ts = ftd->getTextService();
ITextDocument *td = ftd->getTextDocument();
long cnt;
LRESULT lResult;
/*
TEXTRANGE trg;
trg.chrg = range;
trg.lpstrText = new TCHAR[trg.chrg.cpMax - trg.chrg.cpMin + 1];
ts->TxSendMessage(EM_GETTEXTRANGE, 0, (LPARAM)&trg, &lResult);
MessageBox(0, txt, trg.lpstrText, MB_OK);
*/
ts->TxSendMessage(EM_SETSEL, range.cpMin, range.cpMax, &lResult);
IRichEditOle* RichEditOle;
ts->TxSendMessage(EM_GETOLEINTERFACE, 0, (LPARAM)&RichEditOle, &lResult);
td->Freeze(&cnt);
// HDC emfdc = CreateEnhMetaFile(NULL, NULL, NULL, _T("icon"));
// DrawIconEx(emfdc, 0, 0, (HICON)_ttol(txt), 16, 16, 0, NULL, DI_NORMAL);
// InsertBitmap(RichEditOle, CloseEnhMetaFile(emfdc));
#ifdef _WIN64
bool res = InsertBitmap(RichEditOle, CacheIconToEmf((HICON)_tstoi64(txt)));
#else
bool res = InsertBitmap(RichEditOle, CacheIconToEmf((HICON)_ttoi(txt)));
#endif
td->Unfreeze(&cnt);
RichEditOle->Release();
return res;
}
示例3: RichEdit_GetImageOle
BOOL RichEdit_GetImageOle(HWND hWnd, POINT pt, IImageOle** pImageOle)
{
IRichEditOle * pRichEditOle;
REOBJECT reobject;
HRESULT hr;
BOOL bRet = FALSE;
if (NULL == pImageOle)
return FALSE;
*pImageOle = NULL;
pRichEditOle = RichEdit_GetOleInterface(hWnd);
if (NULL == pRichEditOle)
return FALSE;
int nCount = pRichEditOle->GetObjectCount();
for (int i = 0; i < nCount; i++)
{
memset(&reobject, 0, sizeof(REOBJECT));
reobject.cbStruct = sizeof(REOBJECT);
hr = pRichEditOle->GetObject(i, &reobject, REO_GETOBJ_POLEOBJ);
if (S_OK == hr)
{
if (reobject.poleobj != NULL)
{
if (CLSID_ImageOle == reobject.clsid)
{
IImageOle * pImageOle2 = NULL;
hr = reobject.poleobj->QueryInterface(__uuidof(IImageOle), (void**)&pImageOle2);
reobject.poleobj->Release();
if (SUCCEEDED(hr))
{
RECT rcObject = {0};
hr = pImageOle2->GetObjectRect(&rcObject);
if (SUCCEEDED(hr))
{
if (::PtInRect(&rcObject, pt))
{
*pImageOle = pImageOle2;
bRet = TRUE;
break;
}
}
pImageOle2->Release();
}
}
else
{
reobject.poleobj->Release();
}
}
}
}
pRichEditOle->Release();
return bRet;
}
示例4: RichEdit_GetCustomPicCount
int RichEdit_GetCustomPicCount(HWND hWnd)
{
IRichEditOle * pRichEditOle;
REOBJECT reobject;
HRESULT hr;
pRichEditOle = RichEdit_GetOleInterface(hWnd);
if (NULL == pRichEditOle)
return 0;
int nCustomPicCnt = 0;
for (int i = 0; i < pRichEditOle->GetObjectCount(); i++)
{
memset(&reobject, 0, sizeof(REOBJECT));
reobject.cbStruct = sizeof(REOBJECT);
hr = pRichEditOle->GetObject(i, &reobject, REO_GETOBJ_POLEOBJ);
if (S_OK == hr)
{
if (reobject.poleobj != NULL)
{
if (CLSID_ImageOle == reobject.clsid)
{
IImageOle * pImageOle2 = NULL;
hr = reobject.poleobj->QueryInterface(__uuidof(IImageOle), (void**)&pImageOle2);
reobject.poleobj->Release();
if (SUCCEEDED(hr))
{
LONG lFaceId = -1, lFaceIndex = -1;
pImageOle2->GetFaceId(&lFaceId);
pImageOle2->GetFaceIndex(&lFaceIndex);
if (-1 == lFaceId && -1 == lFaceIndex)
nCustomPicCnt++;
pImageOle2->Release();
}
}
else
{
reobject.poleobj->Release();
}
}
}
}
pRichEditOle->Release();
return nCustomPicCnt;
}
示例5: bbCodeImageFunc
static bool bbCodeImageFunc(IFormattedTextDraw *ftd, CHARRANGE range, TCHAR *txt, DWORD)
{
ITextServices *ts = ftd->getTextService();
ITextDocument *td = ftd->getTextDocument();
long cnt;
LRESULT lResult;
ts->TxSendMessage(EM_SETSEL, range.cpMin, range.cpMax, &lResult);
IRichEditOle* RichEditOle;
ts->TxSendMessage(EM_GETOLEINTERFACE, 0, (LPARAM)&RichEditOle, &lResult);
td->Freeze(&cnt);
#ifdef _WIN64
bool res = InsertBitmap(RichEditOle, CacheIconToEmf((HICON)_tstoi64(txt)));
#else
bool res = InsertBitmap(RichEditOle, CacheIconToEmf((HICON)_ttoi(txt)));
#endif
td->Unfreeze(&cnt);
RichEditOle->Release();
return res;
}
示例6: GetDrawingProp
void GetDrawingProp(void)
{
if (m_hwnd == NULL) return;
IRichEditOle* RichEditOle;
if (SendMessage(m_hwnd, EM_GETOLEINTERFACE, 0, (LPARAM)&RichEditOle) == 0)
return;
REOBJECT reObj = {0};
reObj.cbStruct = sizeof(REOBJECT);
HRESULT hr = RichEditOle->GetObject(m_lastObjNum, &reObj, REO_GETOBJ_NO_INTERFACES);
if (hr == S_OK && reObj.dwUser == (DWORD)(ISmileyBase*)this && reObj.clsid == CLSID_NULL)
m_richFlags = reObj.dwFlags;
else {
long objectCount = RichEditOle->GetObjectCount();
for (long i = objectCount; i--; ) {
HRESULT hr = RichEditOle->GetObject(i, &reObj, REO_GETOBJ_NO_INTERFACES);
if (FAILED(hr)) continue;
if (reObj.dwUser == (DWORD)(ISmileyBase*)this && reObj.clsid == CLSID_NULL) {
m_lastObjNum = i;
m_richFlags = reObj.dwFlags;
break;
}
}
}
RichEditOle->Release();
if ((m_richFlags & REO_SELECTED) == 0) {
CHARRANGE sel;
SendMessage(m_hwnd, EM_EXGETSEL, 0, (LPARAM)&sel);
if (reObj.cp >= sel.cpMin && reObj.cp < sel.cpMax)
m_richFlags |= REO_INVERTEDSELECT;
else
m_richFlags &= ~REO_INVERTEDSELECT;
}
}
示例7: SetPosition
static void SetPosition(HWND hwnd)
{
IRichEditOle* RichEditOle;
if (SendMessage(hwnd, EM_GETOLEINTERFACE, 0, (LPARAM)&RichEditOle) == 0)
return;
ITextDocument* TextDocument;
if (RichEditOle->QueryInterface(IID_ITextDocument, (void**)&TextDocument) != S_OK) {
RichEditOle->Release();
return;
}
// retrieve text range
ITextRange* TextRange;
if (TextDocument->Range(0, 0, &TextRange) != S_OK) {
TextDocument->Release();
RichEditOle->Release();
return;
}
TextDocument->Release();
int objectCount = RichEditOle->GetObjectCount();
for (int i = objectCount - 1; i >= 0; i--) {
REOBJECT reObj = {0};
reObj.cbStruct = sizeof(REOBJECT);
HRESULT hr = RichEditOle->GetObject(i, &reObj, REO_GETOBJ_POLEOBJ);
if (FAILED(hr)) continue;
ISmileyBase *igsc = NULL;
if (reObj.clsid == CLSID_NULL)
reObj.poleobj->QueryInterface(IID_ISmileyAddSmiley, (void**) &igsc);
reObj.poleobj->Release();
if (igsc == NULL) continue;
TextRange->SetRange(reObj.cp, reObj.cp);
BOOL res;
POINT pt;
RECT rect;
hr = TextRange->GetPoint(tomStart | TA_BOTTOM | TA_LEFT, &pt.x, &pt.y);
if (hr == S_OK) {
res = ScreenToClient(hwnd, &pt);
rect.bottom = pt.y;
rect.left = pt.x;
}
else rect.bottom = -1;
hr = TextRange->GetPoint(tomStart | TA_TOP | TA_LEFT, &pt.x, &pt.y);
if (hr == S_OK) {
res = ScreenToClient(hwnd, &pt);
rect.top = pt.y;
rect.left = pt.x;
}
else rect.top = -1;
igsc->SetPosition(hwnd, &rect);
igsc->Release();
}
TextRange->Release();
RichEditOle->Release();
}
示例8: OnPreSendMsg
//.........这里部分代码省略.........
m_pRecordView->GetRichEditCtrl().SetSel(-2, -1);
m_pRecordView->GetRichEditCtrl().SetWordCharFormat(m_sendUserCharFormat);
m_pRecordView->GetRichEditCtrl().ReplaceSel(ch, FALSE); //输入用户发送时间
EDITSTREAM es;
es.dwCookie = (DWORD_PTR)&memFile;
es.pfnCallback = RichEditStreamInCallback;
m_pRecordView->GetRichEditCtrl().SetSel(-2, -1);
m_pRecordView->GetRichEditCtrl().StreamIn(SF_RTF | SFF_SELECTION, es);
//为了解决添加SFF_SELECTION后,自动滚动不显示的问题
if(!(GetAsyncKeyState(VK_LBUTTON) && 0x8000)) ////鼠标没有按下
m_pRecordView->GetRichEditCtrl().PostMessage(WM_VSCROLL, MAKELONG(SB_BOTTOM, 0), 0);;
m_pRecordView->GetRichEditCtrl().SetReadOnly(TRUE);
}
TRACE(_T("写入上面View 用时:%d ms 时间:%d\n"), clock() - clr0, clock()); clr0 = clock();
}
break;
case 1:
{
CFileDialog filedlg(TRUE, NULL, NULL, OFN_PATHMUSTEXIST | OFN_READONLY, _T("All Files (*.*)|*.*||"), this);
if (IDOK == filedlg.DoModal())
{
CString filePath = filedlg.GetPathName();
SendFileOrDic(filePath);
}
InvalidateRect(m_sendFileRc, FALSE);
}
break;
case 2:
{
TCHAR szPath[MAX_PATH] ={ 0 }; //存放选择的目录路径
BROWSEINFO bi;
bi.hwndOwner = m_hWnd;
bi.pidlRoot = NULL;
bi.pszDisplayName = szPath;
bi.lpszTitle = _T("请选择需要导出的目录:");
bi.ulFlags = BIF_RETURNONLYFSDIRS;
bi.lpfn = BrowseCallbackProc; //设置CALLBACK函数
bi.iImage = 0;
bi.lParam = long(m_oldDic.GetBuffer());
//弹出选择目录对话框
LPITEMIDLIST lp = SHBrowseForFolder(&bi);
if (lp && SHGetPathFromIDList(lp, szPath))
{
m_oldDic = szPath;
SendFileOrDic(szPath);
}
InvalidateRect(m_sendDicRc, FALSE);
}
break;
case 3:
{
CString sFilter = _T("All image file|*.bmp;*.jpg;|Bitmap Files (*.bmp)|*.bmp|JPEG Files (*.jpg)|*.jpg|");
//CString sFilter = _T("All image file|*.bmp;*.jpg;*.gif|Bitmap Files (*.bmp)|*.bmp|JPEG Files (*.jpg)|*.jpg|GIF Files (*.gif)|*.gif|");
CFileDialog filedlg(TRUE, NULL, NULL, OFN_PATHMUSTEXIST | OFN_READONLY, sFilter, this);
if (IDOK == filedlg.DoModal())
{
CTapBitmap bmp;
if (bmp.Load(filedlg.GetPathName()) == FALSE)
{
AfxMessageBox(_T("Could not load image."));
return TRUE;
}
CEnBitmap enBitmap;
CBitmap Bitmap;
if (enBitmap.Attach(bmp.GetBMP(), 0))
{
Bitmap.DeleteObject();
Bitmap.Attach(enBitmap.Detach());
IRichEditOle *pRichEditOle;
pRichEditOle = m_pMsgEdit->GetRichEditCtrl().GetIRichEditOle();
HBITMAP hBitmap = (HBITMAP)Bitmap;
if (hBitmap)
{
ImageDataObject::InsertBitmap(pRichEditOle, hBitmap);
}
pRichEditOle->Release();
}
}
InvalidateRect(m_sendPictureRc, FALSE);
}
break;
}
return TRUE;
}
示例9: AboutProc
//.........这里部分代码省略.........
// the text in the control (bug #DPEV-6JUJSQ)
hText = GetDlgItem(hDlg, textScrollID);
SendMessageA(hText,WM_SETTEXT,0,(LPARAM)"");
SendMessageA(hText,setTextMsg,setTextParam,(LPARAM)aboutText);
ShowWindow(hText, SW_SHOWNORMAL);
}
// Add full SDK name to the RichEdit control by replacing <sdk_name> tag with the
// name defined in SdkProductInfo.h. Note that decision between MIDP and C++ SDK
// product names is made using CWinMenubar iMidpSdk member.
static const TCHAR keywordHeading[] = TEXT("<sdk_name>");
static const UINT keywordHeadingLen = COUNT(keywordHeading)-1;
FINDTEXT findHeading;
ZeroMemory(&findHeading, sizeof(findHeading));
findHeading.chrg.cpMax = -1;
findHeading.lpstrText = (LPTSTR)keywordHeading;
// Select whole content
SendMessage(hText, EM_SETSEL, 0, 0);
// Find from selection
int pos = SendMessage(hText,EM_FINDTEXT, FR_MATCHCASE|FR_DOWN,
(LPARAM)&findHeading);
if (pos >= 0) {
// Sdk name tag found
IRichEditOle* re = NULL;
SendMessage(hText, EM_GETOLEINTERFACE, 0, (LPARAM)&re);
if (re) {
// Select SDK name tag and replace it with the full SDK name
SendMessage(hText, EM_SETSEL, pos, pos+keywordHeadingLen);
if(menubar->iMidpSDK)
SendMessage(hText, EM_REPLACESEL, true, (LPARAM)TEXT(SDK_FULL_PRODUCT_NAME_MIDP));
else
SendMessage(hText, EM_REPLACESEL, true, (LPARAM)TEXT(SDK_FULL_PRODUCT_NAME_CPP));
re->Release();
}
}
if (hBitmap)
{
static const TCHAR keyword[] = TEXT("<java logo>");
static const UINT keywordLen = COUNT(keyword)-1;
FINDTEXT find;
ZeroMemory(&find, sizeof(find));
find.chrg.cpMax = -1;
find.lpstrText = (LPTSTR)keyword;
SendMessage(hText, EM_SETSEL, 0, 0);
int pos = SendMessage(hText,EM_FINDTEXT, FR_MATCHCASE|FR_DOWN,
(LPARAM)&find);
if (pos >= 0) {
IRichEditOle* re = NULL;
SendMessage(hText, EM_GETOLEINTERFACE, 0, (LPARAM)&re);
if (re) {
CImageDataObject* bmp = new CImageDataObject(hBitmap);
if (bmp) {
SendMessage(hText,EM_SETSEL,pos,pos+keywordLen);
bmp->Insert(re);
bmp->Release();
}
re->Release();
}
}
}
Free(aboutText);
}
示例10: RichEdit_GetText
// 获取文本
void RichEdit_GetText(ITextServices * pTextServices, tstring& strText)
{
REOBJECT reobject;
LONG nFaceId, nPos = 0;
tstring strOrgText, strTemp;
IRichEditOle * pRichEditOle = RichEdit_GetOleInterface(pTextServices);
if (NULL == pRichEditOle)
return;
CHARRANGE chrg = {0, RichEdit_GetWindowTextLength(pTextServices)};
RichEdit_GetTextRange(pTextServices, &chrg, strOrgText);
for (LONG i = 0; i < (int)strOrgText.size(); i++)
{
memset(&reobject, 0, sizeof(REOBJECT));
reobject.cbStruct = sizeof(REOBJECT);
reobject.cp = i;
HRESULT hr = pRichEditOle->GetObject(REO_IOB_USE_CP, &reobject, REO_GETOBJ_POLEOBJ);
if (SUCCEEDED(hr))
{
if (reobject.cp > 0 && reobject.cp > nPos)
{
strTemp = strOrgText.substr(nPos, reobject.cp-nPos);
Replace(strTemp, _T("/"), _T("//"));
strText += strTemp;
}
nPos = reobject.cp + 1;
if (NULL == reobject.poleobj)
continue;
if (CLSID_ImageOle == reobject.clsid)
{
IImageOle * pImageOle = NULL;
hr = reobject.poleobj->QueryInterface(__uuidof(IImageOle), (void**)&pImageOle);
if (SUCCEEDED(hr))
{
pImageOle->GetFaceId(&nFaceId);
if (nFaceId != -1)
{
TCHAR cBuf[32] = {0};
wsprintf(cBuf, _T("/f[\"%03d\"]"), nFaceId);
strText += cBuf;
}
else
{
strText += _T("/c[\"");
BSTR bstrFileName = NULL;
pImageOle->GetFileName(&bstrFileName);
strText += bstrFileName;
::SysFreeString(bstrFileName);
strText += _T("\"]");
}
pImageOle->Release();
}
}
reobject.poleobj->Release();
}
}
if (nPos < (int)strOrgText.size())
{
strTemp = strOrgText.substr(nPos);
Replace(strTemp, _T("/"), _T("//"));
strText += strTemp;
}
pRichEditOle->Release();
}
示例11: RichEdit_InsertFace
// 插入表情图片
BOOL RichEdit_InsertFace(ITextServices *pTextServices, ITextHost *pTextHost,
LPCTSTR lpszFileName, int nFaceId, int nFaceIndex,
COLORREF clrBg, BOOL bAutoScale, int nReservedWidth)
{
BSTR bstrFileName = NULL;
IRichEditOle * pRichEditOle = NULL;
IOleClientSite *pOleClientSite = NULL;
IImageOle* pImageOle = NULL;
IOleObject *pOleObject = NULL;
REOBJECT reobject = {0};
HRESULT hr = E_FAIL;
if (NULL == pTextServices || NULL == pTextHost ||
NULL == lpszFileName || NULL == *lpszFileName)
return FALSE;
TCHAR cProtocol[16] = {0};
_tcsncpy(cProtocol, lpszFileName, 7);
if ((_tcsicmp(cProtocol, _T("http://")) != 0) && ::GetFileAttributes(lpszFileName) == 0xFFFFFFFF)
return FALSE;
bstrFileName = ::SysAllocString(lpszFileName);
if (NULL == bstrFileName)
return FALSE;
pTextServices->TxSendMessage(EM_GETOLEINTERFACE, 0, (LPARAM)&pRichEditOle, NULL);
if (NULL == pRichEditOle)
goto Ret0;
hr = ::CoCreateInstance(CLSID_ImageOle, NULL,
CLSCTX_INPROC_SERVER, IID_IImageOle, (void**)&pImageOle);
if (FAILED(hr))
goto Ret0;
hr = pImageOle->QueryInterface(IID_IOleObject, (void **)&pOleObject);
if (FAILED(hr))
goto Ret0;
pRichEditOle->GetClientSite(&pOleClientSite);
if (NULL == pOleClientSite)
goto Ret0;
pOleObject->SetClientSite(pOleClientSite);
pImageOle->SetTextServices(pTextServices);
pImageOle->SetTextHost(pTextHost);
pImageOle->SetFaceId(nFaceId);
pImageOle->SetFaceIndex(nFaceIndex);
pImageOle->SetBgColor(clrBg);
pImageOle->SetAutoScale(bAutoScale, nReservedWidth);
pImageOle->LoadFromFile(bstrFileName);
hr = ::OleSetContainedObject(pOleObject, TRUE);
reobject.cbStruct = sizeof(REOBJECT);
reobject.clsid = CLSID_ImageOle;
reobject.cp = REO_CP_SELECTION;
reobject.dvaspect = DVASPECT_CONTENT;
reobject.dwFlags = REO_BELOWBASELINE;
reobject.poleobj = pOleObject;
reobject.polesite = pOleClientSite;
reobject.dwUser = 0;
hr = pRichEditOle->InsertObject(&reobject);
Ret0:
if (pOleObject != NULL)
pOleObject->Release();
if (pImageOle != NULL)
pImageOle->Release();
if (pOleClientSite != NULL)
pOleClientSite->Release();
if (pRichEditOle != NULL)
pRichEditOle->Release();
if (bstrFileName != NULL)
::SysFreeString(bstrFileName);
return SUCCEEDED(hr);
}