Link to home
Start Free TrialLog in
Avatar of sylexer
sylexer

asked on

ActiveX Param

Hi

Does anybody have a example program how to handle the <PARAM> strings in a html document with an activeForm in delphi

I want to read the folowing parameters :

<OBJECT
       classid="clsid:B95A6EC2-C498-41CB-98E6-5352161D4A8E"
       codebase="testing1234Proj1.ocx"
       width=333
       height=347
       align=center
       hspace=0
       vspace=0>

<param NAME="testpar1" VALUE="0">
<param NAME="testpar2" VALUE="http://www.test.com">
<param NAME="testpar3" VALUE="False">
<param NAME="testpar4" VALUE="True">

</OBJECT>

how can i fix this ???
Avatar of mocarts
mocarts

in TypeLibrary window add to your form interface BSTR (WideString) properties (read/write) with apropriate names and then implement getter and setter methods. then use your property name as Param tag NAME identifier i.e. <param name="PropertyName" value="PropertyValue" />

all properties must be of type WideString (BSTR in type library definition)

wbr, mo.
Avatar of sylexer

ASKER

Could you be a little be more specific or send me an url where its exact explained.

Tnx man
Avatar of sylexer

ASKER

Well i tried a few things but no succes so far


in delphi the typelib added a few thingz

(in protected area)
function Get_Property1: WideString; safecall;
procedure Set_Property1(const Value: WideString); safecall;


(in implementation)
function TActiveFormX.Get_Property1: WideString;
begin
 //--- ??? what to put here
end;

procedure TActiveFormX.Set_Property1(const Value: WideString);
begin
 //--- ??? what to put here
end;

(in html i added this)
<OBJECT
       classid="clsid:91C03AC5-9D3A-449C-B878-D5B95284E93A"
       codebase="./theocx.ocx#version=1,0,0,0"
       width=271
       height=135
       align=center
       hspace=0
       vspace=0
>
<PARAM name="Property1" value="1234567">
</OBJECT>

but no succes till now

i want the property1 value in an variable called propertyval1 for example :S

(yeah i am a newbe to this)
Avatar of sylexer

ASKER

(It workx but not how it should be :( )

Hmmmzz i know now why the first time my vars where not
passed trough the first time


This is what i got now :

(html param)
<param name="Property1" value="1234567890 test">

(delphi)
var
 property1var : string;


function TActiveFormX.Get_Property1: WideString;
begin
  Result := property1var;
end;

procedure TActiveFormX.Set_Property1(const Value: WideString);
begin
  property1var := Value;
end;


On the form oncreate event i do the next
label1.caption := property1var;

Now when the page loads the caption stays empty
BUT !!!! when i refresh the page the label gets its value

How is this fixable so he gets its params the first time the page loads
Add interface to IPersistPropertyBag, e.g.

TMyActiveForm = class(TActiveForm, IMyActiveForm, IPersistPropertyBag) <-- add this!

then implement all these as protected

    function IPersistPropertyBag.Load = PersistPropertyBagLoad;
    function IPersistPropertyBag.Save = PersistPropertyBagSave;
    function IPersistPropertyBag.InitNew = PersistPropertyBagInitNew;
    function IPersistPropertyBag.GetClassID = PersistPropertyBagGetClassID;
    function PersistPropertyBagLoad(const pPropBag: IPropertyBag;
      const pErrorLog: IErrorLog): HResult; stdcall;
    function PersistPropertyBagSave(const pPropBag: IPropertyBag; fClearDirty: BOOL;
      fSaveAllProperties: BOOL): HResult; stdcall;
    function PersistPropertyBagGetClassID(out classID: TCLSID): HResult; stdcall;
    function PersistPropertyBagInitNew: HResult; stdcall;


... and the code

function TMyActiveForm.PersistPropertyBagLoad(
  const pPropBag: IPropertyBag; const pErrorLog: IErrorLog): HResult;
var
  v: OleVariant;
begin
  Result := S_OK;
  try
    if pPropBag.Read('Property1', v, pErrorLog) = S_OK then
      Caption := v;
  except
  end;
end;

function TMyActiveForm.PersistPropertyBagSave(
  const pPropBag: IPropertyBag; fClearDirty,
  fSaveAllProperties: BOOL): HResult;
begin
  Result := S_OK;
end;

function TMyActiveForm.PersistPropertyBagGetClassID(out classID: TCLSID): HResult;
begin
  Result := S_OK;
end;

function TMyActiveForm.PersistPropertyBagInitNew: HResult;
begin
  Result := S_OK;
end;



HTH
DragonSlayer
ASKER CERTIFIED SOLUTION
Avatar of mocarts
mocarts

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial