Board index » cppbuilder » ActiveX Form interacting with HTML Form

ActiveX Form interacting with HTML Form

I have three (newbie) questions about BCB's ActiveX Form interacting
with HTML Forms. This is the thing I want to do.

I want to replace an existing (HTML) Form placed on a HTML page which
submits data to a webserver with an ActiveX form made with Builder. The
ActiveX form should submit data to the server as usual _IF_ the computer
is connected to the net, if not, it should export the data to a local
textfile instead. Quite easy, right?

So, my questions are:
1. Is it possible for an ActiveX form placed on a HTML page to interact
with the browser's objects (like .document, .window etc)? The same
objects that you can access when using JavaScript.

2. Is it possible to read hidden formvalues stored inside a form on the
page?

3. How do you replace the standard "Submit" function in HTML with an
ActiveX function which does exactly the same thing (submitting formdata
to a webserver).

Any answers to these questions (or samples, references to online
information focusing on ActiveX/BCB) would be greatly appreciated.

// jP

 

Re:ActiveX Form interacting with HTML Form


John, I think that you should dig on the MSDN site for 1. and 2. I don't
know about 3.

Alex

Quote
John Paulsson wrote:

[snip]

Re:ActiveX Form interacting with HTML Form


Quote
John Paulsson wrote:
> I have three (newbie) questions about BCB's ActiveX Form interacting
> with HTML Forms. This is the thing I want to do.

> I want to replace an existing (HTML) Form placed on a HTML page
which
> submits data to a webserver with an ActiveX form made with Builder.
The
> ActiveX form should submit data to the server as usual _IF_ the
computer
> is connected to the net, if not, it should export the data to a
local
> textfile instead. Quite easy, right?

If it is an HTML Control you want to create, you will need to start
with implementing the IWebBrowser2 interface. The ActiveForm Wizard
will not do this for you automatically.

Quote
> Any answers to these questions (or samples, references to online
> information focusing on ActiveX/BCB) would be greatly appreciated.

You might want to look for the IE4/IE5 programming SDK or examples on
DHTML programming.

-- Dave

Re:ActiveX Form interacting with HTML Form


Quote
Dave Borg wrote:
> If it is an HTML Control you want to create, you will need to start

I don't know if it's called a HTML Control, but it should be just like a
standard Form (Editboxes, dropdown listboxes)
on a HTML page but made as an ActiveX.

Quote
> with implementing the IWebBrowser2 interface. The ActiveForm Wizard
> will not do this for you automatically.

Thank you Alex and Dave for your answers.

Ok, I've been reading about the different kinds of interfaces now and it
seems like I need the IHTMLDocument2 interface atleast (and perhaps also
IWebBrowser2 ( what does the 2 mean?)).

I know almost nooooothing about developing ActiveX controls, how difficult
is it to connect to different interfaces? Is it even recommended doing or
so or will it require a couple of hundred lines just to be able to access
the Interface?

About my third question I asked (submitting data from ActiveX component
back to server). I found a KB article (Q172064) about this issue in MSDN.
It seems really easy, you just let a JavaScript read the "Default
Property" from the object and save it to a hidden value inside the HTML
document.

      MyForm.Text.Value = ActiveForm.EditBox.Text;

But, do any of you people know what a "Default Property" for an ActiveX
control is? By using this technique described in Microsoft's document, is
it only possible to have ONE property value per ActiveX control?

// jP

Re:ActiveX Form interacting with HTML Form


Quote
John Paulsson wrote:
> I don't know if it's called a HTML Control, but it should be just
like a
> standard Form (Editboxes, dropdown listboxes)
> on a HTML page but made as an ActiveX.

No, I think I misunderstood. You are referring to an HTML Form.

Quote
> Ok, I've been reading about the different kinds of interfaces now
and it
> seems like I need the IHTMLDocument2 interface atleast (and perhaps
> also IWebBrowser2 ( what does the 2 mean?)).

The 2 means Version 2. COM relies on interfaces remaining the same. An
interface named IWebBrowser must always contain the same methods and
behave the same way. If Microsoft adds new features to the interface
they typically give it a new name by appending a '2' to the end of the
original name.

