Solved

Prevent Web Browser from reading Keys

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
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…
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…

911 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

16 Experts available now in Live!

Get 1:1 Help Now