IPicture(disp) problems !!
hello com-experts,
i tried to use the IPicture(Disp) to transfer a picture from a client to
a server application or vice versa. It does't work, crashing every time
with the strange message 'unexcepted failure'.
Is is somehow possible that the IPicture transfer is not bugfree (Delphi
side) ? All books (including 'Delphi COM programming' from Eric Harmon)
mention the three types IStrings, IFont and IPicture, but none of them
implements the IPicture (using SetOlePicture and GetOlePicture) ! Isn't
this strange ?
Is anyone knows what the problem is in this issue ; I warmly welcome you
and your advice !
yves.
some excerpts out of my code (different units) ;
type
TListServer = class(TAutoObject, IListServer)
private
FPicture : TPicture;
protected
function Get_Picture: IPicture; safecall;
procedure Set_Picture(const Value: IPicture); safecall;
property Picture: IPicture read Get_Picture write Set_Picture;
public
destructor Destroy; override;
procedure Initialize; override;
end;
implementation
destructor TListServer.Destroy;
begin
FPicture.Free;
inherited;
end;
procedure TListServer.Initialize;
begin
inherited;
FPicture := TPicture.Create;
end;
// ListServerForm is the mainform of my serverapplication -
// just to check the transfer of the picture (dumping it in a TImage
component)
function TListServer.Get_Picture: IPicture;
var
TmpIPicDisp : IPictureDisp;
begin
FPicture.Assign(ListServerForm.Image1.Picture);
GetOlePicture(FPicture,TmpIPicDisp);
Result := TmpIPicDisp as IPicture;
end;
procedure TListServer.Set_Picture(const Value: IPicture);
begin
SetOlePicture(FPicture, Value as IPictureDisp);
ListServerForm.Image1.Picture.Assign(FPicture);
end;