Library tutorials & articles
A Real-Time VB6 ActiveX News Control
Displaying the link
When the user moves their mouse over a label containing a headline, we want to
make it look like an actual link. We do this by setting the colour of the links
text to blue, underlining it, and setting the cursor to the hand icon.
As mentioned earlier, the hand icon is included with the support material at the
end of this article. Our ActiveX control contains a picture control named "picHand".
The Picture property of "picHand" is set to the location of the hand cursor file.
Then, whenever the MouseMove event is triggered for a label, we set its icon to
the hand, like this: lblLink1.MousePointer = 99
lblLink1.MouseIcon = picHand.Picture
Here's how the hand looks when it is displayed over a label:
When the user actually clicks on a link, the JumpToNews function is called, with
the index of the news item clicked: JumpToNews 1
We create the JumpToNews function as a privately declared sub-routine, like this:
Private Sub JumpToNews(index As Integer)
Our JumpToNews function will actually display a new browser window. The URL of
that browser window will be the URL retrieved from the arrLinks array. To actually
open a browser window, we use the ShellExecute API call. The ShellExecute function
is privately declared in the general declarations section of our ActiveX control,
and looks like this: Private Declare Function ShellExecute Lib "shell32.dll"
Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal
lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal
nShowCmd As Long) As Long
The ShellExecute API call allows us to execute any program (or file) directly
from our application. It takes six arguments, and returns a long integer value.
Each of these six arguments are described below:
- hWnd: Handle to parent window.
- lpOperation: String that specifies the operation to perform
- lpFile: Filename to execute
- lpParameters: String that specifies the executable-file parameters
- lpDirectory: String that specifies the default directory
- nShowCmd: Specifies how the application is shown when it’s opened. Should be zero if lpFile is a document file.
Dim openURL As Long
openURL = ShellExecute(0&, "Open", arrLinks(index - 1), "", vbNullString, 1)
This will launch a new browser window. The URL of the browser window is retrieved from the arrLinks array, based on which link was clicked.
And that's all there is to it! A couple of controls, some XML objects and an API call. Now that I've talked about the code involved in creating our ActiveX control, I will describe how to compile it and how to use it in both a web page, and a VB application.
Related articles
Related discussion
-
Run-time error '91'
by converter2009 (1 replies)
-
VB6 Runtime error 381 subsript out of range Error
by Uncle (2 replies)
-
passing and reading parameters from using Shell
by jigartoliya (0 replies)
-
Convert C++ code to VB6
by mawcot (4 replies)
-
listbox scrollbar
by Dennijr (10 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.