Library tutorials & articles
A Real-Time VB6 ActiveX News Control
By Mitchell Harper, published on 10 Apr 2002
Page 2 of 6
- Introduction
- Creating the ActiveX control
- Obtaining our news with XMLHTTP
- Displaying the link
- Compiling and using our new ActiveX control
- Conclusion
Creating the ActiveX control
Our ActiveX control will contact the MoreOver.com server using XMLHTTP. It will
retrieve an XML document containing a list of news items. In this case, we will
be retrieving video game news. Each entry in the XML file will contain a URL,
headline text, source, media type, cluster, tagline, document URL and harvest
time, as shown below:
We will use the five most recent items in the returned XML file and create a hyperlink to each one in a new browser window. The hyperlink will feature a proper hand icon, and while the XML is being retrieved in the background, a progress bar will display the status of the retrieval.
Start by firing up Microsoft Visual Basic 6. Choose the ActiveX Control option and click on the OK button, as shown below:
Name your project "prjXMLNews" and your control "ctrlNews". Set its background colour to white. Resize the control so that it's about 2500 twips wide by 5400 tips in length. When the XML document is being retrieved from the MoreOver.com server, our control will display a progress bar telling the user what is going on. We need to use the Project -> Components menu option to add the "Microsoft Windows Common Controls 6.0" library to our project. This will allow us to drop a progress bar onto our control. We also need a reference to the "Microsoft XML, v4.0" library.
Also, as mentioned above, our control will display the five most recent XML items retrieved from the MoreOver.com new feed. Each one will be displayed as a label control, which will have hyperlink to the actual URL of the news story.
There are a number of ways that we can retrieve the icon for the hyperlink (you know, the "hand" icon). Because we are creating an ActiveX control, I have chosen to add a picture box, with its Picture property set to the actual image of the hand cursor. The location for this cursor varies from machine to machine, so I have already included it as part of the control.
So far, our ActiveX control looks like this:
Now that I've described how the control will operate, and what it will look like, let's talk about using the XMLHTTP library to retrieve our XML news from MoreOver.com.
We will use the five most recent items in the returned XML file and create a hyperlink to each one in a new browser window. The hyperlink will feature a proper hand icon, and while the XML is being retrieved in the background, a progress bar will display the status of the retrieval.
Start by firing up Microsoft Visual Basic 6. Choose the ActiveX Control option and click on the OK button, as shown below:
Name your project "prjXMLNews" and your control "ctrlNews". Set its background colour to white. Resize the control so that it's about 2500 twips wide by 5400 tips in length. When the XML document is being retrieved from the MoreOver.com server, our control will display a progress bar telling the user what is going on. We need to use the Project -> Components menu option to add the "Microsoft Windows Common Controls 6.0" library to our project. This will allow us to drop a progress bar onto our control. We also need a reference to the "Microsoft XML, v4.0" library.
Also, as mentioned above, our control will display the five most recent XML items retrieved from the MoreOver.com new feed. Each one will be displayed as a label control, which will have hyperlink to the actual URL of the news story.
There are a number of ways that we can retrieve the icon for the hyperlink (you know, the "hand" icon). Because we are creating an ActiveX control, I have chosen to add a picture box, with its Picture property set to the actual image of the hand cursor. The location for this cursor varies from machine to machine, so I have already included it as part of the control.
So far, our ActiveX control looks like this:
Now that I've described how the control will operate, and what it will look like, let's talk about using the XMLHTTP library to retrieve our XML news from MoreOver.com.
Related articles
Related discussion
-
Automating Excel from VB6.0
by epurdy (0 replies)
-
VB6 system conversion using VBA to Word 2007
by b.macgregor@vodamail.co.za (0 replies)
-
video not working with visual basic
by Jupiter 2 (9 replies)
-
Hyperterminal Data
by sengreen (1 replies)
-
vb6 - custom font
by Ruffsta3 (0 replies)
Related podcasts
-
Christian Beauclair
14 mai 2008 (�mission #0074) ::.Christian Beauclair: Stratégies de migration VB6 vers .NET Nous discutons avec Christian Beauclair des stratégies de migration VB6 vers .NET. Entre autres, nous discutons comment utiliser le "VB 6 Code Advisor" et le "Interop Forms Toolkit" pour ajouter la puiss...
Good example.
This is the first time played with any xmlhttp feeds, and found the example whet my appetite for more! The code was not quite complete, but if you are familiar with vb then you should be able to fill in the blanks. Once you get it working, you will no doubt see the other possible uses of this technology.
Keep it real.
I've went thru the listing a few times, and it is not working for me at all....
Things I noticed, the For loop he uses has no Next statement
I'm probably overlooking something ....any suggestions?
And after the LoadNews returns a TRUE it has EXIT function, shouldn't that be end?
Thanks!
Edit = typos
hmmm... yes... it seems the author hasn't released the entire VB project for the control. The hand icon will in fact be in your VB installation directory (in something like Shared/Icons/ along with the icons/toolbar bitmaps etc).
I see the images for the article, but not any hand images.
don't you see any images on http://www.developerfusion.com/show/2273/2/ ? Try hitting refresh on your browser....
I went to the article again and found no images?
There was one crucial thing missing from the article.... the images
I have now added them, which might make it a bit easier for future readers 
This was a somwehat confusing but very cool article once you get it working.
What was frustrating was that the article indicated there was support material, but I cannot find any anywhere.
This just made me really read the article and work with the project until I had it working.
Great topic and a useful tool to add to any non-profit individual.
BTW, I wonder what it costs to use for $$ purposes?
This thread is for discussions of A Real-Time VB6 ActiveX News Control.