Delphi Pages Forums  

Go Back   Delphi Pages Forums > Delphi Forum > General

Lost Password?

Reply
 
Thread Tools Display Modes
  #1  
Old 05-06-2001, 02:41 AM
mAsSiVe mAsSiVe is offline
Junior Member
 
Join Date: May 2001
Posts: 7
Default VK's 2 chars... Pls help

Hey everyone I need a function that converts a Win32 virtual-key code to a Delphi Char.

Thanx in advance!

Moti Zilberman
Reply With Quote
  #2  
Old 05-06-2001, 10:36 AM
VVM VVM is offline
Junior Member
 
Join Date: Jan 2001
Posts: 17
Default RE: VK's 2 chars... Pls help

If you want to catch chars in KeyDown or KeyUp
procedures you can try this:
Key type is Word and convert into char is
Char(Key). In that case instead of VK codes you will
get capital letter of pressed key. I`m using this
method. So, if you pressing "k" in procedure
KeyDown you`ll get Char(key)="K" and so on.
For letters you `ll get itselves...
Any questions send to v_matroskin@aport2000.ru
Reply With Quote
  #3  
Old 05-06-2001, 04:15 PM
DelphiFan DelphiFan is offline
Junior Member
 
Join Date: Apr 2001
Posts: 13
Default RE: VK's 2 chars... Pls help

Pretty simple since VK code are just the numeric representation of the character... simply put into code...

var
ch: Char;
begin
ch := Chr(Key); // "Key" being the var with the VK code
// check if the key is a regular character rather than
// a special key like up, down, ect
// if not in the normal character range change it to null
if not(ch in [' '..'~'] then ch:=#0;
// make sure in your code to test if ch = #0 and skip it
end;

DelphiFan
Reply With Quote
  #4  
Old 05-06-2001, 10:40 PM
Verence Verence is offline
Senior Member
 
Join Date: Feb 2001
Posts: 435
Default RE: VK's 2 chars... Pls help

Hi Moti!

If you only want to handle standard keys, you can go the way shown by VVM and DelphiFan.
If you want to get any char on your keyboard just by looking on the VK_codes, well, thats another problem...
There are:
- Key codes that are no keys : VK_LBUTTON, VK_RBUTTON ...
- Key codes that don't represent a char: VK_HOME, VK_UP ...
- chars that don't have an own key code : !"з$%&/...
- chars that are produced by more than one keystrike : рст
You have to filter out any invalid key codes, check previous pressed key codes for modifiers (VK_SHIFT, VK_MENU) and double key characters ('`','^', the key codes are OEM specific) and keep in mind the Caps Lock state (VK_CAPS).
Thats a keyboards drivers task - but if you want to do it... :-)



HTH )
Verence
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump


All times are GMT. The time now is 02:22 PM.


Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2014, vBulletin Solutions, Inc.