Fórum Tab/Enter em todos Forms #227451
22/04/2004
0
procedure TF_VslCli01.FormKeyPress(Sender: TObject; var Key: Char);
begin
if Key = #13 then
begin
Key := 0;
SendMessage(Self.Handle, Wm_NextDlgCtl,0,0);
end;
end;
Gostaria de saber se tem uma forma de implementar em todo o meu projeto ou terei que repetir esta rotina em todos os forms que eu criar?
Desde já agradeço qualquer ajuda.
Rony Lee
Ronylee
Curtir tópico
+ 0Posts
22/04/2004
Weverton
1 - Criar um form, implementar esse código no OnKeyPress e criar os outros forms herdando desse primeiro;
2 - Colocar um componente ApplicationEvents no form principal da aplicação e fazer o tratamento no evento OnMessage.
Gostei + 0
22/04/2004
Ronylee
Gostei + 0
23/04/2004
Eniorm
procedure TSimoFormPrincipal.ProcessaMsg(var Msg: TMsg; var Handler: Boolean); begin if (Msg.message = WM_KEYDOWN) then if not (Screen.ActiveControl is TCustomMemo) and not (Screen.ActiveControl is TButtonControl) then begin if not (Screen.ActiveControl is TCustomControl) then begin if (Msg.wParam = VK_Down) and not(Screen.ActiveControl is TListBox) and not(Screen.ActiveControl is TComboBox) then Msg.wParam:= VK_Tab; if (Msg.wParam = VK_UP) and not(Screen.ActiveControl is TListBox) and not(Screen.ActiveControl is TComboBox) then begin Msg.wParam:= VK_CLEAR; Screen.ActiveForm.Perform(WM_NextDlgCtl,1,0); end; if (Msg.wParam = VK_Escape) and not (Screen.ActiveForm is TSimoformPrincipal) then Screen.ActiveForm.Close; end; if (Msg.wParam = VK_Return) then Msg.wParam:= VK_Tab; end; end;
Agora no OnCreate do form principal:
Application.OnMessage := ProcessaMsg;
Gostei + 0
Clique aqui para fazer login e interagir na Comunidade :)