
ActiveX and VB Scripting Part 1.
ActiveX controls are very basically controls created for Windows, i.e .ocx controls are ActiveX controls that can be used over the Internet . This is because ActiveX controls follow the specification for DCOM (Distribute Control Object Model) which we will not get into (yet).
The ActiveX controls are "in process" i.e. they run in the same memory space as Internet Explorer or Netscape. ActiveX controls must be downloaded and registed upon the users or the client machines that wish to use them. However a number of ActiveX controls come pre-built with Windows'95 and Windows NT 4. Another set of ActiveX controls come with Internet Explorer and the ActiveX Control Pad comes with the HTML layout control.
It is therefore possible to write scrips for and make use of these pre-built controls as everybody who has Internet Explorer 3+ (or Netscape Navigator 3 and ScriptActive) will already have the pre-built controls registed on their machines.
e.g. Create an HTML document with just the basic HTML tags in it.
- <HTML>
- <BODY>
- <CENTER>A simple ActiveX control.</CENTER>
- </BODY>
- </HTML>
And then add the following lines to the HTML document. It it very
important that you type this in accurately.
- <BR>
- <CENTER>
- <OBJECT ID="CommandButton1" WIDTH=96 HEIGHT=32 CLASSID="CLSID:D7053240-CE69-11CD-A777-00DD01143C57">
- <PARAM NAME="Caption" VALUE="Button1">
- <PARAM NAME="Size" VALUE="2540;846">
- <PARAM NAME="FontCharSet" VALUE="0">
- <PARAM NAME="FontPitchAndFamily" VALUE="2">
- <PARAM NAME="ParagraphAlign" VALUE="3">
- </OBJECT>
- </CENTER>
The <OBJECT></OBJECT> tags are how we include ActiveX controls into HTML documents. You should add the above lines into the HTML document between the <CENTER></CENTER> tags and the </BODY> tag. The resultanty HTML document should have this in it,
- <HTML>
- <BODY>
- <CENTER>A simple ActiveX control.</CENTER>
- <BR>
- <CENTER>
- <OBJECT ID="CommandButton1" WIDTH=96 HEIGHT=32 CLASSID="CLSID:D7053240-CE69-11CD-A777-00DD01143C57">
- <PARAM NAME="Caption" VALUE="Button1">
- <PARAM NAME="Size" VALUE="2540;846">
- <PARAM NAME="FontCharSet" VALUE="0">
- <PARAM NAME="FontPitchAndFamily" VALUE="2">
- <PARAM NAME="ParagraphAlign" VALUE="3">
- </OBJECT>
- </CENTER>
- </BODY>
- </HTML>
Clicking the button will, at the moment, do nothing. The <OBJECT> </OBJECT> tags specify the ActiveX control to load into the document. The ID part of the tag specifies the name by which the ActiveX control will be known to the HTML document. e.g. If ID="CommandButton1" (as it does in our example) then the control will be known as CommandButton1 if we need to interact with or automate it. The CLASSID="CLSID:D7053240-CE69-11CD-A777-00DD01143C57" attribute specifies the type of control that is to be loaded, in this case CLSID means and ActiveX control (this could be CLASS="java: to specify a Java applet) and the "D7053240-CE69-11CD-A777-00DD01143C57" is the ActiveX controls registry key number. This key uniquely identifies this particular ActiveX control and is the same on every Windows'95 and Windows NT 4 machine.
The <PARAM...> tags are paremets, passed to the ActiveX control that contain information about how the control is to present itself.
e.g. The <PARAM NAME="Caption" VALUE="Button1"> sets the Caption value of the button to "Button1" i.e. the value in the VALUE="..." attribute.
For this button control, really called a "Form2.CommandButton" you could change the VALUE="..." attribute of <PARAM NAME="Size" VALUE="2540;846"> to change the size of the button.
Which is a very long way of going about things, if you had to enter the CLASSID every time you would soon tire of using ActiveX controls. A much easier way of putting ActiveX controls into HTML documents is to use the ActiveX Control Pad.