Weblink ActiveX
Learn to make a WebLink ActiveX control using Visual Basic 6 with this Tutorial that Celebrates the CESPage 25th Anniversary
This is a simple program, which will introduce you to ActiveX Controls, Functions, Properties, Methods and the Win32 API.
Step 1
Step 2
Step 3
Step 4
Step 5
Name
of Label1
to lblWeblink
and the Caption
to Weblink Control
Step 6
Step 7
Step 8
Step 9
Step 10
Location
and select the Property Option from the Type Radio Buttons and Click on Ok
Step 11
lblWeblink
for all Properties/Events/Methods except the Location
Property
Step 12
String
and type in a
meaningful Description
Step 13
Click on Next and then Finish to create the items selected in the Wizard a Summary Report will also be created, it is recommended that you read this for extra ActiveX information
Step 14
Double Click on the UserControl and at the bottom of the General Declarations Section type in:
Private Declare Function ShellExecute Lib "shell32.dll" Alias
"ShellExecuteA" (ByVal hWnd As Long, ByVal lpOperation As String, ByVal
lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String,
ByVal nShowCmd As Long) As Long
Public Function HyperJump(ByVal URL As String) As Long
On Error Resume Next
HyperJump = ShellExecute(0&, vbNullString, URL, vbNullString, vbNullString, vbNormalFocus)
End Function
Step 15
Double Click on the UserControl and type in the UserControl_Resize
Sub:
' Move to 0,0 and resize lblWeblink to control size
lblWeblink.Top = 0
lblWeblink.Left = 0
lblWeblink.Width = UserControl.Width
lblWeblink.Height = UserControl.Height
lblWeblink.FontUnderline = True
Step 16
Double Click on the Label for Weblink Control or lblWeblink
and type in the cmdWeblink_Click()
Sub (remove the RaiseEvent Click
line)
HyperJump (m_Location)
Step 17
Step 18
Step 19
Step 20
Step 21
Double Click on the Form of Form1
and type in the Form_Load()
Sub:
Weblink1.Caption = "Windows Folder"
Weblink1.ForeColor = vbBlue
Weblink1.Location = "file://c:\windows"
Step 22
Step 23
Location
property is set to
To Exit the application, Click the X button on the
Top Right of the Form or End / Stop
You have just created a simple Weblink ActiveX control using the Interface Wizard and
Win32 API. Try adding extra Properties such as FontUnderline
and see what else you can achieve with this program.