The Hyperlink control (HyperLink) is not as common as a text box, command button, and so on, and is typically used when making a "about" form of a software. The most common method for this control is NavigateTo (specifying the URL to be opened), which is an example of this control, run as follows:
In the figure above:
Clicking on the Blue Label text opens the program starter network directly;
When you click the About this Site button, the API function is used to invoke the "about" form of the Windows system (used in the FOXTOOLS.FLL library, which is available in the source code).
Click the link below "about this site", you can open the corresponding Web site.
In addition, the hyperlink control in this example is added with the AddObject function when the form is init, and the list items in the list box are added to this event. Of course, you can set it in the form designer at design time, and if you do this, you have to remove the corresponding code from the form Init event.
The production steps are as follows:
A new form, set its AutoCenter property value to. T, and save it as "form 1.scx".
Add a Label control to the form the Label1,caption property value is set to programming getting Started network, and the FontBold property value is set to the. T.,fontsize property value set to 12,forcolor property value to "0,0,255" (RGB color).
Third, add a command button control to the form Command1,caption property value to "about this site."
Add a Label control to the form the Label2,caption property value is set to "access the specified Web site."
Add a list box control List1 to the form with its default property value.
Six, adjust the control, size and position on the form, the form designer is as follows:
Vii. Add event code:
1, the form's Load event code:
Declare integer shellabout in Shell32.dll long hwnd,string szapp,string szotherstuff;
Long Hicon && declaring API functions
Set Library to "FOXTOOLS.FLL" && loading VFP FLL Library
2, the form of the Init event code:
This. AddObject ("Hyperlink1", "HyperLink")
&& This is added, if you want to remove it later available removeobject ("Hyperlink1")
This.list1.additem ("MSDN")
This.list1.additem ("CSDN")
This.list1.additem ("Yesky")
This.list1.additem ("Little Bird")
3, "Programming Getting Started Network" label Label1 Click event Code: THISFORM. Hyperlink1.navigateto ("www.bianceng.cn")
4, "About this Site" command button Command1 Click event Code:
Hwnd=_whtohwnd (_wontop ())
=shellabout (HWnd, "Getting Started with programming web", "Welcome to the website:", 0)
5, List box control List1 Click event code:
Do case This.listindex case
this.selected (1) && visit Microsoft MSDN Home
thisform. Hyperlink1.navigateto ("msdn.microsoft.com") Case
this.selected (2) && visit csdn website
thisform. Hyperlink1.navigateto ("www.csdn.net") Case
this.selected (3) && access Pole
thisform. Hyperlink1.navigateto ("www.yesky.com") Case
this.selected (4) && access to Programming starter Network
thisform. Hyperlink1.navigateto ("www.bianceng.cn")
endcase
Eight, run "form 1.scx".
This example code is debugged in the win2003+vfp6.0 environment.
See the full set of "rookie also learn VFP" tutorial