Articles   Members Online: 3
-Article/Tip Search
-News Group Search over 21 Million news group articles.
-Delphi/Pascal
-CBuilder/C++
-C#Builder/C#
-JBuilder/Java
-Kylix
Member Area
-Home
-Account Center
-Top 10 NEW!!
-Submit Article/Tip
-Forums Upgraded!!
-My Articles
-Edit Information
-Login/Logout
-Become a Member
-Why sign up!
-Newsletter
-Chat Online!
-Indexes NEW!!
Employment
-Build your resume
-Find a job
-Post a job
-Resume Search
Contacts
-Contacts
-Feedbacks
-Link to us
-Privacy/Disclaimer
Embarcadero
Visit Embarcadero
Embarcadero Community
JEDI
Links
How to find difference between the two ENTER keys? Turn on/off line numbers in source code. Switch to Orginial background IDE or DSP color Comment or reply to this aritlce/tip for discussion. Bookmark this article to my favorite article(s). Print this article
31-Oct-03
Category
Win API
Language
Delphi 2.x
Views
111
User Rating
No Votes
# Votes
0
Replies
0
Publisher:
DSP, Administrator
Reference URL:
DKB
			 Author: Igor Siticov

How to find difference between the two ENTER keys?

Answer:

An application may find it useful to differentiate between the user pressing the 
ENTER key on the standard keyboard and the ENTER key on the numeric keypad. Either 
action creates a WM_KEYDOWN message and a WM_KEYUP message with wParam set to the 
virtual key code VK_RETURN. When the application passes these messages to 
TranslateMessage, the application receives a WM_CHAR message with wParam set to the 
corresponding ASCII code 13. 

To differentiate between the two ENTER keys, test bit 24 of lParam sent with the 
three messages listed above. Bit 24 is set to 1 if the key is an extended key; 
otherwise, bit 24 is set to 0 (zero). 

Because the keys in the numeric keypad (along with the function keys) are extended 
keys, pressing ENTER on the numeric keypad results in bit 24 of lParam being set, 
while pressing the ENTER key on  the standard keyboard results in bit 24 clear. 

The following code sample demonstrates differentiating between these two ENTER 
keys: 
1   
2   procedure TForm1.WMKeyDown(var message: TWMKeyDown);
3   begin
4     inherited;
5     case message.CharCode of
6       VK_RETURN:
7         begin // ENTER pressed
8           if (message.KeyData and $1000000 <> 0) then // Test bit 24 of lParam
9           begin
10            // ENTER on numeric keypad
11  
12          end
13          else
14          begin
15            // ENTER on the standard keyboard
16  
17          end;
18        end;
19    end;
20  end;


			
Vote: How useful do you find this Article/Tip?
Bad Excellent
1 2 3 4 5 6 7 8 9 10

 

Advertisement
Share this page
Advertisement
Download from Google

Copyright © Mendozi Enterprises LLC