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

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

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

哪位大哥能帮帮我啊???
...全文
1507 69 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
69 条回复
切换为时间正序
请发表友善的回复…
发表回复
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
  • 打赏
  • 举报
回复
头都大了,差点没成功。。。
加载更多回复(49)

15,980

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 界面
社区管理员
  • 界面
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