关于RxRichEdit的使用 (100分)

  • 主题发起人 主题发起人 死水
  • 开始时间 开始时间

死水

Unregistered / Unconfirmed
GUEST, unregistred user!
我想使插入(或粘贴)到RxRichEdit的图片不能改变大小(即不允许用鼠标拖拽改变它的大小),
请问该怎么做?

我有急用。
谢谢
 
没人帮忙?
 
try it
RxRichEdit.readonly:=trye;
 
我试过,没问题!win2000 for d5
 
RxRichEdit.readonly:=true;

我还要编辑啊,您弄成只读的了,那怎么行?
 
RxRichEdit.readonly:=true;
且不说被设为只读,图片还是能被拖拉改变大小,所以根本不行

死水,同病相连!
 
死水:试试下面的程序,可以实现,不过要先把RxRichEdit.AllowObject:=false。
unit InsRich;
interface
uses
...ActiveX;
const
REO_CP_SELECTION = ULONG(-1);
REO_BELOWBASELINE = $00000002;
REO_RESIZABLE = $00000001;
REO_STATIC = $40000000;
EM_GETOLEINTERFACE = WM_USER + 60;
IID_IUnknown: TGUID = (D1:$00000000;D2:$0000;D3:$0000;D4:($C0,$00,$00,$00,$00,$00,$00,$46));
IID_IOleObject: TGUID = (D1:$00000112;D2:$0000;D3:$0000;D4:($C0,$00,$00,$00,$00,$00,$00,$46));
type
_ReObject = record
cbStruct: DWORD; { Size of structure }
cp: ULONG; { Character position of Object }
clsid: TCLSID; { Class ID of Object }
pOleObj: IOleObject; { Ole Object interface }
pstg: IStorage; { Associated storage interface }
pOleSite: IOleClientSite; { Associated Client Site interface }
sizel: TSize; { Size of Object (may be 0,0) }
dvAspect: Longint; { Display aspect to use }
dwFlags: DWORD; { Object status flags }
dwUser: DWORD; { Dword for user's use }
end;
TReObject = _ReObject;
TCharRange = record {Copy From RichEdit.pas}
cpMin: Integer;
cpMax: Integer;
end;
TFormatRange = record
hdc: Integer;
hdcTarget: Integer;
rectRegion: TRect;
rectPage: TRect;
chrg: TCharRange;
end;
IRichEditOle = interface(System.IUnknown)
['{00020d00-0000-0000-c000-000000000046}']
function GetClientSite(out ClientSite: IOleClientSite): HResult; stdcall;
function GetObjectCount: HResult; stdcall;
function GetLinkCount: HResult; stdcall;
function GetObject(iob: Longint; out ReObject: TReObject; dwFlags: DWORD): HResult; stdcall;
function InsertObject(var ReObject: TReObject): HResult; stdcall;
function ConvertObject(iob: Longint; rclsidNew: TIID;lpstrUserTypeNew: LPCSTR): HResult; stdcall;
function ActivateAs(rclsid: TIID; rclsidAs: TIID): HResult; stdcall;
function SetHostNames(lpstrContainerApp: LPCSTR; lpstrContainerObj: LPCSTR): HResult; stdcall;
function SetLinkAvailable(iob: Longint; fAvailable: BOOL): HResult; stdcall;
function SetDvaspect(iob: Longint; dvaspect: DWORD): HResult; stdcall;
function HandsOffStorage(iob: Longint): HResult; stdcall;
function SaveCompleted(iob: Longint; const stg: IStorage): HResult; stdcall;
function InPlaceDeactivate: HResult; stdcall;
function ContextSensitiveHelp(fEnterMode: BOOL): HResult; stdcall;
function GetClipboardData(var chrg: TCharRange; reco: DWORD; out dataObj: IDataObject): HResult; stdcall;
function ImportDataObject(dataObj: IDataObject; cf: TClipFormat; hMetaPict: HGLOBAL): HResult; stdcall;
end;
function InsertBitmap(Editor: TRxRichEdit; BmpFile: String): Boolean;

implementation

function InsertBitmap(Editor: TRxRichEdit; BmpFile: String): Boolean;
var
FRTF: IRichEditOle;
FOle: IOleObject;
FormatEtc: tagFormatETC;
FStorage: ISTORAGE;
FClientSite: IOleClientSite;
FLockBytes: ILockBytes;
ReObject: TReObject;
xt: TGuid;
FTemp: IUnknown;
begin
Result:=false;
if not FileExists(BmpFile) then Exit;
try
SendMessage(Editor.Handle, em_GetOleInterFace, 0, LongInt(@FRTF));
if not Assigned(FRTF) then Exit;
if CreateILockBytesOnHGlobal(0,true,FLockBytes)<>S_OK then Exit;
if StgCreateDocfileOnILockBytes(FLockBytes,STGM_SHARE_EXCLUSIVE or STGM_CREATE or STGM_READWRITE,0,FStorage)<>S_OK then Exit;
FormatEtc.cfFormat:=0;
FormatEtc.ptd:=nil;
FormatEtc.dwAspect:=DVASPECT_CONTENT;
FormatEtc.lindex:=-1;
FormatEtc.tymed:=TYMED_NULL;
FRTF.GetClientSite(FClientSite);
//从文件中创建一个Ole对象
if OleCreateFromFile(GUID_NULL,PWideChar(WideString(BmpFile)),IID_IUnknown,0,@FormatEtc,FClientSite,FStorage,FOle)<>S_OK then Exit;
FTemp:=FOle;
FTemp.QueryInterface(IID_IOleObject, FOle);
OleSetContainedObject(FOle, true);
ReObject.cbStruct:=SizeOf(TReObject);
FOle.GetUserClassID(xt);
ReObject.clsid:=xt;
ReObject.cp:=ULong(REO_CP_SELECTION);
ReObject.dvaspect:=DVASPECT_CONTENT;
ReObject.dwFlags:=ULogn(REO_STATIC) or ULong(REO_BELOWBASELINE);
ReObject.dwUser:=0;
ReObject.pOleObj:=FOle;
ReObject.pOleSite:=FClientSite;
ReObject.pstg:=FStorage;
ReObject.sizel.cx:=0;
ReObject.sizel.cy:=0;
FRTF.InsertObject(ReObject);
finally
FRTF:=nil;
FOle:=nil;
end;
Result:=true;
end;
 
死水呢?
我的方法可以吗?
 
接受答案了.
 
后退
顶部