Solved

Prevent Web Browser from reading Keys

Posted on 1999-01-17
2
267 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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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…

685 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