Solved

Prevent Web Browser from reading Keys

Posted on 1999-01-17
2
261 Views
Last Modified: 2008-02-01

How do you prevent the Vb6 Web Browser Control from
reading key input such as the Backspace Key.

It is very annoying to see the Web Browser Control
go Back when all I want to do is delete a Character in
a ComboBox.

Do let the above explanation fool you, my combobox is
located on the MDI itself,
the Child would be the WebBrowser.

So, does anyone have a good work around or tip that could
prevent the WebBrowser from reading the BackSpace key?

Thanks a million.
0
Comment
Question by:vienna
2 Comments
 

Accepted Solution

by:
MrOBrian earned 30 total points
ID: 1469064
I am doing something similar, here is what I have done to disable keys:
Dim WithEvents WinDoc As HTMLDocument
Private Sub WebMain_NavigateComplete2(ByVal pDisp As Object, URL As Variant)
  Set WinDoc = pDisp.Document
End Sub
Private Sub WinDoc_onkeydown()
Dim Cancel As Boolean
Cancel = False
With WinDoc.parentWindow.event
 If .ctrlKey Then 'Ctrl+
  If .KeyCode = 78 Then Cancel = True 'N
  If .KeyCode = 79 Then Cancel = True 'O
 End If
 If .KeyCode = 116 Then Cancel = True 'F5
 If .KeyCode = 8 Then Cancel = True 'Backspace
 
 If Cancel Then
  .cancelBubble = True
  .KeyCode = 0
 End If
End With
End Sub

In summary, I have a Web Control named WebMain, when it is done navigating to a site, the document is set to WinDoc.  The above code disables Backspace, F5, Ctrl+N, and Ctrl+0 (Back, Refresh, New Window, Open URL).  Hope this helps!
0
 

Author Comment

by:vienna
ID: 1469065

Would you kindly tell me what references you have inserted into your project
to get ... WinDoc As HTMLDocument?


0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now