请教在RichEdit里如何插入Flash文件并播放? ( 积分: 50 )

  • 主题发起人 主题发起人 Pau1
  • 开始时间 开始时间
P

Pau1

Unregistered / Unconfirmed
GUEST, unregistred user!
请教在RichEdit里如何插入Flash文件并播放?
 
请教在RichEdit里如何插入Flash文件并播放?
 
这个不太能实现吧,做在WebBrowser里面应该可以的。
 
用RxRichedit看看

RxRichEdit1.InsertObjectDialog;
插入ole对象,一定程序上可以满足你
 
使用微软的DHTML的Activate插间
 
chenybin:
请帮忙看看如下代码那里出问题了,根据阁下提供的插入GifAnimator改编,Flash对象是插入了,但却不能正常播放.

procedure RichEditAddFlash(FlashFile:string;Editor:TRxRichEdit);
type
tagSize = TSize;
var
FRTF: IRichEditOle;
FLockBytes: ILockBytes;
FStorage: ISTORAGE;
FClientSite: IOLECLIENTSITE;
m_lpObject: IOleObject;
m_lpFlash: TShockwaveFlash;
i_Flash: IShockwaveFlash;
reobject: TReObject;
clsid: TGUID;
sizel: tagSize;
dwStart, dwEnd: DWORD;
Rect: TRect;
SystemDir:Pchar;
AppDir:string;
begin
try
if CreateILockBytesOnHGlobal(0, True, FLockBytes) <> S_OK then
begin
showmessage('Error to create Global Heap');
exit;
end;
//建立一个混合文档存取对象
if StgCreateDocfileOnILockBytes(FLockBytes, STGM_SHARE_EXCLUSIVE or STGM_CREATE or STGM_READWRITE, 0, FStorage) <> S_OK then
begin
showmessage('Error to create storage');
exit;
end;
//取得RichEdit的接口
Sendmessage(Editor.handle, EM_GETOLEINTERFACE, 0, LongInt(@FRTF));

if FRTF.GetClientSite(FClientSite) <> S_OK then
begin
showmessage('Error to get ClentSite');
exit;
end;
CoInitializeEx(nil, COINIT_APARTMENTTHREADED);
m_lpFlash:= TShockwaveFlash.Create(Application);
i_Flash:= m_lpFlash.ControlInterface;
i_Flash.LoadMovie(0,FlashFile);
i_Flash.QueryInterface(IID_IOleObject, m_lpObject);
OleSetContainedObject(m_lpObject, True);
FillChar(reobject, SizeOf(reobject), 0);
reobject.cbStruct := SizeOf(reobject);
m_lpObject.GetUserClassID(clsid);
reobject.clsid := clsid;
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 := FClientSite;
//the storage
reobject.pstg := FStorage;
sizel.cx := 0;
sizel.cy := 0;
reobject.sizel := sizel;
//Sel all text
//Sendmessage(Editor.handle, EM_SETSEL, 0, -1);
//Sendmessage(Editor.handle, EM_GETSEL, dwStart, dwEnd);
//Sendmessage(Editor.handle, EM_SETSEL, dwEnd + 1, dwEnd + 1);
//Insert after the line of text
FRTF.InsertObject(reobject);
Sendmessage(Editor.handle, EM_SCROLLCARET, 0, 0);
//VARIANT_BOOL ret;
//do frame changing [red]此处本来为m_lpAnimator.TriggerFrameChange();
但m_lpFlash找不到相应的方法,因此不知用什么方法?[/red]
//show it
m_lpObject.DoVerb(OLEIVERB_UIACTIVATE, nil, FClientSite, 0, Editor.handle, Rect);
// m_lpObject.DoVerb
m_lpObject.DoVerb(OLEIVERB_SHOW, nil, FClientSite, 0, Editor.handle, Rect);
//redraw the window to show animation
redrawwindow(Editor.handle, nil, 0, RDW_ERASE or RDW_INVALIDATE or RDW_FRAME or RDW_ERASENOW or RDW_ALLCHILDREN);
finally
FRTF := nil;
FClientSite := nil;
FStorage := nil;
end;
end;
 
高手请进
 
在RichEdit里插入Flash文件并播放的问题通过多次测试已解决了,但当保存为RTF文件后,再读出时却又不能播放了,有做多媒体的朋友请帮忙.
 
把你的代碼貼上來看看,謝謝
 
代码见前面,只是加了一行
m_lpFlash.Parent=Editor
//这样就可以在Editor里播放
但其实这句语句是不对的,它并没有把Flash添加到Editor的Text里去,因此这语句只是把Flash的容器设为Editor罢了,其实使用Editor.InserControl效果也一样.
 
太难了,用我给你的代码(也是网上找的),写出来的rtf文件,你用记事本打开看看里面有标志的,自己可以试着形成那个标志,另外网上有介绍GIF和bitmap,那么你是不是也可以尝试考虑flash。只是bmp和gif比flash通用一点,flash必须要flash的控件才能播放,gif和bitmap可能用richedit本来就可以了,个人看法
 
chenybin:
我相信是可行的,因为Flash对象是插入到Editor里去了,生成的Rtf文件亦可以证实这一点,只是没办法播放罢了,我们再想想办法吧.
 
试一下richview吧,功能很强大
 
鍙?互鐨勶紝
 
后退
顶部