急!!如何在richedit中插入gif格式的图片?以及在richedit中实现象qq中接收文件的超链接!!!!!!!!!

feior 2004-08-21 10:59:47
如何在richedit中插入gif格式的图片?
就象在qq中插入表情!

以及在richedit中实现象qq中接收文件的超链接?

哪位大哥能帮帮我啊???
...全文
1454 点赞 收藏 69
写回复
69 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复
HenryGo 2005-07-27
麻烦发一份代码给我啦
henrywong@sogou.com
谢谢您啦
回复
SmallBigCat 2004-12-15
To: hanbig(),inwindfighter(浪迹天涯)

发一份代码给我,谢谢:ligs2001@163.com
回复
shishulv 2004-12-15
我也想要一份,有的帮忙发一份哦,谢谢
tong2003@hotmail.com
回复
deergao 2004-12-14
To: hanbig()
我也想要一份,谢谢!
gao-y01@mails.tsinghua.edu.cn
回复
liceai 2004-12-14
To: hanbig()

可以也给我一份吗,非常感谢!

lee_capitel@msn.com
回复
onestation 2004-12-07
看看这个!
http://blog.csdn.net/dtianx/archive/2004/11/17/184949.aspx
回复
gungun2000 2004-12-07
hanbig()
Crazyrebel
你们好!能给我发一份代码吗?不胜感激!

molly.liu@pulseasia.com
回复
gungun2000 2004-12-07
onestation
解决问题了,太感谢了!:)
回复
onestation 2004-12-07
// MyRichEdit.cpp : implementation file
//

#include "stdafx.h"
#include "ZJP.h"
#include "MyRichEdit.h"
#include "Richole.h"

#import "E:\\Program files\\tencent\\qq\\ImageOle.dll" named_guids

#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif

/////////////////////////////////////////////////////////////////////////////
// CMyRichEdit

CMyRichEdit::CMyRichEdit()
{
}

CMyRichEdit::~CMyRichEdit()
{
}


BEGIN_MESSAGE_MAP(CMyRichEdit, CRichEditCtrl)
//{{AFX_MSG_MAP(CMyRichEdit)
// NOTE - the ClassWizard will add and remove mapping macros here.
//}}AFX_MSG_MAP
END_MESSAGE_MAP()


/////////////////////////////////////////////////////////////////////////////
// CMyRichEdit message handlers

