usando Teclas de atalho Ctrl G
como faço pra pega quando o usuario pressionar Ctrl + G por exemplo. usarei isso para inserir gravar etc... sempre facilita né afinal naum precisa ta usando o mause...
Picyka
Curtidas 0
Respostas
Mayron Cachina
04/10/2007
vc vai ter que ir no evento OnKeyDown do Form ou usar HotKey...
ou
//In the main forms OnCreate //handler assign the hotkey: If not RegisterHotkey (Handle, 1, MOD_ALT or MOD_SHIFT, VK_F9) Then ShowMessage(´Unable to assign Alt-Shift-F9 as hotkey.´) ; //In the main forms //OnClose event remove the handler: UnRegisterHotkey( Handle, 1 ) ; //Add a handler for the //WM_HOTKEY message to the form: private // form declaration Procedure WMHotkey( Var msg: TWMHotkey ) ; message WM_HOTKEY; Procedure TForm1.WMHotkey( Var msg: TWMHotkey ) ; Begin If msg.hotkey = 1 Then Begin If IsIconic( Application.Handle ) Then Application.Restore; BringToFront; End; End;
ou
procedure TForm1.FormKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
// Declare as seguintes variáveis globais
// Buffer : String;
// KeyCount : Word;
{
//Exemplo 1
//Verifica se digitou os seguintes caracteres
//e se o Alt está pressionado
if (Chr(VkKeyScan(Chr(Key))) in [´E´,´G´]) and (Shift = [ssAlt]) then
begin
Buffer := Buffer + AnsiUpperCase(Chr(VkKeyScan(Chr(Key))));
//verifica se está na ordem
if (Pos(´EGG´, Buffer) <> 0) then
begin
MessageDlg(´Achou um ovo de páscoa!´, mtInformation, [mbOK], 0);
Buffer := ´´;
end;
end
else
Buffer := ´´;
}
{
//Exmplo 2
//Deve-se pressionar Ctrl + Alt + E + G + G
if Shift= [ssCtrl,ssAlt] then
Case KeyCount of
0:if Key = 69 then Inc(KeyCount);
1:if Key = 71 then Inc(KeyCount);
2:if Key = 71 then Inc(KeyCount);
end
else
KeyCount := 0;
if KeyCount = 3 then
begin
ShowMessage(´Achou´);
KeyCount := 0;
end;
}
end;GOSTEI 0
Massuda
04/10/2007
Se essa ação estiver implementada via TAction ou TMenuItem, você pode simplesmente atribuir ´Ctrl G´ à propreidade ShortCut.
GOSTEI 0