Doh!
ProcessDialogKey should return a True if it processed the key.
| Protected Overrides Function ProcessDialogKey(ByVal keyData As
| System.Windows.Forms.Keys) As Boolean
| Dim offset As Point
| Select Case keyData
| Case Keys.Left
| offset = New Point(-1, 0)
| Case Keys.Right
| offset = New Point(1, 0)
| Case Keys.Up
| offset = New Point(0, -1)
| Case Keys.Down
| offset = New Point(0, 1)
| Case Else
| Return MyBase.ProcessDialogKey(keyData)
| End Select
| Me.PictureBox1.Location = New Point(Me.PictureBox1.Location.X +
| offset.X, Me.PictureBox1.Location.Y + offset.Y)
Return True
| End Function
Jay
| Jay,
| Image.Position is a structure you need to change the entire structure.
|
| Something like:
|
| Protected Overrides Function IsInputKey(ByVal keyData As
| System.Windows.Forms.Keys) As Boolean
| Select Case keyData
| Case Keys.Left, Keys.Right, Keys.Up, Keys.Down
| Return False
| Case Else
| Return MyBase.IsInputKey(keyData)
| End Select
| End Function
|
| Protected Overrides Function ProcessDialogKey(ByVal keyData As
| System.Windows.Forms.Keys) As Boolean
| Dim offset As Point
| Select Case keyData
| Case Keys.Left
| offset = New Point(-1, 0)
| Case Keys.Right
| offset = New Point(1, 0)
| Case Keys.Up
| offset = New Point(0, -1)
| Case Keys.Down
| offset = New Point(0, 1)
| Case Else
| Return MyBase.ProcessDialogKey(keyData)
| End Select
| Me.PictureBox1.Location = New Point(Me.PictureBox1.Location.X +
| offset.X, Me.PictureBox1.Location.Y + offset.Y)
| End Function
|
| The above was tested in a Form with KeyPreview=True. I would also expect
the
| above to work within a custom control itself.
|
| NOTE: Left, Right, Up, & Down are normally not input keys, so the
IsInputKey
| override is not specifically needed...
|
| Hope this helps
| Jay
|
| ||I am trying to code an application that will move a image around the
screen
|| depending on what arrow keys the user presses. If the user presses the
up
|| key, the graphic will move up a few positions, and so on. I was
wondering
|| how I would move the image though, it seems that when I try to change the
| X
|| and Y values in the position property, nothing happenes. I must be
| changing
|| the wrong property, but I don't know where to find the one that needs to
|| change. Thanks
|
|