Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Adding a weblink to the menu

Status
Not open for further replies.
Jan 10, 2001
2,873
US
I have an application I am attempting to write. I am finishing the About page and am running into an issue. In the menu I want to add a link to a support website. The menu editor allows me to create the button, however I am not sure where to begin t owrite code to send a user to that address when they cick on the button. ANy suggestions?

James Collins
Systems Analyst
A+, MCP, MCSA, Network+
 
Yep!
You just have to use ShellExecute API call with your URL in the click event of the menu option you desire. Thet's all.

Example:

ShellExecute(NULL, "open", " NULL,SW_SHOWNORMAL)

OK. You have to declare the function first:

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

Hope I've been helpful,
Bogdan Muresan.
 
This will open Mozilla and send the browser to Tek-Tips:

Code:
Shell "D:\Program Files\mozilla.org\Mozilla\mozilla.exe [URL unfurl="true"]http://www.tek-tips.com",[/URL] vbMaximizedFocus

This will open Internet Exploder and send the browser to Tek-Tips:
Code:
Shell "D:\Program Files\Internet Explorer\IEXPLORE.EXE [URL unfurl="true"]http://www.tek-tips.com",[/URL] vbMaximizedFocus

Note that there is a space between the executable and the url.

Note also that you will probably need to change the path to the executable for this to work correctly. Also, different users will probably have different paths, so you will need to deal with that in some way (perhaps by looking up registry keys...). But this is how to open a browser window with the site you want.

I used to rock and roll every night and party every day. Then it was every other day. Now I'm lucky if I can find 30 minutes a week in which to get funky. - Homer Simpson
 
I have a Sub which I use for opening all sorts of different docs:
Code:
Public Sub OpenDocument(DocumentWithPath As String)
    Shell "RUNDLL32.EXE URL.DLL, FileProtocolHandler " & DocumentWithPath, vbNormalFocus
End Sub

For a website use:
Code:
OpenDocument "www.essexsteam.co.uk"

For a Word doc (for instance)
Code:
 OpenDocument "c:\mydoc.doc"

It also works with all other registered file types

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

'If we're supposed to work in Hex, why have we only got A fingers?'

for steam enthusiasts
 
Surely jebenson's code has a flaw in that it assumes to know where the browser is installed and which browser it is? Using ShellExecute is definitely the best option because it works on the Windows association between the file extension and the type of file you're trying to open.

Eg.
XLS -> Excel
DOC -> Word
HTM -> Browser etc.


- Andy
___________________________________________________________________
If you think nobody cares you're alive, try missing a couple of mortgage payments
 
How about adding a real hyperlink in the menu, which will be underlined and changes color on mouseover. Is it possible?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top