Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Keystroke prevention

Status
Not open for further replies.

TheDelphiBeginner

Programmer
Sep 29, 2003
5
0
0
US
Is there a way to intercept Alt+Esc key combination, in a Delphi application?
I tried the following:

begin
if ssAlt in Shift then
case Key of
27:
begin
ShowMessage('Alt + Esc is pressed');
end;
end;
end;

but Key gets a value of '18' (which is 'Alt') during the run-time when goes through the loop.
However, when I use Case of "N" (for example), it works fine.

Do you think Alt+Esc is a 'protected' Windows combination, that cannot be disabled, kind of like Ctrl+Alt+Esc?
 
Hi TheDelphiBeginner,

You may want to drop an eye to WM_Char and WM_DIALOGCHAR
Windows messages in the MS SDK Help file that ships with
Delphi.

In order to prevent your next question, you can handle
messages in this way :

Type

TMyForm = class( TForm )
private
procedure HandleMessage( Mesg : TMessage );message WM_Message; // Here you define the message to handle
end;

procedure TMyForm.HandleMessage( Mesg : TMessage );
begin
// Your code here
inherited;// better to call the previous handler, you never know
end;

Please notice that you can place your code before or
after the "inherited" call, according to the type of
result you want to achieve.

As a further note, please *always* remember to call
"inherited" since lots of messages have specific
actions to be taken.

Cheers,

Andrew
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top