Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

Well i'm new on this and i'm trying to now how to cath the cursor keys on the Overrides Sub OnKeyPress

 

i'm using this code

 

       If e.KeyChar = Microsoft.VisualBasic.ChrW(13) Then

           abol_x = bol_x
           bol_x += 10
           mov_bola()
           e.Handled = True
       End If

 

the problem is to now what are the keycodes of the cursor keys,

 

if the Overrides sub OnKeyPress is not a good idea I'm open to sugestions.

 

Thanks in advance

Posted

you could try with

 

If e.KeyChar = Keys.Down Then '' or Keys.Enter or Keys.Something

           abol_x = bol_x
           bol_x += 10
           mov_bola()
           e.Handled = True
       End If

 

:D

Some people are wise and some are other-wise.
Posted

Well that tip was fantastic!:D the only problem is the ball doesn't move... :confused: but I belive that is becouse I'm design the ball insede a picturebox like this code show:

 

bolinha.grafic = Me.campo.CreateGraphics

bolinha is the object

campo is the name of my picture box

 

I'm don´t use the Overrides Sub OnPaint becouse the program seams to freeze and over the form is always the mouse show the hand icon. That the reason why I'm use the picture box and to start the drawing I'm click a buton, I'm guess that all that is rigth.

 

Thanks

Posted

The code above is not quite good!! :(

 

try with this code

 

If e.KeyChar = Convert.ToChar (Keys.Down) Then 
           abol_x = bol_x
           bol_x += 10
           mov_bola()
           e.Handled = True
       End If

:D

Some people are wise and some are other-wise.
Posted

thanks sizer!

well the code don't work but in other post i'm fond this:

this is function that returns value ( bool )

try with this:



VB:
--------------------------------------------------------------------------------
Protected Overrides Function ProcessKeyPreview(ByRef m As System.Windows.Forms.Message) As Boolean
     If m.WParam.ToInt32 = Keys.Up Then
           'whatever the code is
     End If
Return True
End Function

and was the solution to my prob too :D

 

Thanks a lot!!!!

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...