Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 272
  • Last Modified:

Prevent Web Browser from reading Keys


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
vienna
Asked:
vienna
1 Solution
 
MrOBrianCommented:
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
 
viennaAuthor Commented:

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


0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now