473,771 Members | 2,347 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Correct Handling of Keypresses for a Control

20 New Member
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 ProcessKeyPrevi ew() 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 1253
Sparky74
20 New Member
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
2259
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 error resume next. For 1. This is a general handling. I want to handle local error. Maybe i do special thing when error occured. For 2. I have to write alot of lines code. I have to control every line.
2
1204
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 "post-back handling" the process by which, the page framework searches the posted content and determines whether a posted name corresponds to the UniqueID of a server control that implements IPostBackEventHandler and if so, it invokes the...
9
2337
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 into the place holder. This is done dynamically based on the choice they selected. This user control has a datagrid in it that supports paging. When I click on the next or prev buttons of the datagrid in a user control it should display the next page...
2
8228
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 an issue with the concept of detecting keypresses. I use this frequently in Access 97, generally for giving the user an keyboard-based alternative to clicking on command buttons. For example, if I have a form where the user will be entering...
9
3809
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 DataGridCell events but it doesn't have the keypress event. Robert
1
1201
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 pressed to control when the program is brought to the screen. Anyone have a good solution for doing this??
2
1237
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 things...since I started using Visual Studio 2005 I've been quite pleased with the messages it gives you when you make mistakes, and its underlining of unused variables and so on... One thing that, not so much puzzles me, but makes me think over and...
1
1727
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"> document.write("TEeve"); function QQ(event){ alert("Key Pressed " + event.charCode()); }
8
5301
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 has the focus and handle ctrl-c, ctrl-v, or any other shortcuts. I have the same shortcuts working in my app, but have not determined how to find out which control has focus. Would I set up a loop or code for each control at form level. Any help...
0
9619
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
10260
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
10038
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
9910
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
8933
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...
1
7460
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
1
4007
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
3609
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2850
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.