Default
Google

How can I disable key presses?

Applies To: C++Builder 1 or higher
Category: Knowledge Base

I want to disable the 'a' key when entering data in an edit box. How?
 
 1.
  Start a new project using File | New Application.
 
 2.
  Add an Edit and double-click the OnKeyPress event:
 
void __fastcall TForm1::Edit1KeyPress(TObject *Sender, char &Key)
{
    if(Key == 'a')
        Key = 0;
}
 
The Key parameter is not read-only and you can change its value. Setting Key to 0 disables the key press.

C++Builder Developer's Network
Copyright © Yoto Yotov



Acquiring image from ProHosting Banner Exchange