Fórum Não tenho controle sobre o enter #240292
29/06/2004
0
Olá amigos, utilizo no módulo principal da aplicação a função abaixo para mudar em toda aplicação o enter por tab, só que em um cadastro quando o usuário digitar o código e pressionar enter, quero analisar o que ele digitou, daí surge o problema, pois não tenho controle sobre está tecla.
O que posso fazer para interceder?
***************
procedure TfPrincipal.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 TfPrincipal) then
Screen.ActiveForm.Close;
end;
if (Msg.wParam = VK_Return) then
Msg.wParam:= VK_Tab;
end;
end;
*****************
No código onde preciso fazer a análise:
procedure TfCadBai.cCodBaiKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
inherited;
if Key = VK_TAB then
begin
if TrimRight(cCodBai.Text) <> ´´ then
begin
if DM.ClientDataSet_Bairros.Locate(´codbai´,StrToInt(TrimRight(cCodBai.Text)),[]) then
begin
cNomBai.Text := DM.ClientDataSet_Bairros.Fieldbyname(´NOMBAI´).asstring;
end;
end;
end;
end;
**************
Obrigado pela atenção.
Mario
O que posso fazer para interceder?
***************
procedure TfPrincipal.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 TfPrincipal) then
Screen.ActiveForm.Close;
end;
if (Msg.wParam = VK_Return) then
Msg.wParam:= VK_Tab;
end;
end;
*****************
No código onde preciso fazer a análise:
procedure TfCadBai.cCodBaiKeyDown(Sender: TObject; var Key: Word;
Shift: TShiftState);
begin
inherited;
if Key = VK_TAB then
begin
if TrimRight(cCodBai.Text) <> ´´ then
begin
if DM.ClientDataSet_Bairros.Locate(´codbai´,StrToInt(TrimRight(cCodBai.Text)),[]) then
begin
cNomBai.Text := DM.ClientDataSet_Bairros.Fieldbyname(´NOMBAI´).asstring;
end;
end;
end;
end;
**************
Obrigado pela atenção.
Mario
Aldus
Curtir tópico
+ 0
Responder
Posts
29/06/2004
Aldus
Sobe
Responder
Gostei + 0
29/06/2004
Aldus
Sobe
Responder
Gostei + 0
Clique aqui para fazer login e interagir na Comunidade :)