INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

API Functions

Email/Website Hyperlinks on a Form by craigsboyd
Posted: 13 Jul 03 (Edited 18 Feb 05)

Slighthaze = NULL

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

Back to Microsoft: Visual FoxPro FAQ Index
Back to Microsoft: Visual FoxPro Forum

My Archive

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close