I
import
Unregistered / Unconfirmed
GUEST, unregistred user!
单元名称:RxRichEd
// 单元描述:
// 编码人: xjx Email:x7x@263.net
// 交付时间:2002-7-23 12:32:04
// 版本号: 0.01 ( 每修改一次加1)
// 修正记录:
//*********************************************************************
// 时间 修正人 备注
//----------------------------------------------------------------------
20020723 xjx 添加了InsertObject过程实现在RxRichEdit
中插入Ole对象功能
例子:reole.InsertObject('PBrush');
reOle 为TRxRichEdit 类的实例
//***********************************************************************}
{*******************************************************}
{ }
{ Delphi VCL Extensions (RX) }
{ }
{ Copyright (c) 1998 Master-Bank }
{ }
{*******************************************************}
procedure TRxCustomRichEdit.InsertObject(const AOleClassName: string);
var
//Data: TOleUIInsertObject;
NameBuffer: array[0..255] of Char;
OleClientSite: IOleClientSite;
Storage: IStorage;
OleObject: IOleObject;
ReObject: TReObject;
IsNewObject: Boolean;
Selection: TCharRange;
begin
{TODO -c扩展-oxjx:加入InsertObject过程的实现}
//FillChar(Data, SizeOf(Data), 0);
FillChar(NameBuffer, SizeOf(NameBuffer), 0);
FillChar(ReObject, SizeOf(TReObject), 0);
if Assigned(FRichEditOle) then begin
IRichEditOle(FRichEditOle).GetClientSite(OleClientSite);
Storage := nil;
try //try1
CreateStorage(Storage);
try //try2 Data.dwFlags and
IsNewObject := IOF_SELECTCREATENEW = IOF_SELECTCREATENEW;
OleCheck(OleCreate(ProgIDToClassID(AOleClassName), IOleObject, OLERENDER_DRAW, nil, // ClassID
OleClientSite, Storage, OleObject));
with ReObject do begin
cbStruct := SizeOf(TReObject);
cp := REO_CP_SELECTION;
clsid := ProgIDToClassID(AOleClassName);
poleobj := OleObject;
pstg := Storage;
polesite := OleClientSite;
dvAspect := DVASPECT_CONTENT;
dwFlags := REO_RESIZABLE;
if IsNewObject then dwFlags := dwFlags or REO_BLANK;
OleCheck(OleSetDrawAspect(OleObject,
IOF_SELECTCREATENEW {Data.dwFlags} and IOF_CHECKDISPLAYASICON <> 0,
0 {Data.hMetaPict}, dvAspect));
end;
SendMessage(Handle, EM_EXGETSEL, 0, Longint(@Selection));
Selection.cpMax := Selection.cpMin + 1;
OleCheck(IRichEditOle(FRichEditOle).InsertObject(ReObject));
SendMessage(Handle, EM_EXSETSEL, 0, Longint(@Selection));
SendMessage(Handle, EM_SCROLLCARET, 0, 0);
IRichEditOle(FRichEditOle).SetDvaspect(
Longint(REO_IOB_SELECTION), ReObject.dvAspect);
if IsNewObject then OleObject.DoVerb(OLEIVERB_SHOW, nil,
OleClientSite, 0, Handle, ClientRect);
finally
ReleaseObject(OleObject);
end; //try2
finally
ReleaseObject(OleClientSite);
ReleaseObject(Storage);
end; //try1
end;
end;
附件>>> <a href="RxRichEd.rar" target="_blank">RxRichEd.rar</a>
// 单元描述:
// 编码人: xjx Email:x7x@263.net
// 交付时间:2002-7-23 12:32:04
// 版本号: 0.01 ( 每修改一次加1)
// 修正记录:
//*********************************************************************
// 时间 修正人 备注
//----------------------------------------------------------------------
20020723 xjx 添加了InsertObject过程实现在RxRichEdit
中插入Ole对象功能
例子:reole.InsertObject('PBrush');
reOle 为TRxRichEdit 类的实例
//***********************************************************************}
{*******************************************************}
{ }
{ Delphi VCL Extensions (RX) }
{ }
{ Copyright (c) 1998 Master-Bank }
{ }
{*******************************************************}
procedure TRxCustomRichEdit.InsertObject(const AOleClassName: string);
var
//Data: TOleUIInsertObject;
NameBuffer: array[0..255] of Char;
OleClientSite: IOleClientSite;
Storage: IStorage;
OleObject: IOleObject;
ReObject: TReObject;
IsNewObject: Boolean;
Selection: TCharRange;
begin
{TODO -c扩展-oxjx:加入InsertObject过程的实现}
//FillChar(Data, SizeOf(Data), 0);
FillChar(NameBuffer, SizeOf(NameBuffer), 0);
FillChar(ReObject, SizeOf(TReObject), 0);
if Assigned(FRichEditOle) then begin
IRichEditOle(FRichEditOle).GetClientSite(OleClientSite);
Storage := nil;
try //try1
CreateStorage(Storage);
try //try2 Data.dwFlags and
IsNewObject := IOF_SELECTCREATENEW = IOF_SELECTCREATENEW;
OleCheck(OleCreate(ProgIDToClassID(AOleClassName), IOleObject, OLERENDER_DRAW, nil, // ClassID
OleClientSite, Storage, OleObject));
with ReObject do begin
cbStruct := SizeOf(TReObject);
cp := REO_CP_SELECTION;
clsid := ProgIDToClassID(AOleClassName);
poleobj := OleObject;
pstg := Storage;
polesite := OleClientSite;
dvAspect := DVASPECT_CONTENT;
dwFlags := REO_RESIZABLE;
if IsNewObject then dwFlags := dwFlags or REO_BLANK;
OleCheck(OleSetDrawAspect(OleObject,
IOF_SELECTCREATENEW {Data.dwFlags} and IOF_CHECKDISPLAYASICON <> 0,
0 {Data.hMetaPict}, dvAspect));
end;
SendMessage(Handle, EM_EXGETSEL, 0, Longint(@Selection));
Selection.cpMax := Selection.cpMin + 1;
OleCheck(IRichEditOle(FRichEditOle).InsertObject(ReObject));
SendMessage(Handle, EM_EXSETSEL, 0, Longint(@Selection));
SendMessage(Handle, EM_SCROLLCARET, 0, 0);
IRichEditOle(FRichEditOle).SetDvaspect(
Longint(REO_IOB_SELECTION), ReObject.dvAspect);
if IsNewObject then OleObject.DoVerb(OLEIVERB_SHOW, nil,
OleClientSite, 0, Handle, ClientRect);
finally
ReleaseObject(OleObject);
end; //try2
finally
ReleaseObject(OleClientSite);
ReleaseObject(Storage);
end; //try1
end;
end;
附件>>> <a href="RxRichEd.rar" target="_blank">RxRichEd.rar</a>