如何将复制或拖放到 Richedit中的 图片对象保存到流. ( 积分: 300 )

  • 主题发起人 主题发起人 manjel
  • 开始时间 开始时间
M

manjel

Unregistered / Unconfirmed
GUEST, unregistred user!
Function TOLEEdit.PicturetoStream(TmpStream:TmemoryStream):Boolean;
var ReObject:TReObject;
FDataObject:IDataObject;
begin
result:=False;
try
ReObject.cbStruct:= sizeof(REObject);
if FRichEditOle.GetObject(integer(REO_IOB_SELECTION), ReObject, REO_GETOBJ_POLEOBJ) = S_OK then
begin
ReObject.oleobj.QueryInterface(IID_IUnknown,FDataObject);
if assigned(FDataObject) then
begin
result:=True;
end;
end;
except
end;
end;
 
各位兄弟.不要求有完整答案.给一些提示性的代码也好.
 
幫頂一下。跟著學習。。。。
 
发点东西不然对不起观众 目前只做到复制的BMP可以保存.

function TRichEditOleCallback.QueryAcceptData(dataobj: IDataObject; var cfFormat: TClipFormat;
reco: DWORD; fReally: BOOL; hMetaPict: HGLOBAL): HRESULT;
var
StgMedium: TStgMedium;
TmpStream:TmemoryStream;
begin
if (dataobj.GetData(TDropFormatEtc, StgMedium)) = S_OK then
begin
ReleaseStgMedium(StgMedium);
Result:= E_NOTIMPL;
if Assigned(Fowner.FOnTextChange) then FOwner.OnTextChange(Self);
end else begin
if (dataobj.GetData(BDropFormatEtc, StgMedium)) = S_OK then
try
TmpStream:=TmemoryStream.Create;
with Tbitmap.Create do
try
handle:=StgMedium.hBitmap;
SaveToStream(TmpStream);
SaveToFile('c:/Test.bmp');
finally
free;
end;
finally
FreeAndNil(TmpStream);
ReleaseStgMedium(StgMedium);
end;
Result:=S_FALSE;
end;
 
幫頂一下。跟著學習。。。。
 
procedure TOleContainer.SaveAsDocument(const FileName: string);
var
TempStorage: IStorage;
PersistStorage: IPersistStorage;
begin
CheckObject;
if FModSinceSave then SaveObject;
FOleObject.QueryInterface(IPersistStorage, PersistStorage);
if PersistStorage <> nil then
begin
OleCheck(StgCreateDocFile(PWideChar(WideString(Filename)), STGM_READWRITE
or STGM_SHARE_EXCLUSIVE or STGM_CREATE, 0, TempStorage));
OleCheck(OleSave(PersistStorage, TempStorage, False));
PersistStorage.SaveCompleted(nil);
end;
end;
用源码做参考
试试ReObject.oleobj.QueryInterface(IPersistStorage,PersistStorage);
 
非常感谢 lake_cx 我这就试试看.
 
后退
顶部