Delphi32.com - Home!
| Home/News | Downloads | Forums | D32 Magazine | Resources | Info and Facts |  
 
 Detecting tab key press


Since the KeyPress and the KeyDown events do not get called for the tab key, how do I trap the tab key at the form level?   

    At form level, the tab key is generally handled by Windows. The following example demonstrates creating a CM_Dialog message handler to trap for Dialog keys. The code surfaces the tab character through the KeyPress event. Example:

    type
      TForm  = class(TForm)
      private
        procedure CMDialogKey( Var msg: TCMDialogKey );
         message CM_DIALOGKEY;
      end;

    var Form : TForm ;

    implementation

    {$R *.DFM}

    procedure TForm .CMDialogKey(var msg: TCMDialogKey); begin if msg.Charcode <> VK_TAB then inherited; end;

    procedure TForm .FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState); begin if Key = VK_TAB then Form .Caption := 'Tab Key Down!'; end;

     



  << 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