
VB Control Creation Example
ActiveX Control Example. As was explained earlier we can't get an individual software publishers certificate because we are not citizens of either the USA or Canada (which is the slightly odd criteria that Verisign have set).
As a way around this we have included the actual "control" (.ctl) file for you to download, this can be in turn loaded into Microsoft Visual Basic 5 for you to use, the only provisio is that you add the line "Original control from www.shorrock.u-net.com" somewhere in either the source code or (if you create one) the Projects copyright or other information section.
This control is a three way button, READ the small print first.
This is downloaded at your own risk, although just downloading this control won't do anything, examine to code once you have downloaded and ONLY then use it, by downloading this code you are accepting the we are neither responsible nor liable for any damage, physical or otherwise caused by the use or misuse of any of or part of this (triplebutton.ctl) control.
To Download, select the Example 1 button form the toolbar.
To use this control you will need a new version of WinZip (32bit). Download it by clicking on one of the above options, create a new direrctory for it, extract the contents into that directory and then load the Visual Basic Project File (.vbp) into Microsoft Visual Bacis 5 Control Creation Edition.
Examine the code, look at the first lines,
'Event Declarations:
Event Button1Click() 'MappingInfo=Command1,Command1,-1,Click
Exposing. This is the exposure of an event, the event I exposed in this case is the Command1_Click() event, it was exposed as Button1Click, this basically means that I can use the Button1Click event in the Visual Basic Script inside the .html document that the TripleButton control is in. In Visual Basic itself, if I wanted something to happen when I clicked the Command1 button I would modify the code for the Command1_Click() event, however this cannot be directly accessed by Scripting languages, we have to tell the browser/scripting engine the name of the event. This is what exposure does and in this case the Command1_Click() event is exposed as the Button1Click event, so for something to happen when the top button is clicked we would modify that event, for instance..
<SCRIPT LANGUAGE="VBSCRIPT">
<!--
sub tr1_Button1Click
msgbox "Top Button Clicked"
end sub
-->
<SCRIPT>
..where tr1 is the OBJECT ID of the control.
So if you create a new project in Microsoft Visual Basic and add the triplebutton control to it, remove the old control, create an ActiveX .ocx control, create a download set from that and then add the previous code to the resultant example .html file then run it in Internet Explorer you should (with any luck) be able to click on the top button and see a message box appear.
You can call the other two buttons click events by using the Visual Basic Script in the same .html document as the triplebutton ActiveX control.
sub tr1_button2click
and
sub tr1_button3click
and you can set the captions on the buttons by using the following lines of code:
tr1.button1caption = "button 1"
tr1.button2caption = "button 2"
tr1.button3caption = "button 3"
also there is a title property which sets the caption of the title by using this line of Visual Basic Script.
tr1.title = "Title"
How was this done? Move onto the next part.