473,783 Members | 2,286 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

No arrow keys ?

Rob
If I use the following code:

Private Sub Form1_KeyDown(B yVal sender As Object, _
ByVal e As System.Windows. Forms.KeyEventA rgs) _
Handles MyBase.KeyDown

Dim myKey As Integer

myKey = e.KeyValue
MsgBox(myKey.To String)

End Sub

all of my keyboard input is displayed in the MsgBox,
However if I use any of the arrow keys the KeyDown
event handler no longer works ! All keyboard input is
no longer displayed in the MsgBox and the handler no
longer works. How can I rewrite the code to handle
arrow key input. Using Microsoft Development
Environment 2002 Version 7.0.9955
Mar 24 '06 #1
5 1805
"Rob" <rl*****@worldn et.att.net> schrieb
If I use the following code:

Private Sub Form1_KeyDown(B yVal sender As Object, _
ByVal e As System.Windows. Forms.KeyEventA rgs) _
Handles MyBase.KeyDown

Dim myKey As Integer

myKey = e.KeyValue
MsgBox(myKey.To String)

End Sub

all of my keyboard input is displayed in the MsgBox,
However if I use any of the arrow keys the KeyDown
event handler no longer works ! All keyboard input is
no longer displayed in the MsgBox and the handler no
longer works. How can I rewrite the code to handle
arrow key input. Using Microsoft Development
Environment 2002 Version 7.0.9955

Are there controls on the form? Which control has the focus when you press
the arrow key?
Armin

Mar 25 '06 #2
Rob
Yes, there are 2 controls on the form. The form
contains a read only Text Box and a Button. Neither
control has a Tab stop. I want to use the
arrow keys to direct a cursor. The cursor is drawn
on the desktop by means of a C++ DLL.

"Armin Zingler" <az*******@free net.de> wrote in message
news:eA******** ******@TK2MSFTN GP12.phx.gbl...
"Rob" <rl*****@worldn et.att.net> schrieb
If I use the following code:

Private Sub Form1_KeyDown(B yVal sender As Object, _
ByVal e As System.Windows. Forms.KeyEventA rgs) _
Handles MyBase.KeyDown

Dim myKey As Integer

myKey = e.KeyValue
MsgBox(myKey.To String)

End Sub

all of my keyboard input is displayed in the MsgBox,
However if I use any of the arrow keys the KeyDown
event handler no longer works ! All keyboard input is
no longer displayed in the MsgBox and the handler no
longer works. How can I rewrite the code to handle
arrow key input. Using Microsoft Development
Environment 2002 Version 7.0.9955

Are there controls on the form? Which control has the focus when you press
the arrow key?
Armin

Mar 25 '06 #3
Hello, Rob,

That's interesting. It happens to me too. (And it clearly doesn't have
anything to do with the DLL, since I don't have this.)

