1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
|
//==============================================================================
//== Creation de shortcut globalement dans une application.
//== Si la touche est traitée, Mettre Handled:=TRUE;
//==============================================================================
procedure TForm1.AppOnShortCut(var Msg: TWMKey; var Handled: Boolean);
begin
//Quand Shift ou Control sont appuyés...GetAsyncKeyState retourne <>0
if ( ( GetAsyncKeyState(VK_SHIFT)=0) and ( GetAsyncKeyState(VK_CONTROL)=0)) then
begin
//ShowMessage(intToStr(GetKeyState(VK_CONTROL)));
case msg.CharCode of
VK_F1:begin
ShowMessage('Touche F1') ;
Handled := TRUE;
end;
{comme ca jusqu'à F12}
VK_F12:begin
ShowMessage('Touche F12') ;
Handled := TRUE;
end;
end;
end;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
application.OnShortCut:=AppOnShortCut;
end; |
Partager