PDA

Click to See Complete Forum and Search --> : Keydown Doesn't Work With WebBrowser Control on Form?


SteveCRM
Nov 16th, 1999, 02:59 AM
I am making a game where there is an animation, but now the hero won't walk! :( (the hero is not the animation) How can I make him move while having the webbrowser control on my form?(i'm using the webbrowser control to load an animated gif)

Thanks A Bunch!
Steve

Aaron Young
Nov 16th, 1999, 03:14 AM
Try using the GetAsyncKeyState API with a Timer Control, eg.

Private Declare Function GetAsyncKeyState Lib "user32" (ByVal vKey As Long) As Integer
Private Declare Function GetActiveWindow Lib "user32" () As Long

Private Sub Form_Load()
Timer1.Interval = 100
End Sub

Private Sub Timer1_Timer()
'Only Move if your Form is Active
If GetActiveWindow <> hWnd Then Exit Sub
If GetAsyncKeyState(vbKeyLeft) Then
Caption = "Moving Left"
WebBrowser1.Left = WebBrowser1.Left - 100
ElseIf GetAsyncKeyState(vbKeyRight) Then
Caption = "Moving Right"
WebBrowser1.Left = WebBrowser1.Left + 100
End If
End Sub



------------------
Aaron Young
Analyst Programmer
aarony@redwingsoftware.com
adyoung@win.bright.net