procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word; Shift: TShiftState);
var Index, Pos: Cardinal; WinControl: TWinControl;
begin
Index := ControlCount;
while Index <> 0 do
begin
Dec(Index);
if (Controls[Index] is TButton) then
with Controls[Index] as TButton do
begin
Pos := System.Pos('&', Caption);
if (Pos > 0) and (Pos < Length(Caption)) and
((Key = $20) or (Key = (Byte(Caption[Pos + 1]) and $DF))) and
((ssAlt in Shift) or (ActiveControl.Name = Name)) then
OnMouseDown(nil, mbLeft, [], 0, 0);
end;
end;
end;
procedure TForm1.Button1MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
if Button <> mbLeft then Exit;
Application.MessageBox('Button 1', 'Pseudo OnClick');
end;
procedure TForm1.Button2MouseDown(Sender: TObject; Button: TMouseButton; Shift: TShiftState; X, Y: Integer);
begin
if Button <> mbLeft then Exit;
Application.MessageBox('Button 2', 'Pseudo OnClick');
end;