Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

I have a form with one button on it. I have set KeyPreview to true so that the form first recieves all the keydown messages. The problem is that the button still recieves the arrow keys!!

 

Why is that? Can it be fixed?

 

I read somewhere that that was a .net 1 bug and was fixed in 1.1 but I installed 1.1 and it does not make a difference.

C#
  • *Experts*
Posted
Could someone please translate the C# code in VB.Net code?

 

Thanks

Dan

 

Its very simple translation :):

Protected Overrides Function IsInputKey(ByVal keyData As System.Windows.Forms.Keys) As Boolean
Select case keyData
   case Keys.Up
         return True
   case Keys.Down
         return True
   case Keys.Right
         return True
   case Keys.Left
         return True
End Select
MyBase.IsInputKey(keyData)
End Function

  • *Experts*
Posted

Thanks mutant,

 

I have another thread also dealing with this. After creating this and other override events and then using the keydown and key press events...nothing happens??? I'm really stuck on this one, please help!!!

 

keypreview is set to true.

 

Thanks

Dan

Member, in good standing, of the elite fraternity of mentally challenged programmers.

 

Dolphins Software

  • Leaders
Posted

here ya go , took me a while of messing but i sussed it :)

   Private Const VK_UP As Integer = CInt(&H26)
   Private Const VK_RIGHT As Integer = CInt(&H27)
   Private Const VK_LEFT As Integer = CInt(&H25)
   Private Const VK_DOWN As Integer = CInt(&H28)


   Protected Overrides Function ProcessKeyPreview(ByRef m As System.Windows.Forms.Message) As Boolean

       Select Case m.WParam.ToInt32
           Case VK_UP
               MsgBox("up")
           Case VK_DOWN
               MsgBox("down")
           Case VK_LEFT
               MsgBox("left")
           Case VK_RIGHT
               MsgBox("right")
       End Select

   End Function

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...