rxRichEdit中插入gif文件? ( 积分: 188 )

  • 主题发起人 主题发起人 ymqpc
  • 开始时间 开始时间
Y

ymqpc

Unregistered / Unconfirmed
GUEST, unregistred user!
rxRichEdit中插入gif文件?
在网上找了很久找到如下内容:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, ActiveX, ComCtrls, RxRichEd, ImageOleLib_TLB;
//RxRichEd单元是Rxlib下的RxRichEdit,一套增强功能的RichEdit
//ImageOleLib_TLB是从qq的ImageOle.dll引入的类型库
const
IID_IOleObject: TGUID = (
D1: $00000112; D2: $0000; D3: $0000; D4: ($C0, $00, $00, $00, $00, $00, $00,
$46));
EM_GETOLEINTERFACE = WM_USER + 60;
type
TForm1 = class(TForm)
Button1: TButton;
Editor: TRxRichEdit;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.Button1Click(Sender: TObject);
var
FRTF: IRichEditOle;
FLockBytes: ILockBytes;
FStorage: ISTORAGE;
FClientSite: IOLECLIENTSITE;
m_lpObject: IOleObject;
m_lpAnimator: TGifAnimator;
i_GifAnimator: IGifAnimator;
reobject: TReObject;
clsid: TGuid;
sizel: tagSize;
dwStart, dwEnd: DWORD;
Rect:TRect;
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_lpAnimator := TGifAnimator.Create(Self);
i_GifAnimator := m_lpAnimator.ControlInterface;
i_GifAnimator.LoadFromFile('c:/ti.gif');
i_GifAnimator.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
m_lpAnimator.TriggerFrameChange();
//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(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;
end.

以上内容执行时提示以下三句定义变量的类型没有定义,从而编译不过去.
FRTF: IRichEditOle;
reobject: TReObject;
sizel: tagSize;

我安装的是Rxlib2.75 for D6版本(按readme.txt里的安装方法正确安装的.).
正常安装之后,就是如上的代码执不了.
我发现在uses 里的RxRichEd单元按Ctrl+鼠标左键里并没有打开RxRichEd单元,再点其它的单,其它的单元可以打开.不知是什么地方没有安装好?还是还要设什么路经?
我已以在Delphi的Library path里加入了安装rxlib2.75的目录.
不知问题出在什么地方?
 
rxRichEdit中插入gif文件?
在网上找了很久找到如下内容:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls, ActiveX, ComCtrls, RxRichEd, ImageOleLib_TLB;
//RxRichEd单元是Rxlib下的RxRichEdit,一套增强功能的RichEdit
//ImageOleLib_TLB是从qq的ImageOle.dll引入的类型库
const
IID_IOleObject: TGUID = (
D1: $00000112; D2: $0000; D3: $0000; D4: ($C0, $00, $00, $00, $00, $00, $00,
$46));
EM_GETOLEINTERFACE = WM_USER + 60;
type
TForm1 = class(TForm)
Button1: TButton;
Editor: TRxRichEdit;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.Button1Click(Sender: TObject);
var
FRTF: IRichEditOle;
FLockBytes: ILockBytes;
FStorage: ISTORAGE;
FClientSite: IOLECLIENTSITE;
m_lpObject: IOleObject;
m_lpAnimator: TGifAnimator;
i_GifAnimator: IGifAnimator;
reobject: TReObject;
clsid: TGuid;
sizel: tagSize;
dwStart, dwEnd: DWORD;
Rect:TRect;
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_lpAnimator := TGifAnimator.Create(Self);
i_GifAnimator := m_lpAnimator.ControlInterface;
i_GifAnimator.LoadFromFile('c:/ti.gif');
i_GifAnimator.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
m_lpAnimator.TriggerFrameChange();
//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(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;
end.

以上内容执行时提示以下三句定义变量的类型没有定义,从而编译不过去.
FRTF: IRichEditOle;
reobject: TReObject;
sizel: tagSize;

我安装的是Rxlib2.75 for D6版本(按readme.txt里的安装方法正确安装的.).
正常安装之后,就是如上的代码执不了.
我发现在uses 里的RxRichEd单元按Ctrl+鼠标左键里并没有打开RxRichEd单元,再点其它的单,其它的单元可以打开.不知是什么地方没有安装好?还是还要设什么路经?
我已以在Delphi的Library path里加入了安装rxlib2.75的目录.
不知问题出在什么地方?
 
?????
UP!
請高手回答啊?!!
 
連看的人都沒有?
隻有再提問了.
 
建议使用richview,它支持动态gif,而且功能很多
 
那請給一個richview代碼看一下?
 
人啊!
RichView插入的Gif都不會動的.
rxRichEdit也可以插入不會動的gif啊.
高人去哪裡了?
 
这个问题在VC在比较好实现,DELPHI就难了.想一下其它的路子吧
 
gif:=TGifImage.Create;
gif.LoadFromFile('0020.gif');
rich.InsertPicture('0020.gif',gif,rvvaBaseLine);
rich.Format;
到他们的网站看看吧,
http://www.trichview.com/forums/
下破解的话在盒子应该找的到
 
to:gcw5zb
用那樣的代碼插入的gif會動嗎?
我用以下代碼插入gif文件
gif:=TGifImage.Create;
gif.LoadFromFile('0020.gif');
rich.InsertPicture('0020.gif',gif,rvvaBaseLine);
但是插入之後gif沒有動的.
加上一句
rich.Format;

gif就能動了?
我要試一下
 
在RichEdit中,如何实现半个字是红的,另半个字的黑的?
就像是卡拉OK字幕的效果.
 
測試結果:
加了rich.format;之後插入的gif文件還是一樣的不會動.
我暈了.............................

高人呢?
 
你用代码使它动就行了。
 
下个19的版本吧,18的gif是不会动
 
再引用RVGifAnimate,这个是1.9里面才有的,还是不行的话看看demo吧,Demos/Delphi/Tutorial/
 
版本1.9的是要注冊的去那裡要錢啊 ?
 
此問題在下面的貼子裡已經正確解決.
http://www.delphibbs.com/delphibbs/dispq.asp?lid=2914522
 
把你的msn号给我,我传给你吧
 
請發到我的郵箱裡吧
ymq_sy@163.com

謝謝!
 
后退
顶部