Question and Answer Database FAQ1445D.txt How can I detect if a non-menu key has been pressed? Category :VCL Platform :All Product :All 32 bit 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. Example: unit Unit1; interface uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, Menus; type TForm1 = class(TForm) MainMenu1: TMainMenu; One1: TMenuItem; Two1: TMenuItem; THree1: TMenuItem; private { Private declarations } procedure WmMenuChar(var m : TMessage); message WM_MENUCHAR; public { Public declarations } 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; end. 7/16/98 4:31:28 PM
Last Modified: 01-SEP-99