void CMyRichEdit::InsertGraphics(CString strPicPath)
{
LPLOCKBYTES lpLockBytes = NULL;
SCODE sc;
HRESULT hr;
//print to RichEdit' s IClientSite
LPOLECLIENTSITE m_lpClientSite;
//A smart point to IAnimator
ImageOleLib::IGifAnimatorPtr m_lpAnimator;
//ptr 2 storage
LPSTORAGE m_lpStorage;
//the object 2 b insert 2
LPOLEOBJECT m_lpObject;
//Create lockbytes
sc = ::CreateILockBytesOnHGlobal(NULL, TRUE, &lpLockBytes);
if (sc != S_OK)
AfxThrowOleException(sc);
ASSERT(lpLockBytes != NULL);
//use lockbytes to create storage
sc = ::StgCreateDocfileOnILockBytes(lpLockBytes,
STGM_SHARE_EXCLUSIVE|STGM_CREATE|STGM_READWRITE, 0, &m_lpStorage);
if (sc != S_OK)
{
VERIFY(lpLockBytes->Release() == 0);
lpLockBytes = NULL;
AfxThrowOleException(sc);
}
ASSERT(m_lpStorage != NULL);
//get the ClientSite of the very RichEditCtrl
GetIRichEditOle()->GetClientSite(&m_lpClientSite);
ASSERT(m_lpClientSite != NULL);
try
{
//Initlize COM interface

hr = ::CoInitialize(NULL) ;//( NULL, COINIT_APARTMENTTHREADED );
if( FAILED(hr) )
_com_issue_error(hr);

//Get GifAnimator object
//here, I used a smart point, so I do not need to free it
hr = m_lpAnimator.CreateInstance(ImageOleLib::CLSID_GifAnimator);
if( FAILED(hr) )
_com_issue_error(hr);
//COM operation need BSTR, so get a BSTR
BSTR path = strPicPath.AllocSysString();

//Load the gif
hr = m_lpAnimator->LoadFromFile(path);
if( FAILED(hr) )
_com_issue_error(hr);

TRACE0( m_lpAnimator->GetFilePath() );

//get the IOleObject
hr = m_lpAnimator.QueryInterface(IID_IOleObject, (void**)&m_lpObject);
if( FAILED(hr) )
_com_issue_error(hr);

//Set it 2 b inserted
OleSetContainedObject(m_lpObject, TRUE);

//2 insert in 2 richedit, you need a struct of REOBJECT
REOBJECT reobject;
ZeroMemory(&reobject, sizeof(REOBJECT));

reobject.cbStruct = sizeof(REOBJECT);
CLSID clsid;
sc = m_lpObject->GetUserClassID(&clsid);
if (sc != S_OK)
AfxThrowOleException(sc);
//set clsid
reobject.clsid = clsid;
//can be selected
reobject.cp = REO_CP_SELECTION;
//content, but not static
reobject.dvaspect = DVASPECT_CONTENT;
//goes in the same line of text line
reobject.dwFlags = REO_BELOWBASELINE; //REO_RESIZABLE |
reobject.dwUser = 0;
//the very object
reobject.poleobj = m_lpObject;
//client site contain the object
reobject.polesite = m_lpClientSite;
//the storage
reobject.pstg = m_lpStorage;

SIZEL sizel;
sizel.cx = sizel.cy = 0;
reobject.sizel = sizel;
HWND hWndRT = this->m_hWnd;
//Sel all text
// ::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);
//Insert after the line of text
GetIRichEditOle()->InsertObject(&reobject);
::SendMessage(hWndRT, EM_SCROLLCARET, (WPARAM)0, (LPARAM)0);
VARIANT_BOOL ret;
//do frame changing
ret = m_lpAnimator->TriggerFrameChange();
//show it
m_lpObject->DoVerb(OLEIVERB_UIACTIVATE, NULL, m_lpClientSite, 0, m_hWnd, NULL);
m_lpObject->DoVerb(OLEIVERB_SHOW, NULL, m_lpClientSite, 0, m_hWnd, NULL);

//redraw the window to show animation
RedrawWindow();

if (m_lpClientSite)
{
m_lpClientSite->Release();
m_lpClientSite = NULL;
}
if (m_lpObject)
{
m_lpObject->Release();
m_lpObject = NULL;
}
if (m_lpStorage)
{
m_lpStorage->Release();
m_lpStorage = NULL;
}

SysFreeString(path);
}
catch( _com_error e )
{
AfxMessageBox(e.ErrorMessage());
::CoUninitialize();
}
}
回复
solomonx 2004-11-24
来晚了:(
hanbig():
可以也给我一份吗,非常感谢!
solomon_x@sina.com
回复
inwindfighter 2004-11-16
收到hanbig()的源码,非常感激!
回复
inwindfighter 2004-11-05
hanbig():

麻烦您给我发一段代码吧,谢了!
inwind78@yahoo.com.cn
回复
blackboxboyb 2004-10-12
现在我这边有几个问题:
希望大家讨论以下:
1,我们用的是qq的dll,如果机子上没装qq怎么办??自己包含??有没有什么版权问题啊??
2 现在只能从一个文件导入个gif?
3 现在只能insert 一个gif啊??怎么加入多个gif支持呢??
4 怎么对有字有gif的字符串解析??

希望 hanbig() Crazyrebel(隔世情人) 大家帮忙讨论!
回复
ywyw 2004-10-12
UP
回复
blackboxboyb 2004-10-12
收到hanbig()代码,非常感谢!
回复
blackboxboyb 2004-10-11
你们是用了qq的DLL??怎么用???
回复
blackboxboyb 2004-10-11
好帖,支持!
最近也在写richedit刚写完加入bitmap,,gif的还没有头绪!!
现在解析也没!
hanbig() 能不能把代码发给我??万分感谢!!!
zhu_teky@yahoo.com.cn
谢谢!
-----------------------------
回复
zuolihua 2004-09-08
不行啊,楼上的兄弟能给份代码吗....谢谢
回复
hanbig 2004-09-08
??
不是已经搞定?
回复
Crazyrebel 2004-09-08
头都大了,差点没成功。。。
回复
加载更多回复
相关推荐
发帖
界面
创建于2007-09-28

1.5w+

社区成员

VC/MFC 界面
申请成为版主
帖子事件
创建了帖子
2004-08-21 10:59
社区公告
暂无公告