5,136,034 members and growing! (12,193 online)
Email Password   helpLost your password?
Desktop Development » Miscellaneous » General     Intermediate License: The Code Project Open License (CPOL)

XHyperLink - yet another hyperlink control

By Hans Dietrich

XHyperLink is a simple drop-in hyperlink control with optional parent notification.
VC6, C++Windows, Win2K, WinXP, Win2003, MFC, VS6, VS, Dev

Posted: 16 Oct 2003
Updated: 16 Oct 2003
Views: 33,028
Announcements



Search    
Advanced Search
Sitemap
17 votes for this Article.
Popularity: 5.57 Rating: 4.53 out of 5
1 vote, 5.9%
1
0 votes, 0.0%
2
2 votes, 11.8%
3
1 vote, 5.9%
4
13 votes, 76.5%
5

Introduction

For many years I have used Chris Maunder's excellent Hyperlink control. Recently I needed a hyperlink that would send a notification to the parent dialog. So I started by adding this feature, and then I found that I had added other features too. Here is a list of the new features:

  • Parent notification - the parent window is optionally sent a notification message.
  • New browser window - you can optionally tell the browser to open a new window (same as if you had held down SHIFT key).
  • Background color - you can override default background color and set your own.
  • Disable tooltip - you can optionally disable tooltips for the hyperlink. This makes sense where the hyperlink only sends a notification to the parent window, but does not navigate.
  • Disable URL - optionally disable the URL. Again, this makes sense where the hyperlink only sends a notification to the parent window.
  • Dynamic resizing - you can set new window text at any time and now the control will be resized.
  • Use of IDC_HAND - the MFC hand cursor is used when it is available, before defaulting to the cursor from Winhelp.
  • GoToURL() is now static - now you can say CXHyperLink::GoToURL("http://www.somedomain.com").
  • XHYPERLINK_REPORT_ERROR define - by default this symbol is not defined, which will remove all the strings and message box from ReportError().
  • Resource leak fixed - added DestroyCursor(m_hLinkCursor) that was suggested by Geert Delmeiren.

How to use

To integrate XHyperLink() into your app, you first need to add following files to your project:

  • XHyperLink.cpp
  • XHyperLink.h

Then use the resource editor to add a static control to your dialog, and use Class Wizard to attach a member variable to that control. Note that when adding the static control, you must name it something other than IDC_STATIC.

Next, include the header file XHyperLink.h in the dialog's header file. Then replace the CStatic definition with CXHyperLink. Now you are ready to start using XHyperLink.

Demo app

The XHyperLinkTest.exe demo shows how to use CXHyperLink. The first hyperlink sends an email:

screenshot

The next hyperlink sends a notification to the parent dialog:

screenshot

and the dialog displays a message box:

screenshot

The last hyperlink shows how the text and URL may be dynamically changed:

screenshot

Acknowledgments

Revision history

  • Version 1.0 - 2003 October 17
    • Initial public release.

Usage

This software is released into the public domain. You are free to use it in any way you like. If you modify it or extend it, please to consider posting new code here for everyone to share. This software is provided "as is" with no expressed or implied warranty. I accept no liability for any damage or loss of business that this software may cause.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

Hans Dietrich


Mvp
I attended St. Michael's College of the University of Toronto, with the intention of becoming a priest. A friend in the University's Computer Science Department got me interested in programming, and I have been hooked ever since.

Recently, I have moved to Los Angeles where I am doing consulting and development work.

Occupation: Software Developer (Senior)
Location: United States United States

Other popular Miscellaneous articles:

Article Top
Sign Up to vote for this article
You must Sign In to use this message board.
FAQ FAQ Noise ToleranceSearch Search Messages 
 Layout  Per page   
 Msgs 1 to 12 of 12 (Total in Forum: 12) (Refresh)FirstPrevNext
Subject  Author Date 
GeneralThanksmemberAnu_Bala21:53 10 Mar '08  
GeneralSome more bugsmemberconch15:09 2 Mar '06  
GeneralExcatly What I NeedmemberThatsAlok19:30 20 Feb '05  
GeneralFix for SetUnderline()memberdrake2816:55 15 Dec '04  
GeneralModification: Customized Tooltipsmemberdrake288:29 12 Dec '04  
GeneralRe: Modification: Customized TooltipsmemberJaime Olivares6:14 15 May '05  
GeneralUsing in a CView derived...memberPuiu M.11:43 14 Jul '04  
GeneralDoes the length of the url to be set has a cap?memberdxchen9:53 26 Mar '04  
GeneralNot unless you say so....memberdrake288:45 12 Dec '04  
GeneralWithout using MFCmembermaharsoft3:11 6 Jan '04  
GeneralBug fixesmemberAnonymous10:07 26 Aug '05  
GeneralRe: Bug fixesmemberconch15:05 2 Mar '06  

General General    News News    Question Question    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

PermaLink | Privacy | Terms of Use
Last Updated: 16 Oct 2003
Editor: Smitha Vijayan
Copyright 2003 by Hans Dietrich
Everything else Copyright © CodeProject, 1999-2008
Web09 | Advertise on the Code Project