I was wondered about, how to place a website hyperlink in a program.
I searched a lot on the internet but I didn't get it.
The following format was expected by me .
"Created by SACHIN",
where clicking on "SACHIN" would launch the system's default browser and open http://softbysachin.blogspot.com
OR
"Created by sd0389@gmail.com",
where clicking on the e-mail address would launch the system's default mail client such as Outlook etc.
Then I remembered the shellexecute function which we normally use in Autorun CDs. I searched on internet about shellexecute function, and then I got the library in which the function was located and that was shell32.dll.
Then I declared a private function in the program as follows :
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
This function would declare the shell32.dll in the program.
Then I just used shellexecute function as follows in menu.(But you can use it anywhere in the program such as in a button or a picture etc.)
Private Sub Website_Click()
ShellExecute Me.hwnd, "open", "http://softbysachin.blogspot.com/", vbNullString, "", 0
End Sub
That's all,
when you click on the desired button, or text link then the new browser window will open and the desired website will load in it.
Comments
Post a Comment