This section gives brief details on using ActiveX components from within an HTML Web page. ActiveX controls can easily be placed on a Web page by using an interactive tool called ActiveX Control Pad.
34 Using Numerical Software Components within Microsoft Windows
//SYS21///INTEGRAS/ELS/PAGINATION/ELSEVIER UK/CMF/3B2/FINALS_21-11-03/CH003.3D–35– [28–37/10]
21.11.2003 3:03PM
Once the control has been placed onto the Web page it is referenced using the information contained in an HTML object tag. The object tag HTML source code for a Microsoft command button is given below:
<OBJECT ID¼‘‘CommandButtonRed’’ WIDTH¼44 HEIGHT¼26 CLASSID¼‘‘CLSID:D7053240—CE69—11CD—A777—00DD01143C57’’>
<PARAM NAME¼‘‘Caption’’ VALUE¼‘‘Red’’>
<PARAM NAME¼‘‘Size’’ VALUE¼‘‘2540;846’’>
<PARAM NAME¼‘‘FontCharSet’’ VALUE¼‘‘0’’>
<PARAM NAME¼‘‘FontPitchAndFamily’’ VALUE¼‘‘2’’>
<PARAM NAME¼‘‘ParagraphAlign’’ VALUE¼‘‘3’’>
</OBJECT>
It can be seen that the unique class identifier for all Microsoft command buttons is D7053240–CE69–11CD–A777–00DD01143C57, and that this particular one, which is referred to in VBScript/JScript as CommandButtonRed, has the caption Redwritten on it. The size of the component when viewed using a Web browser is controlled by the values of WIDTH and HEIGHT. If an ActiveX control has no interactive user-interface then it is only accessed via its language user-interface and can be made invisible by setting WIDTHandHEIGHTto appropriately small values.
Calling the properties and methods of ActiveX controls on an HTML Web page is similar to using them from other Microsoft products such as Excel, Visual Basic, etc.
However, there are slight differences depending on whether VBScript or JScript is used within the Web page. We will now illustrate this using an ActiveX graphical component calledPlot 1. Code excerpt 3.2 illustrates this using VBScript, and Code excerpt 3.3 gives the equivalent JScript code.
<HTML>
<HEAD>
<TITLE>VBScript GARCH modeller demonstration</TITLE>
</HEAD>
<BODY>
<SCRIPT LANGUAGE¼‘‘VBScript’’>
<!__
Sub Calculate__GARCH__Click()
’plot the modelled volatility Plot1.BrushColor 11,224,230 Plot1.PenColor 0, 0, 255 Plot1.PenWidth¼1
Plot1.text ‘‘The modelled GARCH variance’’,40, bot_pos1þ5 End Sub
Sub Clean_Click() Plot1.Clear End Sub – –>
</SCRIPT>
Code excerpt 3.2 Scripting an ActiveX component’s properties and methods using VBScript
The corresponding JScript code is now given:
<HTML>
<HEAD>
<TITLE>JScript GARCH modeller demonstration</TITLE>
ActiveX and COM 35
//SYS21///INTEGRAS/ELS/PAGINATION/ELSEVIER UK/CMF/3B2/FINALS_21-11-03/CH003.3D–36– [28–37/10]
21.11.2003 3:03PM
</HEAD>
<BODY>
<SCRIPT LANGUAGE¼‘‘JScript’’>
<!-–
function Calculate_GARCH_Click() {
// plot the modelled volatility Plot1.BrushColor (11,224,230);
Plot1.PenColor (0, 0, 255);
Plot1.PenWidth¼1;
Plot1.text (‘‘The modelled GARCH variance’’, 40,bot_pos1þ5);
}
function Clean_Click(){
Plot1.Clear();
} – –>
</SCRIPT>
Code excerpt 3.3 Scripting an ActiveX component’s properties and methods using JScript, the program corresponds to the VBScript in Code excerpt 3.2
Since ActiveX component technology is based on Cþþ, calls to complicated numer- ical routines can be simplified through the use of properties, methods, events, object initialization via constructors, data/information hiding within the object, and also optional arguments that take default values.
ActiveX components can be used by the entire range of Microsoft products, from PowerPoint to Internet Web browsers, and also by other Windows products such as Inprise Delphi. It has been shown that it is easy to script ActiveX components on a Web page and that models developed in this way can be easily modified on a local machine and placed on the Internet when appropriate.
Some of the advantages of using ActiveX models on Web pages are:
. VBScript on a Web page can be converted into working Visual Basic code with only minor modifications. Therefore a Web page ActiveX mathematical model can easily be incorporated into Microsoft products such as Microsoft Visual Basic, Microsoft Excel, Microsoft Access, etc.
. Since Microsoft Web browsers are supplied free of charge VBScript or JScript models can be developed at no extra cost (as long as the required ActiveX components are freely available).
. ActiveX components can be created using Visual Cþþ, which means complex mathematical models can be developed with existing numerical software.
Possible disadvantages include:
. ActiveX components are Microsoft Windows specific, and so cannot be used within UNIX.
. There could be a lack of computational efficiency which may become important for certain types of large or complex problems.
From an historical perspective mathematical modelling using ActiveX components and Web script is very similar to the more traditional method of writing Fortran or C programs. Here Fortran or C source code written by the developer is used instead of Web script to call numerical routines (the equivalent of the ActiveX components) 36 Using Numerical Software Components within Microsoft Windows
//SYS21///INTEGRAS/ELS/PAGINATION/ELSEVIER UK/CMF/3B2/FINALS_21-11-03/CH003.3D–37– [28–37/10]
21.11.2003 3:03PM
from the appropriate Fortran or C numerical Library. The major differences in the approach outlined here are that:
. The model is easy to construct because it is made up of numeric ActiveX compo- nents with a simple language user-interface.
. Although an ActiveX component may have been created using Visual Cþþ, its native language is not relevant when it is called via itsIDispatchCOM interface.
This means that its properties and methods can be accessed directly from VBScript and JScript, and it is not necessary to purchase a Visual Cþþcompiler.
. General-purpose libraries can be replaced by self-contained ActiveX components.
Through the creation of the necessary ActiveX components and HTML Web script, the majority of numerical models implemented in traditional languages such as Fortran, C, or Cþþcould be placed on Web pages.
ActiveX and COM 37
//SYS21///INTEGRAS/ELS/PAGINATION/ELSEVIER UK/CMF/3B2/FINALS_21-11-03/CH004.3D– 38– [38–43/6]
21.11.2003 3:04PM
Chapter 4
A financial derivative pricing example
The financial derivative pricing control was chosen to illustrate a control that gives similar importance to both its language and interactive user-interfaces. Its properties can be set interactively at design-time and have associated events, properties and methods. This control was created using Visual Cþþand calculates the value of a financial derivative (option)by solving the Black–Scholes partial differential equation, see Part II for more detail. The interface for the control is described by its ODL file which is given in the Appendix A.1. The control is contained in the file NAGDBS.ocx, and its instance in this Visual Basic example is called NAGDBS1.
It is acknowledged that a commerical version of this software would require:
. Comprehensive documentation, both printed and as Help file information.
. Sophisticated interactive design-time and language user-interfaces.
This example is therefore merely provided as a guide to show what is possible using ActiveX and should not be regarded as a definitive statement on what constitutes a good user-interface.