IPicture 实际上是 OlePicture 的指针, 在 Delphi 的 AXCtrlx.pas 中优两个
过程专门进行 ActiveX 中的 OlePicture 和 TPicture 的转换工作:
procedure GetOlePicture(Picture: TPicture; var OlePicture: IPicture);
procedure SetOlePicture(Picture: TPicture; OlePicture: IPictureDisp);
GetOlePicture 将用一个 TPicture 来创建一个 OlePicture
SetOlePicture 将一个 OlePicture 直接转换成 TPicture 对象
欲要将做 Automation Server 中的图像传给其他程序, 可以建立一个 Picture
属性, 供其他程序使用:
interface
type
TMyControlX = class(TActiveXControl, IMyControlX)
private
FDelphiControl
...
public
function Get_Picture: IPictureDisp; safecall;
procedure Set_Picture(const Value: IPictureDisp); safecall;
...
property Picture: IPictureDisp read Get_Picture write Set_Picture;
end;
implementation
function TMyControlX.Get_Picture: IPictureDisp;
begin
GetOlePicture(FDelphiControl.Picture, Result);
end;
procedure TMyControlX.Set_Picture(const Value: IPictureDisp);
begin
SetOlePicture(FDelphiControl.Picture, Value);
end;