Mudança de foco com enter
Como programar eventos para que a tecla enter faça o trabalho da tecla TAB ?
Já utilizei
if key=VK_RETURN then Perform(Wm_nextDlgCtl,0,0);
mas não deu certo, o que posso fazer ?
Já utilizei
if key=VK_RETURN then Perform(Wm_nextDlgCtl,0,0);
mas não deu certo, o que posso fazer ?
Hemerson
Curtidas 0
Respostas
Patrick
18/09/2003
cara, eu uso assim:
na sessão de declaração das procedures:
procedure ProcessaMsg(Var Msg: TMsg; var Handled: Boolean);
e depois da diretiva de compilação: {$R *.dfm}
uso a procedure....:
procedure TfPrincipal.ProcessaMsg(var Msg: TMsg; var Handled: 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 then
Msg.wParam:=VK_Tab;
If Msg.wParam=VK_UP then
begin
Msg.wParam:=VK_CLEAR;
Screen.ActiveForm.Perform(WM_NextDlgCtl,1,0);
end;
If Msg.wParam=VK_Escape then
Close
end;
If Msg.wParam=VK_Return then
Msg.wParam:=Vk_Tab;
end;
end;
ele usa o enter, o tab, as setas.....
testa e ve se funciona!!!!
na sessão de declaração das procedures:
procedure ProcessaMsg(Var Msg: TMsg; var Handled: Boolean);
e depois da diretiva de compilação: {$R *.dfm}
uso a procedure....:
procedure TfPrincipal.ProcessaMsg(var Msg: TMsg; var Handled: 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 then
Msg.wParam:=VK_Tab;
If Msg.wParam=VK_UP then
begin
Msg.wParam:=VK_CLEAR;
Screen.ActiveForm.Perform(WM_NextDlgCtl,1,0);
end;
If Msg.wParam=VK_Escape then
Close
end;
If Msg.wParam=VK_Return then
Msg.wParam:=Vk_Tab;
end;
end;
ele usa o enter, o tab, as setas.....
testa e ve se funciona!!!!
GOSTEI 0
E_gama
18/09/2003
Em minhas aplicações eu utilizo assim:
- Configuro a propriedade [b:7f618474b1]KeyPreview[/b:7f618474b1] do TForm para [b:7f618474b1]True[/b:7f618474b1]
- Depois, no OnKeyPress do TForm faço:
- Configuro a propriedade [b:7f618474b1]KeyPreview[/b:7f618474b1] do TForm para [b:7f618474b1]True[/b:7f618474b1]
- Depois, no OnKeyPress do TForm faço:
if Key = #13 then begin Key := 0; SelectNext(ActiveControl, True, True); end;
GOSTEI 0
Tio Frank
18/09/2003
SE FOR UM CAMPO PARA ACEITAR SÓ LETRAS
begin
IF KEY = #13 THEN
EDIT.SETFOCUS;
IF KEY = 27 THEN
EDIT.SETFOCUS;
IF (KEY IN [´0´..´9´]) THEN
KEY := 0;
end;
SE FOR UM CAMPO PARA ACEITAR SÓ NÚMEROS :
begin
IF KEY = 13 THEN
EDIT.SETFOCUS;
IF KEY = 27 THEN
EDIT.SETFOCUS;
IF NOT (KEY IN [´0´..´9´, 8]) THEN
KEY := 0;
end;
begin
IF KEY = #13 THEN
EDIT.SETFOCUS;
IF KEY = 27 THEN
EDIT.SETFOCUS;
IF (KEY IN [´0´..´9´]) THEN
KEY := 0;
end;
SE FOR UM CAMPO PARA ACEITAR SÓ NÚMEROS :
begin
IF KEY = 13 THEN
EDIT.SETFOCUS;
IF KEY = 27 THEN
EDIT.SETFOCUS;
IF NOT (KEY IN [´0´..´9´, 8]) THEN
KEY := 0;
end;
GOSTEI 0