巨难的问题, 怎样向一个Activex 里传递图片,将它作为一个参数来!(搞定立刻送500分!!)(300分)

  • 主题发起人 主题发起人 Puma Wang
  • 开始时间 开始时间
P

Puma Wang

Unregistered / Unconfirmed
GUEST, unregistred user!
各位大侠, 帮帮我吧!
 
很简单啦,把图片内容编码后,以字符串传入,在activex中解码,写临时文件,再调入
 
这位大哥你做过吗? 我不会。
能给我一点例子吗?
 
xlw9644580@sina.com
正在着急呢!!
 
//Automation Object
unit Unit1;

{$WARN SYMBOL_PLATFORM OFF}

interface

uses
ComObj, ActiveX, Project1_TLB, StdVcl, ExtDlgs, Graphics, AxCtrls;

type
TDemo = class(TAutoObject, IDemo)
protected
function Get_Picture: IPicture
safecall;
end;

implementation

uses ComServ;

function TDemo.Get_Picture: IPicture;
var
OpenPictureDialog:TOpenPictureDialog;
FPicture:TPicture;
Ip:IPictureDisp;
begin
OpenPictureDialog:=TOpenPictureDialog.Create(nil);
FPicture:=TPicture.Create;
try
if OpenPictureDialog.Execute then
begin
FPicture.LoadFromFile(OpenPictureDialog.FileName);
GetOlePicture(FPicture,Ip);
Result:=Ip as IPicture;
end;
finally
FPicture.Free;
OpenPictureDialog.Free;
end;
end;

initialization
TAutoObjectFactory.Create(ComServer, TDemo, Class_Demo,
ciMultiInstance, tmApartment);
end.



//调用Automation Object.
unit MainUnit;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ExtCtrls, ActiveX, AxCtrls;

type
TForm1 = class(TForm)
Image1: TImage;
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

implementation

uses Project1_TLB;

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
var
FDemo:Demo;
begin
FDemo:=CoDemo.Create;
try
SetOlePicture(Image1.Picture,FDemo.Picture as IPictureDisp);
finally
FDemo:=nil;
end;
end;

end.
 
接受答案了.
 
后退
顶部