Delphi32.com - Home!
| Home/News | Downloads | Forums | D32 Magazine | Resources | Info and Facts |  
 
 Sending keystroke #255 to a windows control.


Since the keybd_event() function only accepts key values up to 254, how can I send the keystroke #255 to a Windows control?   

    This can be very useful for entering a value in an edit control for a foreign, symbol, or wingding character. The following example shows how to stuff the keyboard with the #255 character and direct it to any Window control. Note: This method should not be used to enter characters that could normally be processed by the keybd_event() function.

    procedure TForm .Button Click(Sender: TObject); var KeyData : packed record RepeatCount : word; ScanCode : byte; Bits : byte; end; begin {Let the button repaint} Application.ProcessMessages; {Set the focus to the window} Edit .SetFocus; {Send a right so the char is added to the end of the line} SimulateKeyStroke(VK_RIGHT, 0); {Let the app get the message} Application.ProcessMessages; FillChar(KeyData, sizeof(KeyData), #0); KeyData.ScanCode := 255; KeyData.RepeatCount := ; SendMessage(Edit .Handle, WM_KEYDOWN, 255, LongInt(KeyData)); KeyData.Bits := KeyData.Bits or ( shl 30); KeyData.Bits := KeyData.Bits or ( shl 3 ); SendMessage(Edit .Handle, WM_KEYUP, 255, LongInt(KeyData)); KeyData.Bits := KeyData.Bits and not ( shl 30); KeyData.Bits := KeyData.Bits and not ( shl 3 ); SendMessage(Edit .Handle, WM_CHAR, 255, LongInt(KeyData)); Application.ProcessMessages; end;

    7/ 6/98 4:3 :28 PM

     



  << Previous Faq     Complete List     Next Faq >>  



 
 Hits/month  2,500,000+ 
 Downloads
 (Since May 2000)
 7,393,709 
 Total Files  6,023 
 Forum msgs  7,670 
 Articles/FAQs  70+/900+ 
Kylix
Tips n Tricks
FAQs
Knowledge Base
Bug Listings
Articles
Books
Newsgroups
Links
Submissions
Testimonials
Advertising
Contact Us
About Us
Search Amazon:
Top Selling Software at Amazon

| Home/News | Downloads | Forums | Resources | Info and Facts | Testimonials |
  Site Search:
 


Comments/Problems: Webmaster@delphi32.com
Copyright © 1998-2006, Delphi32.com. All rights reserved.
Terms of Use