A Real-Time VB6 ActiveX News Control

Compiling and using our new ActiveX control

Because Visual Basic is such a tightly integrated IDE, all we have to do to compile and create our ActiveX control is choose File -> Make prjXMLNews.ocx. Visual Basic will handle the entire library linking and referencing process by itself.

Once the Visual Basic compiler has finished doing its thing, we will be left with a single file, prjXMLNews.ocx. Visual Basic automatically registers our new ActiveX control for us, so all that we have to do is add it to our project.

To do this, we fire up a new instance of Visual Basic and create a standard executable. Using the Project -> Components (or Ctrl+T) menu option, we simply add our ActiveX object as an available control ns our project, like this:

Adding our ActiveX control to a new project is eas

Click OK and take a look at your side tool bar. You should see a new control. Move your mouse over the control, and its tooltip text should display "ctrlNews":

Our ActiveX control is now available from the cont

Now it's simply a matter of double-clicking on the control to add it to our new projects main form. Notice how the control actually shows the news items on it? Resize the control to make sure all of the news items are displayed, and then run the app.

Moving your mouse over any of the labels will show the hand cursor. Clicking on one will open the URL of that news item in a new browser window. If you take your control and play around with it a bit, you can create a neat looking form, like mine, which is shown below:

My implementation of our new ActiveX control

Using our new ActiveX control on a web page is easy as well. Make sure you have your ActiveX control’s source coded loaded in Visual Basic. Now, click on the Play button. This will launch the ActiveX control in a new web browser window. View the source of that page, and copy the entire <OBJECT> tag. It should look something like this:

<OBJECT classid="clsid:B6091979-A970-4967-9257-5372182BC3AA">
</OBJECT>


The classid value is a unique identifier which windows stores in the registry, along with other details of our new ActiveX control, such as its AppId, and ProgId. Simply paste the <OBJECT> tag into a HTML page and save that HTML page on your machine. Fire the page up in your web browser, and our new ActiveX control will be displayed:

Our new ActiveX control in Internet Explorer

You might also like...

Comments

About the author

Mitchell Harper Australia

Visit http://www.devarticles.com for more articles and free programming eBooks, or visit Socket6.com for your dose o...

Interested in writing for us? Find out more.

Contribute

Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“Never trust a programmer in a suit.” - Anonymous