How do I capture the Left Alt key in Application.OnMessage?
Posted on 2002-05-18
I need to be able to detect keys that are pressed with the Left Alt key in Application.OnMessage. I have set up a simple test like this with no extra components on the form...
procedure TForm1.FormCreate(Sender: TObject);
Application.OnMessage := MyMessageHandler
procedure TForm1.MyMessageHandler(var Msg: TMsg; var Handled: Boolean);
if (Msg.message = WM_KEYDOWN) and (Msg.wParam = Ord('A')) then
Handled := True;
These key combinations show the message...
CTRL + A
Right Alt + A
However, when I press Left Alt + A, I just get a bleep - no message is displayed. Try it and you'll see. It seems that key presses with the Left Alt key are ignored by the message handler. How do I get around this? I really need to be able to detect key combinations such as Left Alt + A in Application.OnMessage. I'm using Delphi 4 Pro.
Thanks in Advance,