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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Disable IE navigation sounds programmatically

Status
Not open for further replies.

teriviret

Programmer
Dec 12, 2003
288
US
I'm learning today how to reuse Internet Explorer's browser control (CLSID_WebBrowser) in my own application. I'm following the example from MSDN here.

My problem is, I don't like the "navigate sound", the annoying click sound file, that is played whenever you click on a hyperlink. I don't want the users of my application to hear it in my app. On the other hand, I don't like the idea of hacking their registry programmatically to disable the sound. What if they really do want to hear the sound when using Internet Explorer itself outside my app? I really don't want to annoy users by changing their preferences set for other apps.

I know how to use the control panel or registry editor to disable it on my computer globally for all IE instances, but is there a better way to disable it from my application, temporarily, so it is just disabled for my application and not for Internet Explorer itself, or other apps like mine that reuse the IE browser control?

I'd rather not hack the registry setting temporarily and then have to restore it later. I'd prefer some interface method that disables the sound just for one instance of the control. However, I can't find anything in IWebBrowser2 or related interfaces that will accomplish this. Any ideas?
 
>I don't like ...
Then configure it away in the Control Panel.

>What if they really do want to hear
Then "they" dont configure it away.

> I know how to use the control panel...but is there a better way to disable it from my application

Look at it this way:
With the control panel the user can configure how he want the system to behave. You app should follow that, and not try to be overly clever like "I know you configured to hear clicks but I think you dont want to hear them anyway".

Imagine the other way around - you disable the sound in control panel, but some app thinks it knows better and make all sort of clicking sounds...how annoying would that be on a scale 1-10?

/Per
[sub]
"It was a work of art, flawless, sublime. A triumph equaled only by its monumental failure."[/sub]
 
Okay, maybe if I explain what I'm trying to do with the web browser component, it would make more sense.

I'm writing a role-playing game, where the player program has three views -- world overhead view, command/text view, and general status view. The general status view, I was thinking, would be nice if I could show a mixture of text and graphics, and have it generated by the game engine on the fly.

I figured, text and graphics -- hey, why not use HTML? I can have the game engine generate HTML on the fly and send it to an HTML renderer. Guess what -- Internet Explorer is an HTML renderer, and not only that, I can embed it in my application since it is also an OLE control. Sweet!

So anyway, I got my game's general status view to host a web browser control. I also created a pluggable protocol handler, to construct URLs like "mygame://abc/123" and have another part of the game engine get called back to provide data (through the IInternetProtocol interface) rather than go to files or the network like a web browser normally does. Excellent!

The only problem is, I have to tell my users that my game engine uses Internet Explorer, and to get rid of the annoying "click" sounds whenever the game engine updates the game status or the user clicks a link on the game status automatic content, they have to go into the Control Panel and disable the navigate sound globally for all instances of Internet Explorer!!.

Now in a normal web browsing mode, perhaps the user likes to hear the "click" when they click on a link. But since my game will most likely force a refresh every second or so, perhaps even more often, they're going to hear a lot of "clicks" and won't understand why. After all, they're not browsing the web, they're playing a game!

I'm reusing the web browser component, but not to browse the web. "Links" on the page have a whole different meaning. They might cause different game functions to open up, or maybe issue the game engine some commands or something. I want the ability to have hyperlinks and HTML rendering, without the "IE sound effects".

Do you see my dilemna here? I don't want my users to even know that I'm using Internet Explorer in the first place, let alone make them change their web browser preferences just to play my game.
 
Ah, yes, that makes perfect sense. Too bad I cant help you further though...

/Per
[sub]
"It was a work of art, flawless, sublime. A triumph equaled only by its monumental failure."[/sub]
 
If you're using the JavaScript onclick event from your <A> elements, just add a return false; statement at the end of the event handler. <a href="#" onclick="doSomething()">GO</a> would become <a href="#" onclick="doSomething();return false;">GO</a>.

If you're using traditional links, you may try rewriting them using JavaScript. (I've never tried this.) Try <a href="#" onclick="window.navigate('index.html');return false;">HOME</a> instead of <a href="index.html">HOME</a>
 
Thanks, but that didn't seem to work. I still get the click sound. I think I'll just have to ask users to disable it in the control panel if they don't like it.

On the other hand, it did solve another problem I ran into, where users could open up new windows by shift-clicking. Turning the links into JavaScript successfully disables it -- hooray!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top