如何在ActiveForm中接收外部参数?急急急(100分)

  • 主题发起人 主题发起人 青面书生
  • 开始时间 开始时间

青面书生

Unregistered / Unconfirmed
GUEST, unregistred user!
我在web上发布了一个ActiveForm,但需要象Applet那样能够从外部接收参数.
如:
<object classid="clsid:7A3AA138-D074-46B9-9318-720152A9D48F" codebase="******">
<param name=*** value="????">
<param name=*** value="????">
</object>
请问我在delphi中,在那个事件,采用什么方法可以获得这些参数???
急急急。。。。。
thanks.
 
在ActiveForm中增加一个属性,如:NewParam,
Delphi自动生成Function和Procedure,在框架内加上你自己的代码
function TActiveFormTest.Get_btnCaption: WideString;
begin
Result:=btnCaption;//btnCaption:自定义的变量;
end;

procedure TActiveFormTest.Set_btnCaption(const Value: WideString);
begin
btnCaption:=Value;
end;
 
很简单
1。打开你的***.tlb文件,添加你需要的属性和方法即可,如
IafrmCasejudge = interface(IDispatch)
procedure Set_loginpos(Value: Integer);
safecall;//设置属性的方法
property loginpos: Integer read Get_loginpos write Set_loginpos;//属性
2。然后写ASP脚本来调用这些方法,为ocx传递参数即可
 
Thisdo
cument will explain how to add an IPersistPropertyBag
interface to an ActiveX control. This will allow setting the
properties of an ActiveX control through the use of HTML
PARAM tags. Adding the IPersistPropertyBag interface to an
ActiveX control will also allow it to have its properties set
through the use of tools like the ActiveX Control Pad.
Adding the IPersistPropertyBag interface to an ActiveX control
is a simple process. All that is necessary is to add the
interface to an object's class definition and implement the
interface's three methods. The following example will step you
through this process using a simple ActiveX control based on
TButton. In the example, for the sake of simplicity, this example
will only implement this functionality for the "Caption" property.
It is a simple task to extrapolate this example to provide full
functionality for all properties available in a control.
begin
by using the ActiveX Control Wizard to create a ActiveX
control based on TButton.
Choose File|New and select the ActiveX tab from the New Item
Dialog. then
select ActiveX Control. In the next dialog box
choose TButton for the VCL Class Name. The rest of the defaults
in the dialog box are fine sodo
n't change anything else
. Let
Delphi generate the base code for your control.
The next step is to add the IPersistPropertyBag interface to the
class definition.do
this by modifying the first line of the
type declaration from...

type
TButtonX = class(TActiveXControl, IButtonX)

to...

type
TButtonX = class(TActiveXControl, IButtonX, IPersistPropertyBag)

Now the IPersistPropertyBag interface has been added to the
type declaration. Next declare the necessary methods by adding
the following to the protected section.

function IPersistPropertyBag.InitNew = PersistPropBagInitNew;
function IPersistPropertyBag.Load = PersistPropBagLoad;
function IPersistPropertyBag.Save = PersistPropBagSave;
function PersistPropBagInitNew: HResult;
stdcall;
function PersistPropBagLoad(const pPropBag: IPropertyBag;
const pErrorLog: IErrorLog): HResult;
stdcall;
function PersistPropBagSave(const pPropBag: IPropertyBag;
fClearDirty: BOOL;
fSaveAllProperties: BOOL): HResult;
stdcall;

then
, of course, implement those functions...

// -- implement PersistPropBagInitNew
function TButtonX.PersistPropBagInitNew: HResult;
begin
Result := S_OK;
end;

// -- implement PersistPropBagLoad
function TButtonX.PersistPropBagLoad(const pPropBag:
IPropertyBag;
const pErrorLog: IErrorLog): HResult;
stdcall;
var
v: OleVariant;
begin
if pPropBag.Read('Caption', v, pErrorLog) = S_OK then
FDelphiControl.Caption := v;
Result := S_OK;
end;

// -- implement PersistPropBagSave
function TButtonX.PersistPropBagSave(const pPropBag:
IPropertyBag;
fClearDirty: BOOL;
fSaveAllProperties: BOOL)
: HResult;
stdcall;
var
v: OleVariant;
begin
v:= FDelphiControl.Caption;
pPropBag.Write('Caption', v);
Result := S_OK;
end;

With that code added the Control is finished. Go ahead and build
the ActiveX control and deploy it.do
this through the use of the
Web Delpoy Wizard. Just set up the necessary options through
Project|Web Delpoyment Options and deploy through Project|
Web Deploy.
Either you or the Web Deployment Wizard will create an HTML page
which will contain an OBJECT tag something like the following:
以上是老外的例子,前阶段这个问题也困扰着我,现在已经解决,我有相应的例子
 
用VIEW->Type library,为接口增加属性,刷新后会生成GET_XXX,SET_XXX方法,在SET_XXX中给你定义的变量赋值.
 
后退
顶部