Solved

Prevent Web Browser from reading Keys

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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

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…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

776 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