Class: cLinkLabel

Properties  Events  Methods    Index of Classes

Enables mixing of text and multiple hyperlink areas in a single control

Hierarchy

cObject
---cUIObject
------DfBaseObject
---------DfBaseWindow
------------DfBaseUIWindow
---------------DfBaseContainer
------------------DfBaseDialog
---------------------Container3d
------------------------cLinkLabel

Library: Windows Application Class Library

Package: cLinkLabel.pkg

Mixins: Label_Mixin ToolTip_Support_Mixin

Description

A cLinkLabel object is used to add text hyperlinks to your dialogs. A single cLinkLabel control can contain a mix of text with multiple hyperlink areas. Each area is referred to as an item. The control is created by setting the Label. The control supports a pseudo HTML style of markup using the anchor tag along with an HREF or ID reference. An HREF is usually used to reference an Internet link that is accessed when the link is clicked. An ID is used to reference an ID of your choosing that will passed to an OnClick handler which you must control.


HREF Links

HREF links usually refer to an Internet link, such as:

Object oLink is a cLinkLabel
    Set Size to 14 100
    Set Location to 10 10
    Set Label to '<A HREF="http://www.DataAccess.com">Data Access Worldwide</A>'
End_Object

In the above example, the link text will be "Data Access Worldwide". When the link is clicked, a default OnClick event will be called, which will shell execute "http://www.DataAccess.com". This should load you browser and point it to "http://www.DataAccess.com".

Your HREF reference may be any string that can be shell executed. The following example would load a new email message from an email client such as Outlook.

Object oReportBugLink is a cLinkLabel
    Set Size to 8 101
    Set Location to 243 7
    Set Label to '<A HREF="mailto:support@dataaccess.com?Subject=Bug Report">Found a Bug? Report it here.</A>'
End_Object


The following would load Notepad:

Object oNotepadLink is a cLinkLabel
    Set Size to 8 101
    Set Location to 243 7
    Set Label to '<A HREF="Notepad.exe">Open Notepad</A>'
End_Object



ID Links

ID links are used when you wish to control the action of a link within a program. When an ID link is clicked, the OnClick event is called passing the ID string. It is up to you to decide how to respond to this event.

Object oLinkAbout is a cLinkLabel
    Set Size to 8 63
    Set Location to 243 250
    Set Label to '<A ID="LinkId">About this program</A>'

    Procedure OnClick Integer iItem String sID String sUrl
        Send Activate_About
    End_Procedure

End_Object

In the above example the linked text will be "About this program". When this link is clicked, OnClick is called with the "LinkId" passed in sID. Since there is only one link item, there is no need to use the sID string. Multi-items links are allowed, in which case the sID would let you know which link item was clicked.

Mixing Text and Linked Text

A Label may contain a mix of linked text and regular text. Anything that appears outside of the anchor tag is shown as regular text. In the following example the text "Found a Bug? Report it here." will appear, but only the "Report it here" section will appear as a link.

Object oReportBugLink is a cLinkLabel
    Set Size to 8 101
    Set Location to 243 7
    Set Label to 'Found a bug?<A HREF="mailto:support@dataaccess.com?Subject=Bug Report">Report it here.</A>'
End_Object


Multi Item Links

A Label may contain multiple link items. Each item has its own anchor tag. When an item link is clicked, item number and the ID or HREF for that clicked item is passed to OnClick. Normally, you will use the ID / HREF string to determine how to handle the event.

The following example has link items for saving or clearing a record.

Object oLinkLabel3 is a cLinkLabel
    Set Size to 8 59
    Set Location to 113 232
    Set Label to '<A ID="clear">Clear</A> or <A ID="save">Save</A>'

    Procedure OnClick Integer iItem String sID String sUrl
        If (sID="clear") Begin
            Send Request_Clear
        End
        Else Begin
            Send Request_Save
        End
   End_Procedure

End_Object



Auto-Height

When a link label is displayed, the height of the label will be determined automatically based on the text width. If the text is wider than the width, the height will be increased and the text will wrap. Therefore, it does not really matter what the first (size) parameter is. This can be disabled by setting the pbAutoSizeHeight to False.

Link Label Navigation

You can determine if a link label should take the focus as part of keyboard navigation by setting Skip_State. When True (the default), a link label will only take the focus when it is clicked. When False, you can navigate to the item via normal keyboard navigation.

When a link label has the focus, the pbEnterPassThrough property determines if pressing the enter key should trigger the link or if the enter key will be passed through to the parent container. By default it triggers the link.

Version Restrictions

- This control requires Windows XP or higher. If a this control is used in an earlier version of Windows, nothing is displayed and the event OnControlNotSupported is called. This could be used to report an error.
- This control is defined in the Windows ComCtl32.dll version 6 and requires a manifest or directive that specifies that version 6 of the DLL should be used if it is available.