Delphi - En utilisant les TApplicationEvents événement OnShortCut pour détecter Alt + C touches

StackOverflow https://stackoverflow.com/questions/734990

  •  09-09-2019
  •  | 
  •  

Question

Je suis en utilisant TApplicationEvents événement OnShortCut pour obtenir clavier d'application des raccourcis dans un programme Delphi.

En utilisant le code suivant:

procedure TForm1.ApplicationEvents1ShortCut(var Msg: TWMKey; var Handled: Boolean) ;
begin
   if (Msg.CharCode = VK_F9) then
   begin
     ShowMessage('F9 pressed!') ;
     Handled := True;
   end;
end;

Question:

Comment puis-je détecter quand 'ALT C' a été appuyé?

Était-ce utile?

La solution

comme ceci:

procedure TForm1.ApplicationEvents1ShortCut(var Msg: TWMKey;
  var Handled: Boolean);
begin
  if (Msg.CharCode = Ord('C'))
    and (HiWord(Msg.KeyData) and KF_ALTDOWN <> 0)
  then begin
    ShowMessage('Alt+C pressed!') ;
    Handled := TRUE;
  end;
end;

S'il vous plaît noter que l'utilisation de Alt et une touche est seulement un mauvais choix pour un raccourci, que le système utilise pour activer les éléments du menu ou des commandes de dialogue.

Autres conseils

Ou vous pouvez créer TAction simple, ils raccourcis mange avant d'autres.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top