Make a control
Up

Microsoft defines ActiveX as 'a set of integration technologies that enable software components to interoperate in a networked environment using any language'. So now you know!

The instructions on this page should allow you to convert ALMOST ANY simple one-form EXE project into an ActiveX control that can be inserted into a web page. However, certain code in your project could cause problems, such as the statement that closes you program, END which you should therefore remove from the project (END IF, END SUB, END SELECT etc are OK).

Start VB5 or 6 and open the project to be converted.

Start VB6 at the same time, so that you have VB running twice on your computer. Create a new ActiveX control project (not an EXE project).

In the instance of VB that contains your original EXE project, select all the controls on the form (Ctrl-A), copy them (Ctrl-C) and then switch to the other instance of VB and paste (Ctrl-V) all the controls into the ActiveX control form. Then go back to your original project, select and copy all the CODE and paste it into the code window of the new ActiveX control.

Now we are ready to test the control. Make sure you are connected to the internet, then press F5 to start the control. A Project Properties window will appear - accept the default options by pressing OK.  Now Internet Explorer should open and display the control inside a web page. Selecting a site from the list should cause the corresponding website to open - if this is successful then you can close the browser.

The web page that you just saw was a temporary one - the next step is to use the 'Package and Deployment wizard' to create a permanent one than we can refer to get the necessary html. The process may seem rather long and complicated the first time you do it but it will go much faster if you try it again

The Package and Deployment wizard does not normally run when VB is running - we have to add it to VB using the Add-Ins menu before we can use it. Open the Add-Ins menu, start the Add-In Manager, select the Package and Deployment wizard from near the top of the list, select Loaded/Unloaded so that the Add-Is is only added temporarily (it will be unloaded when we close VB) and click OK.

We cannot use the Package and Deployment wizard until our project has been saved, so click the Save Project icon on the toolbar, make a new folder for the project with a sesible name - I will assume that your project deals with navigation in which case call the folder 'navigation' and then save both the UserControl file and the Project file into the new folder, giving them both the same name as the folder.

Start the Package and Deployment wizard from the Add-Ins menu - three options will appear.

bulletThe first option, 'Package', is used for making packages that can be placed on the internet.
bulletThe second option is used to actually place the package on the internet server.
bulletThe third option is not important to us.

Choose 'Package' and then 'Compile' - this will create the OCX file that contains the actual ActiveX control. Then click 'Yes' to save the project when prompted.

Now the packaging process can begin. Choose to create an Internet Package, then choose a folder in which the package will be placed (allowing VB to create a new folder if necessary, and choosing NOT to include the Property Page DLL in your package. The wizard will now give a list of files that will be included in the package - accept the default choices by pressing Next. The next step gives you the option of including the necessary VB6 runtime files in the package or allowing them to be downloaded from the Microsoft site (the default option). Accept this default option as it will make the package size smaller and click Next. The next step allows us to set safety values - our control should run safely so change each 'no' into a 'yes', then press Next. As a final step, give the name 'Navigation' to the script that we are creating (the script is the set of instructions for creating the package, or 'cab' file). A Packaging Report now appears - click the close button and also close the wizard.

Now start Windows Explorer (hold down the Windows key and press 'E') and navigate to the folder called Package that has been created in the folder you specified in the wizard. You'll see that inside the Package folder there are:

bulleta Support called folder which contains the actual control as well as some other files
bulleta cabinet file that contains information that the control needs in order to run
bulletan HTM file (a web page) that contains the code needed to display the control in a webpage

Double-click the HTM file and the web page should open in Internet Explorer, complete with the control we have created. Close Internet Explorer and Windows Explorer and return to VB.

You can now copy the contents of the package folder to your website, if you have one, making sure that you put the three files into the same folder that contains the page to which you wish to add the control. Finally, copy the 'object' code from the html file in the package into the html code of the page where you want the control to appear.

 

Previous Up