Quote
> I know almost nooooothing about developing ActiveX controls, how
> difficult is it to connect to different interfaces?

I find the learning curve for COM/ActiveX is very steep compared to
other programming tasks. Start small.

Quote
> Is it even recommended
> doing or so or will it require a couple of hundred lines just to be
able to
> access the Interface?

Yes, you usually need to add interfaces to expand the functionality of
your ActiveX. If the interface is a "standard" one implemented in ATL
it is easy. Otherwise you could be looking at a couple hundred lines.

Quote
> About my third question I asked (submitting data from ActiveX
component
> back to server). I found a KB article (Q172064) about this issue in
MSDN.
> ...
> But, do any of you people know what a "Default Property" for an
ActiveX
> control is?

Just a guess, but it looks like any property named 'Value'.

Quote
> By using this technique described in Microsoft's document, is
> it only possible to have ONE property value per ActiveX control?

It looks that way. However you can access any of the HTML form's
elements through scripting. You should be able to do the following:
- place the "submit" button on your ActiveXForm to fire an event.
- run a script in your HTML when the event is fired.
- using a script copy all of your properties from the ActiveXForm to
the HTML form's hidden elements.
- finally, have the script fire the HTML form's submit method.

Hope this helps.

-- Dave

Re:ActiveX Form interacting with HTML Form


Quote
> The 2 means Version 2. COM relies on interfaces remaining the same. An
> interface named IWebBrowser must always contain the same methods and
> behave the same way. If Microsoft adds new features to the interface
> they typically give it a new name by appending a '2' to the end of the
> original name.

> > I know almost nooooothing about developing ActiveX controls, how
> > difficult is it to connect to different interfaces?

> I find the learning curve for COM/ActiveX is very steep compared to
> other programming tasks. Start small.

> > Is it even recommended
> > doing or so or will it require a couple of hundred lines just to be
> able to
> > access the Interface?

> Yes, you usually need to add interfaces to expand the functionality of
> your ActiveX. If the interface is a "standard" one implemented in ATL
> it is easy. Otherwise you could be looking at a couple hundred lines.

> > About my third question I asked (submitting data from ActiveX
> component
> > back to server). I found a KB article (Q172064) about this issue in
> MSDN.
> > ...
> > But, do any of you people know what a "Default Property" for an
> ActiveX
> > control is?

> Just a guess, but it looks like any property named 'Value'.

> > By using this technique described in Microsoft's document, is
> > it only possible to have ONE property value per ActiveX control?

> It looks that way. However you can access any of the HTML form's
> elements through scripting. You should be able to do the following:
> - place the "submit" button on your ActiveXForm to fire an event.
> - run a script in your HTML when the event is fired.
> - using a script copy all of your properties from the ActiveXForm to
> the HTML form's hidden elements.
> - finally, have the script fire the HTML form's submit method.

> Hope this helps.

Thanks a bunch for your clarifying these things to me. I have never really
been interested in developing ActiveX/COM components. But now when I'm
forced to learn about it, and starts to dig in to the information I find
it really interesting.

MSDN contains _alot_ of good and usefull information for ActiveX/COM
developers, unfortunately I can't find any BCB/ActiveForm examples on the
net.

// jP

Re:ActiveX Form interacting with HTML Form


Quote
John Paulsson  wrote:
> Thanks a bunch for your clarifying these things to me. I have never
really
> ...
> MSDN contains _alot_ of good and usefull information for ActiveX/COM
> developers, unfortunately I can't find any BCB/ActiveForm examples
on
> the net.

Yes, this is true. You might find articles on ATL to be helpful since
ActiveForms build upon ATL. Look for examples based on ATL. Borland
C++ Builder 4 Unleashed has a couple chapters that help explain the
link with ATL as well.

-- Dave

Re:ActiveX Form interacting with HTML Form


Quote
Dave Borg wrote:
> John Paulsson wrote:
> > But, do any of you people know what a "Default Property"
>> for an ActiveX control is?

> Just a guess, but it looks like any property named 'Value'.

Well my guess was sort of close. I just stumbled across some
references to the default property.

The default property uses the DISPID of DISPID_VALUE which is 0
(zero). The property name can be anything but it is often called
"Item"

-- Dave

Other Threads