How to put a Hyperlink into a form component

Tony Marston - 26th December 2002

This tip has been tested with UNIFACE 7.2.06 and Windows ME.

I have seen various postings in the UNIFACE newsgroup recently about problems encountered when using an OCX container widget to insert a hyperlink into a form component. I have achieved the desired result not by using an OCX container but by using the Windows ShellExecute API instead. Here are the steps that I used:

1. Create form field

On the relevant form component create your hyperlink as follows:

Set the value of the field to the desired web address. Note that it must be prefixed with 'http://', as in http://www.compuware.com.

Insert the following proc code into the field's <detail> trigger:

activate "WinAPI".shellexecute(0,"",@$fieldname,"","",1)

When the user double-clicks on this field it will pass the field contents to the Windows ShellExecute API. This will recognise the 'http://' prefix and use this to identify the default web browser in the current system as defined in the Windows registry. It will then activate that web browser using the full web address.

2. Create signature for SHELLEXECUTE

In order to create the "WinAPI" signature with an operation named "SHELLEXECUTE" you must do the following with the signature editor:

The SHELLEXECUTE operation requires the following parameters:

This signature requires access to file SHELL32.DLL at runtime, so put the following into your USYS.INI file:

[userdlls]
demandload=C:\WINDOWS\SYSTEM\SHELL32.DLL

Happy browsing!


Tony Marston
26th December 2002

mailto:tony@tonymarston.net
mailto:TonyMarston@hotmail.com
http://www.tonymarston.net

counter