TURLLink
Source: source/classes/urllink.prg
Inherits from: TControl
TURLLink displays a clickable hyperlink text control. When clicked, it
launches the default web browser with the specified URL. The control supports
custom colors for normal, hover, and visited states, transparent backgrounds,
and a custom bAction code block to override the default navigation behavior.
Key DATA Members
| DATA | Type | Description |
|---|---|---|
cURL | Character | The target URL to open on click |
nClrInit | Numeric | Text color in the normal (unvisited) state |
nClrOver | Numeric | Text color when the mouse hovers over the link |
nClrVisit | Numeric | Text color after the link has been clicked (visited) |
bAction | Block | Custom action block overriding default URL launch |
Methods
| Method | Description |
|---|---|
New( nTop, nLeft, oWnd, lPixel, lDesign, oFont, cMsg, cURL, cToolTip, nClrInit, nClrOver, nClrVisit, lTransp ) | Create a new TURLLink control |
ReDefine( nId, oWnd ) | Redefine from a dialog resource |
Example: URL Link with Custom Action
#include "FiveWin.ch"
function Main()
local oWnd, oLink
DEFINE WINDOW oWnd TITLE "URL Link Demo" SIZE 400, 200
@ 20, 20 URLLINK oLink ;
TEXT "Visit FiveTech Software" ;
URL "https://fivetechsoft.com" ;
COLOR CLR_BLUE, CLR_RED, CLR_HGRAY ;
TOOLTIP "Click to open website" ;
OF oWnd
// Override default browser launch with a custom action
oLink:bAction := {|| MsgInfo( "Navigating to: " + oLink:cURL ) }
ACTIVATE WINDOW oWnd CENTERED
return nil
Notes
- By default, clicking the link launches
ShellExecute( "open", cURL )to open the URL in the system default browser. - Set
bActionto override the default behavior entirely. The code block receives the TURLLink object asSelf. - The three color states (
nClrInit,nClrOver,nClrVisit) enable visual feedback as the user interacts with the link.nClrOveris typically a brighter or underlined variant. - The cursor automatically changes to a hand pointer when hovering over the link text.
- Use
ReDefine()to bind to a static text control defined in a .rc dialog resource, converting it into a clickable link at runtime. - Set
lTranspto.T.for a transparent background, allowing the link to blend into any dialog or window backdrop.