Beijufas Posted November 12, 2003 Posted November 12, 2003 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 Quote
Administrators PlausiblyDamp Posted November 12, 2003 Administrators Posted November 12, 2003 Try either the KeyUp or KeyDown events - they give you access to the KeyCodes. Quote Posting Guidelines FAQ Post Formatting Intellectuals solve problems; geniuses prevent them. -- Albert Einstein
sizer Posted November 12, 2003 Posted November 12, 2003 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 Quote Some people are wise and some are other-wise.
Beijufas Posted November 12, 2003 Author Posted November 12, 2003 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 Quote
sizer Posted November 12, 2003 Posted November 12, 2003 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 Quote Some people are wise and some are other-wise.
Beijufas Posted November 13, 2003 Author Posted November 13, 2003 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!!!! Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.