
CHLinkCtrl v1.29 An MFC class
to support Hyperlinks
This class allows you to create a static control on a window or dialog which
behaves similar to a hyperlink as seen on a web page. When the mouse moves over the text
the cursor becomes a hand and when you click on the text the hyperlink is executed.

The enclosed zip file contains
the CHLinkCtrl source code and also includes a VC 2005 solution to build a small
demonstration app.
A place you may find this class useful is to spruce up an
otherwise plain "About box" in your Windows applications.
Copyright
- You are allowed to include the source code in
any product (commercial, shareware, freeware or otherwise) when your product
is released in binary form.
- You are allowed to modify the source code in
any way you want except you cannot modify the copyright details at the top
of each module.
- If you want to distribute source code with
your application, then you are only allowed to distribute versions released
by the author. This is to maintain a single distribution point for the
source code.
Updates
v1.01 (9 January 1997)
- Small bug fix relating to duplicate functions.
v1.02 (8 September 1997)
- Number of minor tweaks to the source code.
v1.1 (17 September 1997)
- Hot tracking look
- Drop shadow effect
- Context Menu
- Properties dialog ala IE3
- Add to Favorites & Desktop
- Clipboard support
v1.2 (6 November 1997)
- Improved drawing of control by handling WM_CTLCOLOR through
MFC message reflection
- class now derived from CStatic as it should have been from
the beginning
- Dropped support for shrink to fit as now no need
- Description is now taken from controls window text
- Now using more standard visited and unvisited colors
- streamlined some of the functions declarations
- Wait cursor is now shown when a shortcut is being saved and
when connected to.
- Context menu for control can now be turned off if so desired
v1.21 (29 March 1999)
- Now uses IDC_HAND cursor (available on 98 and Windows 2000) in
preference to the built in cursor which CHLinkCtrl provides.
- Code is now Unicode compliant and build configurations are provided.
- Documentation is now provided in HTML format similar to all of
the classes of the author.
- All the methods of the class are now fully documented in the help
file
- Copy Shortcut context menu item now actually works !.
- Removed a number of unused variables in the code.
v1.22 (11 December 1999)
- Now supports a disabled hyperlink cursor similar to the
offline cursor in IE via the new Set / GetEnabledLink functions.
v1.23 (12 January 2000)
- The zip file lists disabled.cur in the home directory,
not in the RES directory where it belongs.
- When compiling for UNICODE, the copy-to-clipboard
feature sets the incorrect clipboard type CF_TEXT, not CF_UNICODETEXT. This
results in only the first character being available in the clipboard.
v1.24 (18 February 2002)
- Fixed a problem where the underlined style was not
being set for the control when the "NO wrap" window style was
applied.
- Now includes copyright message in the source code and
documentation.
v1.25 (21 December 2006)
- Updated copyright details
- Optimized CHLinkCtrl constructor code
- Optimized CHLinkPage constructor code
- Code now compiles cleanly on VC 2005
- Code now only uses ShellExecute approach to executing hyperlinks
- Stripped context menu support from the class. This provides for a more
leaner control implementation. Derived classes are of course free to
implement their own functionality
- Reviewed all TRACE statements for correctnesss
- Renamed module to be HLinkCtrl to be consistent with the name of the
class
- Hyperlink is now executed on mouse up instead of on mouse down. This is
to maintain consistency with how a command button operates
v1.26 (27 January 2007)
- Updated copyright details.
- Class now by default sports a tooltip with the hyperlink text as its
data.
- Class now only shows the underline when the hyperlink is highlighted.
- The "EnableLink" property has now been removed. Instead you can use the
standard windows WS_DISABLED style. By also doing this, the code now no
longer requires the disabled cursor resource.
- Class now reverts to standard static control colors and style when
disabled.
- Removed code which loads up the IDC_HLINKCTRL_ENABLED_CURSOR cursor.
This now means that the code has no dependency on any resources which you
need to add to your project.
v1.27 (2 February 2007)
- Fixed a small redraw glitch when you use "Use the System Font" setting
in the dialog resource editor in VC 2005.
- Fixed a small redraw glitch when the enabled state of the control is
changed.
v1.28 (22 December 2008)
- Updated copyright details
- Removed VC 6 style AppWizard comments from the code
- The code has now been updated to support VC 2005 or later only
- Code now compiles cleanly using Code Analysis (/analyze)
- Made the "Open" method virtual
- The verb passed to ShellExecute can now be customized.
- Notifications for the static control are now enabled via a WM_NCHITTEST
message handler
- All the default colors and behaviour for the hyperlink are now taken
from the users default settings at HKEY_CURRENT_USER\Software\Microsoft\Internet
Explorer\Settings|Main. These settings include a new setting which controls
the underline behaviour. The programmer can still change these
values if you so desire.
- Fixed a redraw glitch when the control is sent what looks like
unsolicited reflected CTLCOLOR messages from the parent even when it does
not look like the control needs repainting. The control now does not draw
transparently, instead it uses SetDCBrushColor and GetStockObject(DC_BRUSH).
Please note that this means that the control will only work on Windows 2000
or later and requires _WIN32_WINNT to be defined >= 0x0500
v1.29 (22 December 2008)
- The code now uses TrackMouseEvent to implement support for highlighting
instead of capturing the mouse.