Board index » cppbuilder » Adding a new property to the an ActiveXForm

Adding a new property to the an ActiveXForm

Hi,

I programming an ActiveXForm in BCB4Pro
After some help from our good friend Bruneau, I have managed to
implement the IPersistPropertyBagImpl to retrieve <PARAM NAME.. VALUE..>
info from HTML tags.
The only problem is that I am only doing this with an already existing
property ("Caption"). I am trying to add new properties so they can be
set thru HTML, but after altering everything correctly on the TLB.
I end up with this method on the ActiveXForm class:

STDMETHODIMP TActiveFormXImpl::get_Tag1(BSTR* Value)
{
  try
  {
        *Value=WideString("testing...");
  }
  catch(Exception &e)
  {
    return Error(e.Message.c_str(), IID_IActiveFormX);
  }
  return S_OK;

Quote
};

All the other methods that access properties retrieve them
from the m_VclCtl object. How do I access the data in the Tag1 property?

Thanx.

--
===============================
Alexandre Domingues Gon?alves
EMAIL: ale...@wiz.pt
PGP: Public key on request
TMN: 0936 2326732
-------------------------------
W I Z - Servi?os Internet LDA
WEB: http://www.wiz.pt
TEL: +351 1 464-9004/5
FAX: +351 1 464-9006
===============================

 

Re:Adding a new property to the an ActiveXForm


Alexandre,

Accessing the property via PARAM=/NAME= is independent from the
implementation of the property. The predefined properties of an ActiveForm
are all implemented via m_VclCtl because that's the only thing that
C++Builder can do automatically for you. After you've generated you
ActiveForm, you'll probably add new properties to the Form. These will be
your control's specific properties. How you implement these won't make a
difference to hoe you access them via PARAM=/NAME=. Most likely your new
property will not be implemented via a call to m_VclCtl. But it could:
specially if it's a property you want to display in your control's UI.

Let's take the case where you add a new property:  Tag1. First of all, it
will probably be a Get/Put property (PARAM/NAME is only for initializing -
i.e. Put). You'll end up with a get_Tag1() and a set_Tag1() function. You
may choose to implement these by simply storing the value in some variable.
Of you may choose to implement then by displaying the value on some control
on your form. Let's assume you have an Edit control that will display the
Tag1 property. Then 'set_Tag1' might do something along the lines of:

   m_VclCtl->Edit1->Text = AnsiString(Value);

Once that's done, you can add the Tag1 property to your property map (NOTE:
30 is the dispid of the newly created property):

PROP_ENTRY("Tag1", 30, CLSID_ActiveFormX)

Now you can initialize this property via the following in your <OBJECT> tag.

 <PARAM NAME="Tag1" VALUE="New Value for Tag1 Property">

Hope the above helps,

Bruneau.

Quote
Alexandre D. Gon?alves wrote in message <376162C9.434DF...@wiz.pt>...
>Hi,

>I programming an ActiveXForm in BCB4Pro
>After some help from our good friend Bruneau, I have managed to
>implement the IPersistPropertyBagImpl to retrieve <PARAM NAME.. VALUE..>
>info from HTML tags.
>The only problem is that I am only doing this with an already existing
>property ("Caption"). I am trying to add new properties so they can be
>set thru HTML, but after altering everything correctly on the TLB.
>I end up with this method on the ActiveXForm class:

>STDMETHODIMP TActiveFormXImpl::get_Tag1(BSTR* Value)
>{
>  try
>  {
>        *Value=WideString("testing...");
>  }
>  catch(Exception &e)
>  {
>    return Error(e.Message.c_str(), IID_IActiveFormX);
>  }
>  return S_OK;
>};

>All the other methods that access properties retrieve them
>from the m_VclCtl object. How do I access the data in the Tag1 property?

>Thanx.

>--
>===============================
>Alexandre Domingues Gon?alves
>EMAIL: ale...@wiz.pt
>PGP: Public key on request
>TMN: 0936 2326732
>-------------------------------
>W I Z - Servi?os Internet LDA
>WEB: http://www.wiz.pt
>TEL: +351 1 464-9004/5
>FAX: +351 1 464-9006
>===============================

Other Threads