Title: How can I detect if a non-menu key has been pressed?
Question: How can I detect if a non-menu key has been pressed while a menu
is displayed?
Answer:
Create a message handler for the WM_MENUCHAR character message.
type
TForm1 = class(TForm)
MainMenu1: TMainMenu;
One1: TMenuItem;
Two1: TMenuItem;
THree1: TMenuItem;
private
procedure WmMenuChar(var m : TMessage); message WM_MENUCHAR;
public
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.WmMenuChar(var m : TMessage);
begin
Form1.Caption := 'Non standard menu key pressed';
m.Result := 1;
end;