Slighthaze = [color blue]NULL[/color]
[img http://www.sweetpotatosoftware.com/ttimages/hyperlinks.gif]
Ever wanted to have hyperlinks on a form or in your application's About box? Well this example shows you one way to accomplish this using two ordinary labels and the ShellExecute API call (go to http://www.ml-consult.demon.co.uk/foxst-26.htm for more information on this API function). When the Email Us label is clicked it will bring up the user's default email client. When the Visit Our Website label is clicked it will bring up the user's default web browser. I have also added effects to the labels so that they act very similar to what you see on a webpage. You could use the _hyperlink.vcx to accomplish something similar to this example, but why bother? (CUT-N-PASTE the code below into a prg file and run it within VFP)
PUBLIC oForm
oForm = CREATEOBJECT("clswebemail")
oForm.show()
DEFINE CLASS clswebemail AS form
Top = 0
Left = 0
Height = 139
Width = 214
DoCreate = .T.
Caption = "FORM HYPERLINKS"
Name = "clswebemail"
Backcolor = RGB(255,255,255)
ADD OBJECT label1 AS label WITH ;
AutoSize = .T., ;
FontSize = 12, ;
FontUnderline = .T., ;
BackStyle = 0, ;
Caption = "Email Us", ;
Height = 21, ;
Left = 48, ;
Top = 36, ;
Width = 65, ;
ForeColor = RGB(0,0,255), ;
Name = "Label1"
ADD OBJECT label2 AS label WITH ;
AutoSize = .T., ;
FontSize = 12, ;
FontUnderline = .T., ;
BackStyle = 0, ;
Caption = "Visit Our Website", ;
Height = 21, ;
Left = 48, ;
Top = 72, ;
Width = 124, ;
ForeColor = RGB(0,0,255), ;
Name = "Label2"
PROCEDURE label1.Click
this.ForeColor = 8388736
this.Tag = TRANSFORM(this.ForeColor)
DECLARE integer ShellExecute IN shell32.dll ;
integer hndWin, string cAction, string cFileName, ;
string cParams, string cDir, integer nShowWin
LOCAL cEmail
*!* Replace the email addy below with a valid one
cEmail = "mailto:somewhere@somehost.com"+;
"?Subject= Testing ShellExecute For Email"+;
"&Body= Hello World!"
ShellExecute(0,"open",cEMail,"","",1)
CLEAR DLLS ShellExecute
ENDPROC
PROCEDURE label1.MouseEnter
LPARAMETERS nButton, nShift, nXCoord, nYCoord
this.Tag = TRANSFORM(this.ForeColor)
this.ForeColor = 255
DODEFAULT(nButton, nShift, nXCoord, nYCoord)
ENDPROC
PROCEDURE label1.MouseLeave
LPARAMETERS nButton, nShift, nXCoord, nYCoord
this.ForeColor = VAL(this.Tag)
DODEFAULT(nButton, nShift, nXCoord, nYCoord)
ENDPROC
PROCEDURE label2.Click
this.ForeColor = 8388736
this.Tag = TRANSFORM(this.ForeColor)
DECLARE integer ShellExecute IN shell32.dll ;
integer hndWin, string cAction, string cFileName, ;
string cParams, string cDir, integer nShowWin
LOCAL cWebsite
cWebsite = "http://www.tek-tips.com"
ShellExecute(0,"open",cWebsite,"","",1)
CLEAR DLLS ShellExecute
ENDPROC
PROCEDURE label2.MouseEnter
LPARAMETERS nButton, nShift, nXCoord, nYCoord
this.Tag = TRANSFORM(this.ForeColor)
this.ForeColor = 255
DODEFAULT(nButton, nShift, nXCoord, nYCoord)
ENDPROC
PROCEDURE label2.MouseLeave
LPARAMETERS nButton, nShift, nXCoord, nYCoord
this.ForeColor = VAL(this.Tag)
DODEFAULT(nButton, nShift, nXCoord, nYCoord)
ENDPROC
ENDDEFINE