473,394 Members | 1,879 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

Correct Handling of Keypresses for a Control

Hi. There are so many help offerings out there for the detection of keypresses. I would like to know what the "correct way" is to intercept a keypress for a control.

I have overidden the ProcessKeyPreview() method on a PropertGrid and I'm trying to intercept the arrows keys. Whats bugging me is that the wParam value is returning 0x25 (37) for an arrow keypress - this is the same as the ASCII % (percent) symbol.

Worse still, I also want to determine which keys are numeric, which keys are letters and which keys are printable characters in general. The % symbol is a printable character but the arrow key is not..

The other thing I feel really uncomfortable about is having to declare constants for Windows messages types such as WM_KEYDOWN, WM_CHAR etc. I would have thought that since C# is supposed to be a "nicer" language than C/C++, I shouldn't have to go browsing through winuser.h - something which I would expect to be Windows platform specific!

So.. Rather than comparing literal values for the arrow keys (which is what I've seen people offering as help to others!) .. is there a better way this can be done? In otherwords, can the wParam value of WM_KEYDOWN/WM_CHAR messages be nicely converted into a Keys.???? enumerated value?

Is anyone able to offer the world some nice code that does this?

Thanks
Sparky.
Jul 24 '07 #1
1 1233
Of course, stupid me - there isn't actually a % key anyway is there??? DOH!!! I guess the 0x25 value can be used for the left arrow key after all..
Jul 24 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

8
by: Erencans | last post by:
Hi to all, I want to error handling in ASP. But i think that ASP is not enough for error handling. I have got two chance. 1. I can prapare an error page and control throught IIS. 2. I can use on...
2
by: SMAccount | last post by:
According to Microsoft, The Page.RegisterRequiresPostBack Method "Registers a control as one that requires post-back handling." Is "post-back handling", something that the Page Does? Is...
9
by: Sridhar | last post by:
Hi, I have created a web page which includes a place holder. I also have a dropdown list in that webpage. when I select one of the choices in that dropdown list, It will load a user control...
2
by: Ian Henderson | last post by:
I am currently trying to teach myself .NET (specifically vb.NET). I have been working with VBA in Access 97 for a few years now, and consider myself to be quite proficient. At present, I have...
9
by: robert_rowe | last post by:
Does anyone know how to detect keypresses in a Datagrid cell? The Keypress event ofthe datagrid doesn't fire if you are in a cell. Neither does KeyUp & KeyDown. I've tried hooking in to the...
1
by: TheRain | last post by:
I'm working on a .NET C++ project. The program loads and creates a tray icon, but is not visible on the screen. So what I'm looking for is a way to detect when a specific key combination is...
2
by: Rob Meade | last post by:
Hi there, I have my own "way" I guess of coding, like we all do, whilst I try to maintain consistency throughout my own applications I often wonder whether there are better ways of doing...
1
by: mflll | last post by:
I am having trouble responding writing a Javascript Program respond to keypresses on top of a paragraph. Here is the code I tried: <HTML> <SCRIPT Language="JavaScript">...
8
by: BD | last post by:
How can I duplicate the behavior of the operating system shortcut keys in my application? For example, my windows form has 5 controls (textboxes), the operating system will pickup which control...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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...

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.