Wednesday, December 17, 2008

[vb6] Go to web page or send an e-mail

It is very simple to enable links to web pages in your application or have the user send you an e-mail by clicking on your e-mail address, displayed in a label, for example. Just call the DoWebLink sub below, passing the startup form of your app and a link. The link may be a web-link, like http://www.santa-claus.gl/ or a mail address, like "mailto:SantaClaus@Santaorg.gl". You can make the link more browser-like by displaying it in a blue color and display the hand cursor when the mouse is hovering over it. The cursor can be found under the name h_point.cur on your VB CD-rom.
    Private Const SW_SHOWNORMAL& = 1
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)

Public Sub DoWebLink(MainForm As Form, sLink As String)
Dim r As Long
If 33 > ShellExecute(MainForm.hwnd, "open", sLink, vbNullString, _
vbNullString, SW_SHOWNORMAL) Then
'raise an error
End If
End Sub

No comments:

Post a Comment