Uriah Liggett Guest
|
Posted: Wed Apr 07, 2004 2:19 pm Post subject: Re: How to set params in ActiveX |
|
|
Borland's site explains how to do this in 5 easy steps(I forgot the url
but I saved the information)....
This can be done by adding IPersistPropertyBag support to your
ActiveForm. Normally, you would have to go through and actually
implement the whole interface yourself, but the ATL is nice enough to
provide a default implementation and a couple of handy macros. Here are
the things we need to concern ourselves with:
IPersistPropertyBagImpl -- ATL's default IPersistPropertyBag implementation.
COM_INTERFACE_ENTRY_IMPL -- Tells the compiler that our class implements
a certain interface. PROP_ENTRY -- Tells the compiler about a certain
property of our class.
Adding property support to your ActiveForm (or any ActiveX control in
BCB) is relatively simple. Our test ActiveForm is called AFormTest. The
following additions are necessary (all of the code changes below are in
your **Impl.h file.)
1) Add whatever properties you need in the Type Library Editor.
2) Note each property's DispID (this can be seen in the Attributes page
of the TLE under ID).
3) Change the line:
class ATL_NO_VTABLE TAFormTestImpl:
VCLCONTROL_IMPL(TAFormTestImpl, AFormTest, TAFormTest, IAFormTest,
DIID_IAFormTestEvents)
To this:
class ATL_NO_VTABLE TAFormTestImpl:
VCLCONTROL_IMPL(TAFormTestImpl, AFormTest, TAFormTest, IAFormTest,
DIID_IAFormTestEvents),
public IPersistPropertyBagImpl<TAFormTestImpl>
4) Within the BEGIN..END_COM_MAP macros in your **Impl class, add the
following:
COM_INTERFACE_ENTRY_IMPL(IPersistPropertyBag)
5) Within the BEGIN..END_PROPERTY_MAP macros in your **Impl class, add
the following:
PROP_ENTRY("PropertyName",<dispid>,CLSID_*)
Where PropertyName is the name of your property, dispid is it's
DispID, and CLSID_* is its CLSID.
5) Now implement your class's property getter/setters and it should work
just fine!
jon wrote:
| Quote: | I'm making an ActiveX control.
I have looked and looked, but I just
cannot see how you set up the control
so it accepts the <param> values in html.
The 'property page' looks inappropriate
for this purpose. And ActiveX controls I have looked
at with params don't seem to have it, by right
clicking on the control on the html page.
|
|
|