
raising an event from an activeX control on a htm page in a webbrower control
Quote:
> I have written some activeX controls that contain a number of text
> boxes and combo boxes. I am using the activeX control as a property
> sheet for a program that I am writing. If I was to embed the activeX
> control on a htm page wouldn't it then run in an Internet browser. I
> then want to display the htm page with the ActiveX control on a
> WebBrowser control on a VB form. Is there a way that I can trap the
> ActiveX's custom events through the WebBrowser control?
> I want to embed the ActiveX control in a htm page so that I can load
> my controls or a web page at run time.
> At the moment I am loading the ActiveX control dynamically using a
> VBControlExtender but would rather go the html page route.
> Thank for any help,
> Johnny
You can get the events in the HTML page by using the <SCRIPT> tag:
<SCRIPT language=JavaScript for=ObjectID event=MyEvent>
// code here
</SCRIPT>
If you want to catch the events of the control in the form, first add the
control library to the project references (not components). Then declare a
variable of the control type using WithEvents:
Dim WithEvents MyObjInHTML As MyControl
In the DocumentComplete event of the WebBrowser control get the control
instance from the document:
Private Sub WebBrowser1_DocumentComplete(ByVal pDisp As Object, URL As
Variant)
Set MyObjInHTML = WebBrowser1.Document.getElementById("ObjectID").Object
End Sub
Then use the MyObjInHTML variable to receive events and interact with the
control from the form code.
--
Eduardo A. Morcillo [MS MVP - VB]
http://www.domaindlx.com/e_morcillo