18.01.2013 Views

VBScript Reference Manual for InduSoft Web Studio

VBScript Reference Manual for InduSoft Web Studio

VBScript Reference Manual for InduSoft Web Studio

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

<strong>VBScript</strong> <strong>Reference</strong> <strong>Manual</strong> <strong>InduSoft</strong> <strong>Web</strong> <strong>Studio</strong><br />

Accessing ActiveX Objects from <strong>VBScript</strong><br />

Any of the <strong>VBScript</strong> interfaces relating to a Screen (i.e. Screen Script, Command Dynamic, and/or<br />

ActiveX Events) can directly access the Properties and Methods of an ActiveX control (OCX) that is<br />

inserted on a screen.<br />

Using ActiveX Controls is fairly straight <strong>for</strong>ward. First, the ActiveX controls must be registered (i.e. the<br />

Operating System Windows Registry must have an entry and Class ID (CLSID) established <strong>for</strong> the<br />

ActiveX Control). Usually when an ActiveX Control is installed in the PC, the installation program will<br />

register the ActiveX Control in the final stage of the installation process. If not, registration can be done<br />

with one of two methods:<br />

1. Use the Microsoft RegSvr32 command<br />

- Invoke the Microsoft Windows Run command<br />

- In the dialog box, type CMD, then OK<br />

- Type REGSVR32 “C:\\.OCX”, then Enter<br />

(Be sure path name is in quotes)<br />

- If the ActiveX Control registers properly, you will get a message indicated this<br />

- Close the dialog box<br />

2. Use the Register Controls utility provided by IWS (under Tools on the main toolbar)<br />

- Click on Tools, then Register Controls<br />

- On the dialog box that pops up, click on Register<br />

- Use the file navigator to locate the ActiveX Control that you want to register<br />

- Click on Open.<br />

- Click on Close in the Register Controls dialog box.<br />

You can also use the IWS Register Controls utility to verify that the ActiveX Control has been<br />

registered. Beware that the registered name and the file name may not be the same, and in many<br />

cases they are not. The best way to verify the control is properly registered is to examine the path of<br />

the registered Control.<br />

When the ActiveX Control has been registered, it can be inserted onto a display screen using either the<br />

OCX tool in the IWS toolbar or by using the Insert -> ActiveX Object from the top toolbar. A dialog box<br />

will appear with a scrolled list of ActiveX objects that are available. Insert the ActiveX object(s) that are<br />

appropriate <strong>for</strong> the application by clicking on OK. IWS will automatically assign a unique name to the<br />

ActiveX control. You can use this name or change it, the only requirement being that it must be unique<br />

from other ActiveX controls.<br />

Now that an ActiveX Control has been placed on the Screen, any <strong>VBScript</strong> interface associated with<br />

that screen can access the ActiveX Control. These <strong>VBScript</strong> interfaces are limited to the Screen Script,<br />

Command Dynamic <strong>for</strong> objects located on the same Screen, and ActiveX Event Handler <strong>for</strong> other<br />

ActiveX objects located on the same Screen.<br />

For example, Microsoft has an ActiveX scrollbar control called “MicrosoftFlatScrollBarControl 6.0 (SP6)”.<br />

Assuming this was inserted <strong>for</strong> the first time onto a Screen in an IWS application, IWS would likely<br />

name this Control “MicrosoftFlatScrollbarControl1”. For brevity, let us rename this to “MFSC1”. I could<br />

easily click on the ActiveX Control on the screen to access its Property Pages, Properties, Methods and<br />

Events.<br />

Note that Property Pages and Events are not accessible through the <strong>VBScript</strong> Interface, although a<br />

<strong>VBScript</strong> Interface is available with the ActiveX’s Event Handler. Only an ActiveX Control’s Properties<br />

and Methods are available from <strong>VBScript</strong> as implemented in IWS. By clicking on the object to get the<br />

Object Properties dialog box<br />

58 <strong>InduSoft</strong>, Ltd.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!