Visual Basic
  Home arrow Visual Basic arrow Page 4 - A Real-Time ActiveX News Control
Dev Articles Forums 
ADO.NET  
Apache  
ASP  
ASP.NET  
C#  
C++  
ColdFusion  
COM/COM+  
Delphi-Kylix  
Design Usability  
Development Cycles  
DHTML  
Embedded Tools  
Flash  
Graphic Design  
HTML  
IIS  
Interviews  
Java  
JavaScript  
MySQL  
Oracle  
Photoshop  
PHP  
Reviews  
Ruby-on-Rails  
SQL  
SQL Server  
Style Sheets  
VB.Net  
Visual Basic  
Web Authoring  
Web Services  
Web Standards  
XML  
Dedicated Servers  
Actuate Whitepapers 
Moblin 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
VISUAL BASIC

A Real-Time ActiveX News Control
By: Mitchell Harper
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 4 stars4 stars4 stars4 stars4 stars / 7
    2001-12-22

    Table of Contents:
  • A Real-Time ActiveX News Control
  • Creating the ActiveX control
  • Obtaining our news with XMLHTTP
  • Displaying the link
  • Compiling and using our new ActiveX control
  • Conclusion

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT

    Ajax Application Generator Generate database and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!

    A Real-Time ActiveX News Control - Displaying the link


    (Page 4 of 6 )

    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:

    We use the hand cursor to simulate a real link

    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:
    1. hWnd: Handle to parent window.
    2. lpOperation: String that specifies the operation to perform
    3. lpFile: Filename to execute
    4. lpParameters: String that specifies the executable-file parameters
    5. lpDirectory: String that specifies the default directory
    6. nShowCmd: Specifies how the application is shown when it’s opened. Should be zero if lpFile is a document file.
    Our call to the ShellExecute API function looks like this:

    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.

    More Visual Basic Articles
    More By Mitchell Harper


     

    VISUAL BASIC ARTICLES

    - Developing an XML Web Service Using Visual S...
    - Creating an HTML File List with VB
    - Fun with Email: VB6, CDO, MAPI, and a Remote...
    - Extranet/Intranet Dictionary Cracker in VB
    - Finding Default App Icons With Visual Basic
    - Registry Fever With Visual Basic
    - Implementing An ADO Data Control With VB6
    - Printing With Visual Basic
    - MSMQ Part 1/2: Architecture and Simple Imple...
    - Magnifying The Desktop With Visual Basic
    - Sending Email With MAPI Components in Visual...
    - Two Person Chat With The Winsock Control And...
    - A Real-Time ActiveX News Control
    - Accessing the Windows API in Visual Basic


    Iron Speed





    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway