HOW TO

Hotlink to a Web page

Procedure

Question:

How can I hotlink to a Web page in ArcView GIS?

Answer:

The following script will enable you to hotlink to a user-specified URL. It also serves as an example of how you can use Windows API functions from ArcView.

As with other hotlinking functionality provided with ArcView, feature theme tables will contain a hotlink field. In this case, the value of the field will be a URL.
How to set up your project:

1. Add a new field to the feature theme from which you want to hotlink. For this example, call the field "Hotlink".

2. Edit this field for each record in the table, entering the associated URL for that feature. (e.g., "http://www.esri.com", without the quotes)

3. Enter the script below into a new Script Editor window and compile it. Use the "Script | Properties..." menu item to give the script an appropriate name. For this example, call the script "Link.Web".

4. Open the Theme Properties dialog for your theme and click on the Hotlink icon.

5. Enter the appropriate information:

Field: Hotlink
Predefined Action: Link to User Script
Script: Link.Web

6. Click OK to dismiss the Theme Properties dialog box.

7. With the View as the active window and your theme active, select the hotlink tool (lightning bolt) and click on a feature.

How it works:

The \'"ShellExecuteA' Windows API function does all the work. If there is currently a Web browser open, it will pass the URL string to it, sending the Web browser to that site. Otherwise, the function will startup the default browser on your computer, then pass the URL to it.

'--------------------------------
'Script: "Link.Web" (Windows95/NT Only)
'
'Setup DLL file objects.
if (System.GetOSVariant = #SYSTEM_OSVARIANT_MSWNT) then
dllShell32 =
DLL.Make("C:\winnt\system32\shell32.dll".AsFileName)
dllUser32 =
DLL.Make("C:\winnt\system32\user32.dll".AsFileName)
ElseIf (System.GetOSVariant = #SYSTEM_OSVARIANT_MSW95) then
dllShell32 =
DLL.Make("C:\windows\system\shell32.dll".AsFileName)
dllUser32 =
DLL.Make("C:\windows\system\user32.dll".AsFileName)
Else
MsgBox.Warning("Required DLL files cannot be found.", "Stop")
return nil
End
'
'Setup Win32API functions as Avenue DLLProc objects
dpGetActiveWindow =
DLLProc.Make(dllUser32, "GetActiveWindow",
#DLLPROC_TYPE_INT32, 'return value type
{} 'argument list
)
'
dpShellExecute =
DLLProc.Make(dllShell32, "ShellExecuteA",
#DLLPROC_TYPE_INT32, 'return value type
{#DLLPROC_TYPE_INT32, 'argument list
#DLLPROC_TYPE_STR,
#DLLPROC_TYPE_STR,
#DLLPROC_TYPE_STR,
#DLLPROC_TYPE_STR,
#DLLPROC_TYPE_INT32}
)
'
'Get the Window Handle (hWnd) of the ArcView window.
hWnd_active = dpGetActiveWindow.Call({})
'''or-> hWnd_active = DLL.GetAVWindowHandle
'
'Get the WWW URL for Hotlinking from the active
'theme's hotlink field.
hotlinkVal = SELF
'
'Send the URL to the default browser

retValue = dpShellExecute.Call({hWnd_active, "Open", hotlinkVal,
"", FileName.GetCWD.AsString, 1})
'
'Let the user know if the link failed. The "ShellExecuteA"
'function returns an integer greater than 32 if the process
'succeeded.
if (retValue <= 32) then
MsgBox.Warning("Hotlink to Web failed.","Sorry")
End
'
'End of Script: "HotlinkToWeb.ave"
'--------------------------------

Article ID:000001546

Software:
  • Legacy Products

Get help from ArcGIS experts

Contact technical support

Download the Esri Support App

Go to download options

Related Information

Discover more on this topic