473,396 Members | 1,998 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Let arrow keys work on WebBrowser Control & catch Esc, F11, & F5 (Fullscreen/Refresh)

DTeCH
23
Hello all :)


A strange feature of the MS WebBrowser Control showed it's head, & I tried figuring it out on my own, but it's stressful enough already without me having to go another week trying to make it work.


My problem is, I made a Win Forms app that loads a site's Flash game into it (many servers, & all live players). Now, when I load it up, it works fine... except it's not playable because the arrow keys are REQUIRED, but not working, & no matter how many times you press them, NOTHING happens in the game.

I have the following to catch the Esc, F11, & F5 keys:

Expand|Select|Wrap|Line Numbers
  1.     Private Sub AxWebBrowser1_PreviewKeyDown(sender As Object, e As System.Windows.Forms.PreviewKeyDownEventArgs) Handles AxWebBrowser1.PreviewKeyDown
  2.         F11_Pressed = True
  3.  
  4.         'Arrow Keys (Up, Down, Left, & Right)
  5.         If (e.KeyCode = 37 Or e.KeyCode = 38 Or e.KeyCode = 39 Or e.KeyCode = 40) = True Then Exit Sub
  6.         Try
  7.             'F11, or Esc key (Exit FullScreen)
  8.             If Me.WindowState = FormWindowState.Maximized And (e.KeyCode = 122 Or e.KeyCode = 27) Then 
  9.  
  10.                 Me.WindowState = FormWindowState.Normal
  11.                 Me.Width = Me_Width
  12.                 Me.Height = Me_Height
  13.                 Me.ControlBox = True
  14.                 StatusStrip1.Visible = True
  15.                 Me.FormBorderStyle = 4
  16.                 MenuStrip1.Visible = True
  17.                 Me.CenterToScreen()
  18.  
  19.             'F11 key (FullScreen)
  20.             ElseIf Me.WindowState = FormWindowState.Normal And e.KeyCode = 122 Then
  21.  
  22.                 Me_Width = Me.Width
  23.                 Me_Height = Me.Height
  24.                 Me.WindowState = FormWindowState.Maximized
  25.                 Me.ControlBox = False
  26.                 StatusStrip1.Visible = False
  27.                 Me.FormBorderStyle = 0
  28.                 MenuStrip1.Visible = False
  29.  
  30.             'F5 key (Refresh)
  31.             ElseIf e.KeyCode = 116 Then
  32.  
  33.                 Application.DoEvents()
  34.                 AxWebBrowser1.Refresh()
  35.  
  36.             Else
  37.  
  38.             End If
  39.         Catch ex As Exception
  40.  
  41.         End Try
  42.     End Sub
  43.  
  44.  
They work as expected, but the Arrow keys are not being received/handled by the WebBrowser control... although it does send them in the PreviewKeyDown event. The WebBrowser control is just ignoring their actions, yet everything else works just fine.


I DO NOT want to mess with the DOM of the page (don't see why we even need to :)), or other things because that WILL get the user banned.




UPDATE:

I figured it out guys.

I changed the above code from:

Expand|Select|Wrap|Line Numbers
  1.  
  2.         'Arrow Keys (Up, Down, Left, & Right)
  3.         If (e.KeyCode = 37 Or e.KeyCode = 38 Or e.KeyCode = 39 Or e.KeyCode = 40) = True Then Exit Sub
  4.  
  5.  
To:
Expand|Select|Wrap|Line Numbers
  1.  
  2.         'Arrow Keys (Up, Down, Left, & Right)
  3.         If (e.KeyCode = 37 Or e.KeyCode = 38 Or e.KeyCode = 39 Or e.KeyCode = 40) = True Then
  4.             e.IsInputKey = True
  5.             Exit Sub
  6.         End If
  7.  
  8.  
It did the trick :)
Jul 15 '12 #1

✓ answered by DTeCH

SOLVED :)

I love this place! lol

1 4743
DTeCH
23
SOLVED :)

I love this place! lol
Jul 15 '12 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Darren Oakey | last post by:
ok - the problem - I made a simple breakout game out of a form, just painting the background - and using keydown for left and right arrow keys to control the bat - worked fine. I then moved all...
1
by: bj | last post by:
How to process arrow keys? Hello I need to catch arrow keys down event from control derivied from usercontrol -OnKeyDown method seems to work for all keys besides arrow keys -however OnKeyUp...
4
by: Neil Wallace | last post by:
Hi there, I have an application in which a grid of 100 or more buttons are put on a form in columns of 10. All the buttons are within a panel. They are added in runtime, and so they adopt a...
11
by: Rlrcstr | last post by:
How can you detect when an arrow key gets pressed? Doesn't seem to trigger a KeyPress or KeyDown event. Thanks. Jerry
6
by: Shane Story | last post by:
I am trying to add the Microsoft Web Browseractive X control to a vb.net form. I always get an error on the EndInit line. Parts of the errors says: "Unknown error" "First Chance...
2
by: Vincent | last post by:
Hi, I have a user control that needs to trap the arrow keys to move items around internally. However, using the arrow keys will move the focus to another control on the form hosting the user...
1
by: Martijn Mulder | last post by:
/* I have problems detecting the Arrow Keys on a User Control. A control derived from System.Windows.Forms.Control neglects 'bare' Arrow Keys but does react on the combination <Altor <Ctrl+ Arrow...
4
by: boopsboops | last post by:
Hi thescripts people, I hope I'm in the right forum for Visual Basic Dotnet (VS 2005). I am trying to make a custom control in which you can nudge a point around using the arrow keys. Actually,...
1
by: JP2006 | last post by:
I'm trying to write a control that will take a screen capture of a particular website when a user submits a form in a web application; one of the form fields is for a URL - the control needs to get...
4
by: David | last post by:
I'm using the AxSHDocVw.WebBrowser control to download data from a webpage at work (it's an internal page on my company's intranet). The page produces a runtime error after a while and the...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.