I don't know if this is of any use, but I've noticed that it only
happens when the button has the focus. (It will happen continuously if
you set the TextBox's Enabled property to False, and not at all if the
Button's Enabled property is False. )

Rather mysterious. Sorry I don't know the answer -- hope someone does.

Cheers,
Randy
Rob wrote:
Yes, there are 2 controls on the form. The form
contains a read only Text Box and a Button. Neither
control has a Tab stop. I want to use the
arrow keys to direct a cursor. The cursor is drawn
on the desktop by means of a C++ DLL.

Mar 25 '06 #4
Hi there , I'm shadi
and have use you'r code the same way you write it & it worked good even
with the arrow keys
findout if there any evant depending on the arrow keys , if there any
elemantes on you form or other functions are using this keys

Mar 25 '06 #5
"Rob" <rl*****@worldn et.att.net> wrote in
news:OP******** ******@TK2MSFTN GP10.phx.gbl:
If I use the following code:

Private Sub Form1_KeyDown(B yVal sender As Object, _
ByVal e As System.Windows. Forms.KeyEventA rgs) _
Handles MyBase.KeyDown

Dim myKey As Integer

myKey = e.KeyValue
MsgBox(myKey.To String)

End Sub

all of my keyboard input is displayed in the MsgBox,
However if I use any of the arrow keys the KeyDown
event handler no longer works ! All keyboard input is
no longer displayed in the MsgBox and the handler no
longer works. How can I rewrite the code to handle
arrow key input. Using Microsoft Development
Environment 2002 Version 7.0.9955

With controls, you can get them to respond to the navigation keys by
deriving your own class and overriding IsInputKey:

Public Class Class1
Inherits Button

Protected Overrides Function IsInputKey(ByVa l keyData As
System.Windows. Forms.Keys) As Boolean
If keyData = Keys.Right Then Return True
Return MyBase.IsInputK ey(keyData)
End Function

End Class

Now, if you use a class1, it will trap the right arrow key in the keydown
event. However it won't move focus on to the next control anymore.
You can try this with a derived form, but it wont work. I'd guess that it
would break the navigation keys for all the controls on the form.

You could still trap it in a form by overriding wndproc :

Public Event RightArrowAlarm As EventHandler
Private Const VK_RIGHT = &H27
Private Const WM_KEYDOWN As Integer = &H100

Protected Overrides Sub WndProc(ByRef m As
System.Windows. Forms.Message)
If m.Msg = WM_KEYDOWN Then
If m.WParam = VK_RIGHT Then
RaiseEvent RightArrowAlarm (Me, New EventArgs)
End If
End If
MyBase.WndProc( m)
End Sub
Mar 26 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
18229
by: skipc | last post by:
Hi, I am stuck... I've got a popup window that displays a list in table format with links on the bottom to navigate the list <prev> 1 2 3 ... <next> When I demo'd to the users... they immediately asked if they could use the arrow keys and enter key to navigate the list. I think there must be a way to do this, but I can't figure it out.
2
8112
by: Darren Oakey | last post by:
ok - the problem - I made a simple breakout game out of a form, just painting the background - and using keydown for left and right arrow keys to control the bat - worked fine. I then moved all the code into a user control, put it on the form. Now I don't get keydown events when I press an arrow key - on either the form or the usercontrol ?!!!? I suspect somehow the container fucntionality has decided that they are was of migrating...
4
5889
by: Neil Wallace | last post by:
Hi there, I have an application in which a grid of 100 or more buttons are put on a form in columns of 10. All the buttons are within a panel. They are added in runtime, and so they adopt a sensible tab value. The tab key moves the focus down the column one by one, and the up and down arrow keys work well.
11
2809
by: Rlrcstr | last post by:
How can you detect when an arrow key gets pressed? Doesn't seem to trigger a KeyPress or KeyDown event. Thanks. Jerry
2
5514
by: Vincent | last post by:
Hi, I have a user control that needs to trap the arrow keys to move items around internally. However, using the arrow keys will move the focus to another control on the form hosting the user control. How do I stop this? Vincent.
1
10155
by: Martijn Mulder | last post by:
/* I have problems detecting the Arrow Keys on a User Control. A control derived from System.Windows.Forms.Control neglects 'bare' Arrow Keys but does react on the combination <Altor <Ctrl+ Arrow Key. The code below shows what I mean. How can I cure this? (excuse me for the line breaks) */
0
2922
by: Martijn Mulder | last post by:
/* I override IsInputKey() to direct the Arrow Keys (Cursor Keys) to my custom System.Windows.Forms.Control. But, holding down the Shift-Key prevents the Arrow Keys from coming through. How can I intercept the Arrow Keys when holding down the Shift Key? */
4
3294
by: boopsboops | last post by:
Hi thescripts people, I hope I'm in the right forum for Visual Basic Dotnet (VS 2005). I am trying to make a custom control in which you can nudge a point around using the arrow keys. Actually, the control is meant to be a simple drawing program. To test it out I have put the control on a Windows form which also contains several buttons. I have added a KeyDown event handler to the custom control (see code below). It responds fine to keys...
2
3324
by: Charles Law | last post by:
I'll kick myself when you tell me, but ... I have a user control on a form, and I want the user control to see the arrow keys when I press them. If I press just about any other key the control's KeyDown event is fired, but not when I press a direction key. I want to see them in the KeyDown event so that I can respond as soon as the key is depressed, and I want to detect when the key is held down so that I can perform an action...
4
6283
by: beary | last post by:
Hi Being tested using FF 3 on WAMP server. I have spent a number of hours trying to figure this out myself. I have a html form using table cells and had a request to enable the arrow keys on a keyboard to move through the cells. I found some code and adapted it, and it works well now. Arrow keys move the cursor exactly to the correct cell. There are two things I can't do which I was hoping you guys would give me some help on. I am a...
0
9643
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10315
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10083
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9946
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8968
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5511
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4044
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3645
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2877
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.