The following example demonstrates trapping the CM_DIALOGCHAR
message at the form level. This will give you an opportunity to
respond to a dialog character only if the alt key is held down,
preventing the default handeling of the character shortcuts.
Example:
type
TForm = class(TForm)
Button : TButton;
StringGrid : TStringGrid;
procedure FormCreate(Sender: TObject);
procedure Button Click(Sender: TObject);
procedure StringGrid KeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
private
{ Private declarations }
procedure CMDialogChar(var Message: TCMDialogChar);
message CM_DIALOGCHAR;
public
{ Public declarations }
end;
var
Form : TForm ;
implementation
{$R *.DFM}
procedure TForm .FormCreate(Sender: TObject);
begin
Button .Caption := 'E&xit';
end;
procedure TForm .Button Click(Sender: TObject);
begin
Application.Terminate;
end;
procedure TForm .StringGrid KeyDown(Sender: TObject;
var Key: Word; Shift: TShiftState);
begin
ShowMessage('Grid keypress = ' + Char(Key));
Key := 0;
end;
procedure TForm .CMDialogChar(var Message: TCMDialogChar);
begin
if ssAlt in KeyDataToShiftState(Message.KeyData) then
inherited;
end;
7/ 6/98 4:3 :28 PM