Click here to Skip to main content
15,891,708 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi All,

I am devoloping a sample MFC application which hosts a webbrowser control. I would like to disable keyboard accelerator for this webbrowser control so that backspace doesn't cause naviation back, Cntl+N doesn't open a new window etc.

I tried searching it on Google but didn't find suitable answer.

One option is to use the PreTranslateMessage and handle it. But I don't want to handle every possible key-combination and also I don't have a list of accelerator keys. Also what I have observed is even with this the logic (avoiding naviate back on backspace etc) failed on fe occasions :(

Please let me know an API or some webbrowser control setting which will disable these.


Thanks in advance.
Posted
Updated 5-Feb-12 19:48pm
v2

1 solution

This link should help you - WebBrowser Customization[^]
 
Share this answer
 
Comments
HalliHaida 6-Feb-12 1:44am    
Hi,

Thanks for the reply. I have gone through it and didn't find any API that can accomplish my requirement.
Jochen Arndt 6-Feb-12 5:13am    
The link contains a reference to the IDocHostUIHandler::TranslateAccelerator Method (http://msdn.microsoft.com/en-us/library/ie/aa753266%28v=vs.85%29.aspx) which shows an example to disable a specific accelerator key.
HalliHaida 7-Feb-12 22:38pm    
Hi,

Thanks for the information.This API will not help me in achhieving what I am looking for. I want to disable all the key accelerators and don't want to handle specific keys. Let me give an example,
If backspace is pressed then the webbrowser should not navigate back. This can be achieved by ignoring the backspace key in the above API. However, if the rendered content has a user interactive field like text box or something, then he will not be able to erase the typed characters using backspace as it is ignored in the TranslareAccelerator method. Which is not a desired behavior.
Also, with this method we need to know what all accelerator keys will have to be handled which could be a tedious task.

So I am loking for an API using which we can disable the accelerator keys that caused the webbrowser control to change its state but respond to the user interaction on an interactive content.

Please let me know.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900